From affd7d3cdd0671dcca07f29de9c86b5e3b57ea1f Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Tue, 9 Aug 2016 15:51:56 -0700 Subject: [PATCH] avoid future errors with overwriting symlnks --- arch-init | 2 +- arch-init-chroot | 14 +++++++------- arch-pxe | 2 +- debian-preseed | 15 ++++++++------- fai/config/class/50-host-classes | 2 +- fai/config/distro-install-common/end | 2 +- faiserver-disable | 2 +- faiserver-enable | 2 +- faiserver-setup | 11 ++++++----- 9 files changed, 27 insertions(+), 25 deletions(-) diff --git a/arch-init b/arch-init index 36b77c6..0ce3bf0 100755 --- a/arch-init +++ b/arch-init @@ -57,7 +57,7 @@ export bootn=3 export swapn=2 export BOOT_DEVICE export ROOT_PARTITIONS -sed -ri "/^crypt_dev_\S+$rootn /d" /tmp/fai/crypttab +sed -ri --follow-symlinks "/^crypt_dev_\S+$rootn /d" /tmp/fai/crypttab if ! $already_partitioned; then mount -o subvol=root_$DISTRO $ROOT_PARTITION /mnt diff --git a/arch-init-chroot b/arch-init-chroot index c6e4993..abd9a08 100755 --- a/arch-init-chroot +++ b/arch-init-chroot @@ -24,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 @@ -74,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 <>$preseed ;; debian-jessie) @@ -86,23 +86,24 @@ tar xzf netboot.tar.gz # keymap=us is only needed for debian. pxe_cfg=${distro%-*}-installer/amd64/boot-screens/txt.cfg -sed -ri "s#^[[:space:]]*append[[:space:]]#\0auto priority=critical locale=en_US.UTF-8 netcfg/choose_interface=auto url=tftp://$ip/example-preseed.txt keymap=us#" $pxe_cfg +sed="sed -ri --follow-symlinks" +$sed "s#^[[:space:]]*append[[:space:]]#\0auto priority=critical locale=en_US.UTF-8 netcfg/choose_interface=auto url=tftp://$ip/example-preseed.txt keymap=us#" $pxe_cfg # various google results say timeout x will result in doing the default thing, # but that doesn't happen. no idea why. Maybe it needed to be part of the label. echo 'totaltimeout 1' | tee -a $pxe_cfg if $interactive_partition; then - sed -ri 's/^d-i[[:space:]]partman.*/#\0/' $preseed + $sed 's/^d-i[[:space:]]partman.*/#\0/' $preseed # at least in ubuntu, this does automatic selection of boot device, # and on a server where we setup raid, it choose sda, and failed # and the whole installation could not be salvaged. - sed -ri 's/^d-i[[:space:]]grub-installer.*/#\0/' $preseed + $sed 's/^d-i[[:space:]]grub-installer.*/#\0/' $preseed fi -sed -ri "s#(^d-i time/zone string US/).*#\1Pacific#" $preseed -sed -ri '/^xserver-xorg/,/[^\\$]/ s/.*/#\0/' $preseed +$sed "s#(^d-i time/zone string US/).*#\1Pacific#" $preseed +$sed '/^xserver-xorg/,/[^\\$]/ s/.*/#\0/' $preseed # we set the locale in kernel args. maybe we don't need to. this overrides it. -sed -ri 's!^d-i[[:space:]]debian-installer/locale[[:space:]].*!#\0!' $preseed +$sed 's!^d-i[[:space:]]debian-installer/locale[[:space:]].*!#\0!' $preseed # for secure pass, set the shadow option with mkpasswd -s -m sha-512 < passfile diff --git a/fai/config/class/50-host-classes b/fai/config/class/50-host-classes index 3548b1f..ef70239 100755 --- a/fai/config/class/50-host-classes +++ b/fai/config/class/50-host-classes @@ -12,7 +12,7 @@ case $HOSTNAME in x2) echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;; tp) - echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT STABLE" ;; + echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;; frodo) echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;; treetowl) diff --git a/fai/config/distro-install-common/end b/fai/config/distro-install-common/end index 6be266e..390c204 100755 --- a/fai/config/distro-install-common/end +++ b/fai/config/distro-install-common/end @@ -62,7 +62,7 @@ $ROOTCMD usermod -a -G traci ian f=$target/etc/sysctl.d/99-sysctl.conf key=fs.inotify.max_user_watches -if [[ -e $f ]]; then sed -ri "/^\s*$key\s*=/d" $f; fi +if [[ -e $f ]]; then sed -ri --follow-symlinks "/^\s*$key\s*=/d" $f; fi echo "fs.inotify.max_user_watches = 1000000" >> $f # applies it. it would be also be applied after a reboot $ROOTCMD sysctl --system diff --git a/faiserver-disable b/faiserver-disable index 7893524..8f920d8 100755 --- a/faiserver-disable +++ b/faiserver-disable @@ -15,4 +15,4 @@ if [[ $1 ]]; then usage 1 fi -ssh root@$(chost faiserver) "sed -ri 's,^/srv/fai/,#\0,' /etc/exports; exportfs -ra" +ssh root@$(chost faiserver) "sed -ri --follow-symlinks 's,^/srv/fai/,#\0,' /etc/exports; exportfs -ra" diff --git a/faiserver-enable b/faiserver-enable index a71227c..66e0bee 100755 --- a/faiserver-enable +++ b/faiserver-enable @@ -15,4 +15,4 @@ if [[ $1 ]]; then usage 1 fi -ssh root@$(chost faiserver) "sed -ri 's,^\s*#\s*(/srv/fai/.*),\1,' /etc/exports; exportfs -ra" +ssh root@$(chost faiserver) "sed -ri --follow-symlinks 's,^\s*#\s*(/srv/fai/.*),\1,' /etc/exports; exportfs -ra" diff --git a/faiserver-setup b/faiserver-setup index 0510b40..b9b6d74 100755 --- a/faiserver-setup +++ b/faiserver-setup @@ -34,12 +34,13 @@ if [[ $to_install ]]; then apt-get -y install ${to_install[@]} fi -sed -i 's/^#deb/deb/' /etc/fai/apt/sources.list -sed -i 's/#LOGUSER/LOGUSER/' /etc/fai/fai.conf +sed="sed -ri --follow-symlinks" +$sed 's/^#deb/deb/' /etc/fai/apt/sources.list +$sed 's/#LOGUSER/LOGUSER/' /etc/fai/fai.conf # from man fai-make-nfsroot, # figured out after partitioning ignored my crypt partition if ! grep cryptsetup /etc/fai/NFSROOT &>/dev/null; then - sed -ri '/^PACKAGES install$/a cryptsetup' /etc/fai/NFSROOT + $sed '/^PACKAGES install$/a cryptsetup' /etc/fai/NFSROOT fi fai-setup -vf { head -n 1 /srv/fai/nfsroot/root/.ssh/known_hosts | awk '{print $1}' \ @@ -47,7 +48,7 @@ fai-setup -vf } >>/srv/fai/nfsroot/root/.ssh/known_hosts # this does not alter the config on a new install -sed -ri 's#^([[:space:]]*TFTP_DIRECTORY[[:space:]]*=).*#\1"/srv/tftp"#' \ +$sed 's#^([[:space:]]*TFTP_DIRECTORY[[:space:]]*=).*#\1"/srv/tftp"#' \ /etc/default/tftpd-hpa service tftpd-hpa restart @@ -93,6 +94,6 @@ apt-get -y install apt-cacher-ng # the logsave prompted because the hostname faiserver was uknown. # Here it was faiserver.lan when running from a faiserver vm. # When running from a normal host with faiserver alias, it was the normal hosts name. -sed -ri 's/(^[^,]+,)\S+/\1faiserver/' /srv/fai/nfsroot/root/.ssh/known_hosts +$sed 's/(^[^,]+,)\S+/\1faiserver/' /srv/fai/nfsroot/root/.ssh/known_hosts # ditch the logo banner up top which screws with less. touch /srv/fai/nfsroot/.nocolorlogo -- 2.30.2