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
# # 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
# 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
# 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
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.
sfs=$iso/arch/x86_64/airootfs.sfs
rm -rf $iso
ex $iso.iso
-sed -i -f - $iso/arch/boot/syslinux/archiso_pxe64.cfg <<EOF
+sed -i --follow-symlinks -f - $iso/arch/boot/syslinux/archiso_pxe64.cfg <<EOF
1itotaltimeout 1
/^LABEL arch64_nfs/a menu default
s/^APPEND .*/\0 script=arch-iso-init.sh/
ubuntu-14.04)
wget -q https://help.ubuntu.com/lts/installation-guide/$preseed
wget -qN http://archive.ubuntu.com/ubuntu/dists/trusty/$neboot_path
- sed -ri 's!^tasksel tasksel/first multiselect .*!#\0!' $preseed
+ sed -ri --follow-symlinks 's!^tasksel tasksel/first multiselect .*!#\0!' $preseed
echo 'tasksel tasksel/first multiselect ubuntu-server, openssh-server' >>$preseed
;;
debian-jessie)
# 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
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)
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
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"
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"
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}' \
} >>/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
# 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