avoid future errors with overwriting symlnks
[automated-distro-installer] / arch-init-chroot
index 634991c471a7bb1f939423c4fa025844b7cebadf..abd9a08ae8c3cc67abbf9e2cf6caa21ad37fa76e 100755 (executable)
@@ -7,7 +7,6 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 pacman -Syu
 
-echo $hostname > /etc/hostname
 [[ -L /etc/localtime ]] || ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
 l=en_US.UTF-8
 echo "$l UTF-8" > /etc/locale.gen
@@ -25,9 +24,9 @@ echo "LANG=$l" > /etc/locale.conf
 # # https://bugs.archlinux.org/task/42884
 # # disabled, as with just the module, startup spammed something about
 # # command takes a device name and something else.
-# sed -ri '/^ *MODULES *=.*btrfs/!s/^( *MODULES *=.*)"/\1 btrfs"/' /etc/mkinitcpio.conf
+# sed -ri --follow-symlinks '/^ *MODULES *=.*btrfs/!s/^( *MODULES *=.*)"/\1 btrfs"/' /etc/mkinitcpio.conf
 # # remove extra space
-# sed -ri 's/^( *MODULES *=[^"]*)" */\1"/' /etc/mkinitcpio.conf
+# sed -ri --follow-symlinks 's/^( *MODULES *=[^"]*)" */\1"/' /etc/mkinitcpio.conf
 
 
 
@@ -75,20 +74,20 @@ base=/usr/lib/initcpio
 # https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_entire_system#Configuring_mkinitcpio_2
 # used to have lvm2 after encrypt for lvm, but not using lvm anymore
 for x in encrypt btrfs; do
-    sed -ri -f - /etc/mkinitcpio.conf <<EOF
+    sed -ri --follow-symlinks -f - /etc/mkinitcpio.conf <<EOF
 /^ *HOOKS.*\b$x\b/!s/^( *HOOKS=.*)filesystems/\1$x filesystems/
 EOF
 done
 
 # this is the default file, otherwise you use cryptkey=device:fstype:path
-sed -ri -f - /etc/mkinitcpio.conf <<EOF
+sed -ri --follow-symlinks -f - /etc/mkinitcpio.conf <<EOF
 s#^\s*FILES=.*#FILES="/crypto_keyfile.bin"#
 EOF
 echo "$0: FILES:"
 grep FILES /etc/mkinitcpio.conf
 k_args="${k_args[*]}"
 echo "$0: grub cmdline additions: $k_args"
-sed -ri -f - /etc/default/grub <<EOF
+sed -ri --follow-symlinks -f - /etc/default/grub <<EOF
 \%$k_args%!s%^ *GRUB_CMDLINE_LINUX_DEFAULT *= *"%\0$k_args %
 EOF
 
@@ -97,7 +96,7 @@ mkinitcpio -p linux
 
 # remove the default quiet arg.
 # this doesn't seem to affect anything, so leave it alone.
-#sed -ri 's/^( *GRUB_CMDLINE_LINUX_DEFAULT *= *.*) ?\bquiet\b(.*)/\1\2/' /etc/default/grub
+#sed -ri --follow-symlinks 's/^( *GRUB_CMDLINE_LINUX_DEFAULT *= *.*) ?\bquiet\b(.*)/\1\2/' /etc/default/grub
 
 # https://wiki.archlinux.org/index.php/GRUB#Install_to_disk
 for dev in $BOOT_DEVICE; do
@@ -105,28 +104,14 @@ for dev in $BOOT_DEVICE; do
 done
 grub-mkconfig -o /boot/grub/grub.cfg
 # gtk2 is an optional dependency of unison.
-# debian's unison binary has it linked in,
-# so i install it so I can use the same binary for syncing
-# the two distros.
-pacman -S --noconfirm openssh unison gtk2 rsync
+# I know Im gonna want the gui, so just doing it now.
+pacman -S --noconfirm openssh rsync
 
-echo "root:$ROOTPW" | chpasswd -e
 
 pacman -S --noconfirm sudo
 
-# 9 = user already exists. so we are idempotent.
-useradd -m -p "$ROOTPW" ian || [[ $? == 9 ]]
-
-if [[ $hostname == frodo ]]; then
-    useradd -m -p "$TPPASS" traci || [[ $? == 9 ]]
-else
-    useradd -m traci || [[ $? == 9 ]]
-fi
-# comparing ian's groups to traci, I see none she should join on arch
-usermod -a -G traci ian
-
-
-/root/distro-install-common/end
+. /a/bin/fai/fai-wrapper
+/a/bin/fai/fai/config/distro-install-common/end
 systemctl enable sshd
 
 rm -rf /home/ian/.ssh
@@ -139,7 +124,7 @@ usermod -aG games,rfkill,users,uucp,wheel ian
 
 pacman -S --noconfirm net-tools # for route
 # get the mac of the interface used by the broadcast route.
-mac=$(cat /sys/class/net/$(route -n | sed -rn 's/^0\.0\.0\.0.*[[:space:]]([^[:space:]]+)[[:space:]]*$/\1/p')/address)
+mac=$(cat /sys/class/net/$(route -n | sed -rn --follow-symlinks 's/^0\.0\.0\.0.*[[:space:]]([^[:space:]]+)[[:space:]]*$/\1/p')/address)
 
 
 # simple bridge.