OSDN Git Service

66boot-* scripts: fix or disable shellcheck warnings.
authormobinmob <mobinmob@disroot.org>
Sat, 19 Feb 2022 08:22:14 +0000 (10:22 +0200)
committermobinmob <mobinmob@disroot.org>
Sat, 19 Feb 2022 08:22:14 +0000 (10:22 +0200)
- 66-initial-setup: the style warning in line 64 is silenced.
- 6boot-rcdotconf:
    - separate declaration and export of variables
    - disable warning in line 95
    - fix quoting.
- 66boot-storage-autoconf:
    - separate declaration and export of variables
    - silence warnings in lines 113 and 136-148.

srcpkgs/boot-66serv/files/66boot-initial-setup
srcpkgs/boot-66serv/files/66boot-rcdotconf
srcpkgs/boot-66serv/files/66boot-storage-autoconf

index bf7a29d..841aa9d 100755 (executable)
@@ -60,4 +60,5 @@ warn=$( sed -n -e "/##\ \[STARTWARN\]/p" /etc/66rc.conf | tr -d '[:space:]') &&
 66-tree -z -S default runit || msg_trees runit
 
 # Print on succesfull completion
+# shellcheck disable=SC2181
 if [ "$?" = 0 ]; then 66-yeller %g "Basic trees created and services enabled succesfully!"; fi
index b7be4c3..8ff2823 100755 (executable)
@@ -43,7 +43,7 @@ apply_conf_from_to(){
 
 set_hostname() { 
        # ${1} HOSTNAME value
-       [ -r /etc/hostname ] && export HOSTNAME1="$( cat /etc/hostname )"
+       [ -r /etc/hostname ] && HOSTNAME1="$( cat /etc/hostname )" && export HOSTNAME1
        
        if [ -n "${1}" ]
        then
@@ -84,12 +84,14 @@ reverting to the default [4]." %n
 check_tz() {
        # On installation timezone can be set by symlink and not by the 
        # TIMEZONE key in rc.conf. In that case follow the symlink.
-       if [ $(realpath /etc/localtime | cut -d / -f 1,2,3,4) = "/usr/share/zoneinfo" ]; then
-               export TIMEZONE=$(realpath /etc/localtime | cut -d / -f 5,6)
+       if [ "$(realpath /etc/localtime | cut -d / -f 1,2,3,4)" = "/usr/share/zoneinfo" ]; then
+               TIMEZONE="$(realpath /etc/localtime | cut -d / -f 5,6)"
+               export TIMEZONE
        fi
 }
 
 
+# shellcheck disable=SC1091
 . /etc/rc.conf
 
 check_tz
@@ -104,4 +106,4 @@ set_ttys TTYS TTY "$TTYS"
 
 66-yeller %g "Please re-enable the boot@system service
 for the changes to take effect by running (as root):
-'66-enable -F -t boot boot@system'" %n
\ No newline at end of file
+'66-enable -F -t boot boot@system' " %n
\ No newline at end of file
index ec4ff5e..793ab07 100755 (executable)
@@ -30,7 +30,8 @@ detect_fs() {
 
 detect_swapfile() {
         # Finds swap references in /etc/fstab.
-        export swapfile_detected="$(awk '!/^(#)/' /etc/fstab | awk '$3=="swap" ' | wc -l )"
+        swapfile_detected="$(awk '!/^(#)/' /etc/fstab | awk '$3=="swap" ' | wc -l )"
+        export swapfile_detected
 }
 
 detect_util() {
@@ -108,7 +109,7 @@ detect_fs hpt37x_raid_member
 detect_fs adaptec_raid_member
 detect_fs jmicron_raid_member
 
-#SC2154
+# shellcheck disable=SC2154
 dmraid_detected=$((ddf_raid_member_detected+isw_raid_member_detected\
 +lsi_mega_raid_member_detected+via_raid_member_detected\
 +silicon_medley_raid_member_detected+nvidia_raid_member_detected\
@@ -131,12 +132,19 @@ detect_util dmraid_util dmraid
 detect_util swap_util swapon
 
 # Finally detect and apply the configuration
+# shellcheck disable=SC2154
 check_and_apply_conf "$btrfs_detected" "$btrfs_util_exists" BTRFS BTRFS btrfs "[btrfs_progs]"
+# shellcheck disable=SC2154
 check_and_apply_conf "$zfs_detected" "$zfs_util_exists" ZFS ZFS zfs "[zfs]"
+# shellcheck disable=SC2154
 check_and_apply_conf_zpool "$zfs_detected" "$zfs_util_exists" ZFS
+# shellcheck disable=SC2154
 check_and_apply_conf "$crypto_LUKS_detected" "$luks_util_exists" CRYPTTAB LUKS cryptsetup "[cryptsetup]"
+# shellcheck disable=SC2154
 check_and_apply_conf "$LVM2_member_detected" "$lvm_util_exists" LVM LVM lvchange "[lvm2]"
+# shellcheck disable=SC2154
 check_and_apply_conf "$dmraid_detected" "$dmraid_util_exists" DMRAID DMRAID dmraid "[dmraid]"
+# shellcheck disable=SC2154
 check_and_apply_conf "$swap_detected" "$swap_util_exists" SWAP SWAP swapon "[util-linux]"