make shellcheck happy and randomise mac address

This commit is contained in:
Sebastian Hugentobler 2021-02-09 18:47:27 +01:00
parent 4b93866392
commit 3b68da77aa
Signed by: shu
GPG key ID: BB32CF3CA052C2F0
2 changed files with 23 additions and 7 deletions

View file

@ -26,12 +26,16 @@ get_value() {
secure="s"
fi
# shellcheck source=/dev/null
. "$CONFIG"
if [ -z "${!var_name}" ]; then
local def_val="${default_values[$var_name]}"
read -${secure}rp "$white$prompt [$def_val]:$nocolour " value
echo "export $var_name=\"${value:-$def_val}\"" >> "$CONFIG"
# shellcheck source=/dev/null
. "$CONFIG"
fi
@ -147,7 +151,9 @@ set_fstab() {
local install_dev
install_dev="$(get_value "install_dev" "installation device")"
local boot_uuid="$(blkid | grep ${install_dev}p1 | awk '{print $2}')"
local boot_uuid
boot_uuid="$(blkid | grep "${install_dev}p1" | awk '{print $2}')"
cat >/mnt/etc/fstab <<EOF
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
$boot_uuid /boot vfat defaults 0 0
@ -164,7 +170,13 @@ set_boot_scr() {
local boot_scr="/mnt/boot/boot.scr"
local boot_txt_mine="/mnt/boot/boot.txt.mine"
local root_uuid="$(blkid | grep ${install_dev}p2 | awk '{print $2}' | sed 's/"//g')"
local mac
mac="$(echo -n "06"; dd bs=1 count=5 if=/dev/random 2>/dev/null | hexdump -v -e '/1 " %02X"' | tr '[:upper:]' '[:lower:]')"
local root_uuid
root_uuid="$(blkid | grep "${install_dev}p2" | awk '{print $2}' | sed 's/"//g')"
sed -i "s/setenv macaddr.*/setenv macadr $mac/g" "$boot_txt"
sed -i "s|root=PARTUUID=|root=/dev/void/root rd.auto=1 cryptdevice=${root_uuid}:lvm|g" "$boot_txt"
cp "$boot_txt" "$boot_txt_mine"
@ -350,7 +362,7 @@ cmd_loop() {
while [[ "$cmd" != "exit" ]]; do
read -rp "${white}>$nocolour " cmd
if [[ " ${commands[@]} " =~ " ${cmd} " ]]; then
if [[ "${commands[*]}" == *"${cmd}"* ]]; then
$cmd
else
if [ "$cmd" != "exit" ]; then