shellcheck and fix checkrestart false positive
[distro-setup] / distro-begin
index 690bf856a220662054407508ccd554ac58aef350..633e8d1e3c326085460c9e97784f9756a5c85a0e 100755 (executable)
@@ -65,7 +65,8 @@ fi
 
 
 ##### variables/env setup
-script_dir="$(readlink -f "$BASH_SOURCE")"; script_dir=${script_dir%/*}
+script_dir="$(readlink -f "${BASH_SOURCE[@]}")"; script_dir=${script_dir%/*}
+# shellcheck source=./pkgs
 source $script_dir/pkgs
 set +x
 source /a/bin/distro-functions/src/identify-distros
@@ -82,7 +83,7 @@ has_btrfs() { ! linode; }
 home_network() { ! linode; }
 encrypted() { has_p; }
 shopt -s extglob
-export GLOBIGNORE=*/.:*/..
+export GLOBIGNORE="*/.:*/.."
 umask 022
 PATH="/a/exe:$PATH"
 sed="sed --follow-symlinks"
@@ -138,8 +139,8 @@ EOF
   sudo systemctl start keyscriptoff.service
 
   # from /usr/share/doc/dropbear-initramfs/README.initramfs.gz
-  while read m _; do /sbin/modinfo -F filename "$m"; done </proc/modules | \
-    sed -nr "s@^/lib/modules/`uname -r`/kernel/drivers/net(/.*)?/([^/]+)\.ko\$@\2@p" \
+  while read -r m _; do /sbin/modinfo -F filename "$m"; done </proc/modules | \
+    sed -nr "s@^/lib/modules/$(uname -r)/kernel/drivers/net(/.*)?/([^/]+)\.ko\$@\2@p" \
     | sudo dd of=/etc/initramfs-tools/modules
   sudo apt-get -y install initramfs-tools-core
   # initram auth keys get setup with rootsshsync
@@ -213,6 +214,7 @@ conflink
 set +x
 err-allow
 source /etc/profile.d/environment.sh
+# shellcheck source=./.bashrc
 source ~/.bashrc
 err-catch
 $interactive || set -x
@@ -448,7 +450,7 @@ if has_btrfs || home_network; then
   pi nfs-common
   s dd of=/root/imount <<'EOF'
 #!/bin/bash
-[[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 for dir in /i /mnt/iroot /k /kr /w; do
@@ -512,12 +514,7 @@ fi
 
 
 ##### setup email
-if isdeb; then
-  mail-setup exim4
-else
-  # todo: probably broken
-  mail-setup postfix
-fi
+mail-setup
 
 #### ubuntu nicety
 if isubuntu; then
@@ -580,6 +577,7 @@ if has_x; then
     # https://wiki.archlinux.org/index.php/Xinitrc
     for homedir in /home/*; do
       cp /etc/X11/xinit/xinitrc $homedir/.xinitrc
+      # shellcheck disable=SC2016
       $sed -ri '/^ *twm\b/,$d' $homedir/.xinitrc
       tee -a $homedir/.xinitrc <<'EOF'
 /a/bin/desktop-20-autostart.sh