#!/bin/bash -x
+# Copyright (C) 2016 Ian Kelling
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
# # 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