From: mobinmob Date: Tue, 30 Nov 2021 14:51:13 +0000 (+0100) Subject: 66boot-storage-autoconf: more fixes X-Git-Url: http://git.osdn.net/view?p=avyssos%2F66-voidlinux.git;a=commitdiff_plain;h=792a825c22a9e69ae0fd8580cf9b2a9cb7d39383 66boot-storage-autoconf: more fixes - improve copyright wording (inspired by go) - use variables for 66-yeller instead of lengthy switches each time (proposed by Eric Vidal) - add some indentation fixes - use the name of the program instead of a variable. --- diff --git a/srcpkgs/boot-66serv/files/66boot-storage-autoconf b/srcpkgs/boot-66serv/files/66boot-storage-autoconf index dcf16d2..bd2e2f9 100755 --- a/srcpkgs/boot-66serv/files/66boot-storage-autoconf +++ b/srcpkgs/boot-66serv/files/66boot-storage-autoconf @@ -1,8 +1,14 @@ #!/bin/sh -#Copyright (c) 2021 mobinmob -#Licenced under the 2-Clause BSD License, available in the root of the repo, -#SPDX short identifier: BSD-2-Clause +# Copyright 2021 mobinmob +# Use of this source code is governed by the 2-Clause BSD License +# that can be found in the LICENSE file. +# SPDX short identifier: BSD-2-Clause + +# Variables for 66-yeller +export PROG="66boot-storage-autoconf" +export COLOR_ENABLED="1" +export CLOCK_ENABLED="0" # Script must run as root. user=$(id -u) @@ -23,7 +29,6 @@ detect_util() { # ${1} is the variable for the utility, in the form of "$fs_util" # ${2} is the name of the executable export "${1}"_exists="$(66-which "${2}" | wc -l)" - } check_and_apply_conf() { @@ -33,22 +38,22 @@ check_and_apply_conf() { # ${2} is in the form of $fs_name_exists # ${3} is the name of the configuration variable # ${4} is the user-friendly name for the configuration option - # ${5} is the name of the executable - # ${6} is the name of the package that contains the utility + # ${5} name of the utility needed for the block device type + # ${6} is the name of the package that contains the program # ${6} is **distribution-dependent** if [ "${1}" != "0" ] && [ "${2}" = "1" ] then 66-env -t boot -r "${3}"=!yes boot@system - 66-yeller -cz -p 66boot-storage-autoconf %g "${4} detected and enabled!" %n -elif [ "${1}" != "0" ] && [ "${2}" = "0" ] + 66-yeller %g "${4} detected and enabled!" %n + elif [ "${1}" != "0" ] && [ "${2}" = "0" ] then 66-env -t boot -r "${3}"=!no boot@system - 66-yeller -czW -p 66boot-storage-autoconf %y "${4} detected but cannot be enabled, because the ${5} utility is not installed. Please install the ${6} package and run this script again!" %n -elif [ "${1}" = "0" ] + 66-yeller -W %y "${4} detected but cannot be enabled,\n because the ${5} program is not installed. Please install the ${6} \n package and run this script again!" %n + elif [ "${1}" = "0" ] then 66-env -t boot -r "${3}"=!no boot@system - 66-yeller -cz -p 66boot-storage-autoconf %b "${4} not detected!" %n -fi + 66-yeller %b "${4} not detected!" %n + fi } @@ -60,13 +65,14 @@ check_and_apply_conf_zpool() { if [ "${1}" != "0" ] && [ "${2}" = "1" ] then 66-env -t boot -r "ZFS"=!yes boot@system - if [ -e /etc/zfs/zpool.cache ]; then - 66-env -t boot -r ZFS_IMPORT=!zpoolcache boot@system - 66-yeller -cz -p 66boot-storage-autoconf %g "ZFS import method configured as zpoolcache." %n - else - 66-env -t boot -r ZFS_IMPORT=!scan boot@system - 66-yeller -cz -p 66boot-storage-autoconf %g "ZFS import method configured as scan." %n - fi + if [ -e /etc/zfs/zpool.cache ] + then + 66-env -t boot -r ZFS_IMPORT=!zpoolcache boot@system + 66-yeller %g "ZFS import method configured as zpoolcache." %n + else + 66-env -t boot -r ZFS_IMPORT=!scan boot@system + 66-yeller %g "ZFS import method configured as scan." %n + fi fi } @@ -108,10 +114,9 @@ detect_util lvm_util lvchange detect_util dmraid_util dmraid # Finally detect and apply the configuration -#SC2154 -check_and_apply_conf "$btrfs_detected" "$btrfs_util_exists" BTRFS BTRFS "$btrfs_util" btrfs_progs -check_and_apply_conf "$zfs_detected" "$zfs_util_exists" ZFS ZFS "$zfs_util" zfs +check_and_apply_conf "$btrfs_detected" "$btrfs_util_exists" BTRFS BTRFS btrfs "[btrfs_progs]" +check_and_apply_conf "$zfs_detected" "$zfs_util_exists" ZFS ZFS zfs "[zfs]" check_and_apply_conf_zpool "$zfs_detected" "$zfs_util_exists" ZFS -check_and_apply_conf "$crypto_LUKS_detected" "$luks_util_exists" CRYPTTAB LUKS "$luks_util" cryptsetup -check_and_apply_conf "$LVM2_member_detected" "$lvm_util_exists" LVM LVM "$lvm_util" lvm2 -check_and_apply_conf "$dmraid_detected" "$dmraid_util_exists" DMRAID DMRAID "$dmraid_util" dmraid \ No newline at end of file +check_and_apply_conf "$crypto_LUKS_detected" "$luks_util_exists" CRYPTTAB LUKS cryptsetup "[cryptsetup]" +check_and_apply_conf "$LVM2_member_detected" "$lvm_util_exists" LVM LVM lvchange "[lvm2]" +check_and_apply_conf "$dmraid_detected" "$dmraid_util_exists" DMRAID DMRAID dmraid "[dmraid]"