OSDN Git Service

66boot-* : adopt a somewhat common basic structure and more.
authormobinmob <mobinmob@disroot.org>
Thu, 2 Dec 2021 20:07:43 +0000 (22:07 +0200)
committermobinmob <mobinmob@disroot.org>
Thu, 2 Dec 2021 20:07:43 +0000 (22:07 +0200)
- 66boot-initial-setup:
    - make the script more forgiving, as exiting on all failures was
    confusing at best. Now it only exits 1 on failures of 66-enable.
    - colorize all 66-* commands output, not just 66-yeller.
    - print a message for the user on successful completion.
- 66boot-storage-autoconf:
    - print a message reminding the user to re-enable the boot@system
    service for the settings to take effect.
- 66boot-rcdotconf:
    - print a message reminding the user to re-enable the boot@system
    - quote some vars
    - make a failure message into a warning one and set the color
    accordingly.

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

index 09abd73..bf7a29d 100755 (executable)
@@ -4,24 +4,27 @@
 # that can be found in the LICENSE file.
 # SPDX short identifier: BSD-2-Clause
 
-# Script must run as root, otherwise it creates trees
-# as the user.
-user=$(id -u)
-[ "$user" != "0" ] && printf "You need to run this script as root! \n" && exit 1
+# This scripts create basic trees and enable services.
+# Excluding the common posix userland commands, the script needs 66-yeller
+# (from 66-tools), 66-env, 66-tree and 66-enable (from 66).
 
 # Variables for 66-yeller
 export PROG="66boot-initial-setup"
 export COLOR_ENABLED="1"
 export CLOCK_ENABLED="0"
 
+# Script must run as root, otherwise it creates trees
+# as the user.
+user=$(id -u)
+[ "$user" != "0" ] && printf "You need to run this script as root! \n" && exit 1
+
 # Information for the user, in case of failure. 66 output is informative, this
 # is just a pointer to the docs.
 msg_trees() {
        # ${1} is the name of the tree 
-       66-yeller -F %r "An action for the [${1}] tree failed.
+       66-yeller -W %b "An action for the [${1}] tree failed.
 Check the output before this message for a possibe cause and consult
 the 66-tree documentation." %n
-       exit 1
 }
 
 msg_services() {
@@ -33,9 +36,9 @@ the 66-enable documentation." %n
 }
 
 # Create the mandatory boot tree.
-66-tree -n boot || msg_trees boot
+66-tree -nz boot || msg_trees boot
 # Enable the boot@system service in the boot tree.
-66-enable -F -t boot boot@system || msg_services boot@system
+66-enable -z -F -t boot boot@system || msg_services boot@system
 
 # Copy the default boot@conf so that it will survive updates and be accesible
 # though /etc/66rc.conf. Also, remove the warning in the first lines of the file.
@@ -45,13 +48,16 @@ warn=$( sed -n -e "/##\ \[STARTWARN\]/p" /etc/66rc.conf | tr -d '[:space:]') &&
  [ "$warn" = "##[STARTWARN]" ] && sed -i '1,5d' "$new_conf"
 
 # Create default tree, enable it and make it current.
-66-tree -nEc default || msg_trees default
+66-tree -z -nEc default || msg_trees default
 # Enable switch-initutils oneshot service in the default tree.
-66-enable switch-initutils || msg_services switch-initutils
+66-enable -z switch-initutils || msg_services switch-initutils
 
 # Create and enable runit tree.
-66-tree -nE runit || msg_trees runit
+66-tree -z -nE runit || msg_trees runit
 # Enable the runit service in the runit tree.
-66-enable -t runit runit || msg_services runit
+66-enable -z -t runit runit || msg_services runit
 # Start runit tree after the default tree.
-66-tree -S default runit || msg_trees runit
+66-tree -z -S default runit || msg_trees runit
+
+# Print on succesfull completion
+if [ "$?" = 0 ]; then 66-yeller %g "Basic trees created and services enabled succesfully!"; fi
index d5ef190..900829d 100755 (executable)
@@ -6,6 +6,14 @@
 
 # This script reads a **valid** rc.conf and writes the values to the 
 # corresponding configuration options in the boot@system environment file.
+# Excluding the common posix userland commands, the script needs 66-yeller
+# (from 66-tools) and 66-env (from 66).
+
+# Variables for 66-yeller
+export PROG="66boot-rcdotconf"
+export COLOR_ENABLED="1"
+export CLOCK_ENABLED="0"
+
 
 # Script must run as root.
 user=$(id -u)
@@ -21,12 +29,6 @@ FONT_MAP=
 FONT_UNIMAP=
 TTYS=
 
-
-# Variables for 66-yeller
-export PROG="66boot-storage-autoconf"
-export COLOR_ENABLED="1"
-export CLOCK_ENABLED="0"
-
 apply_conf_from_to(){
        # Set configuration value ${3} from ${1} to ${2}
        # ${1} is the conf option from /etc/rc.conf
@@ -63,7 +65,7 @@ set_ttys() {
        # Same positional args as apply_conf_from_to
        if  [ -n "${3}" ]
        then
-               if [ ${3} -lt 11 ] && [ ${3} -gt 0 ]
+               if [ "${3}" -lt 11 ] && [ "${3}" -gt 0 ]
                 then
                        apply_conf_from_to "${1}" "${2}" "${3}"
                else
@@ -74,7 +76,7 @@ reverting to the default [4]." %n
                fi
        else 
                66-env -t boot -r TTY=!4 boot@system
-               66-yeller -F %r "TTY number not set, reverting
+               66-yeller  -W  %b "TTY number not set, reverting
  to the default [4]." %n
        fi
 }
@@ -90,3 +92,7 @@ apply_conf_from_to FONT_MAP FONT_MAP "$FONT_MAP"
 apply_conf_from_to FONT FONT "$FONT"
 apply_conf_from_to FONT_UNIMAP FONT_UNIMAP "$FONT_UNIMAP"
 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
index bd2e2f9..38f5aa0 100755 (executable)
@@ -5,6 +5,12 @@
 # that can be found in the LICENSE file.
 # SPDX short identifier: BSD-2-Clause
 
+# This scripts determines if the system has dmraid, luks, zfs, btrfs, or
+# btrfs volumes and configures the environment file of the boot@system
+# service accordingly.
+# Excluding the common posix userland commands, the script needs 66-which and 66-yeller
+# (from 66-tools), 66-env (from 66) and blkid (from util-linux).
+
 # Variables for 66-yeller
 export PROG="66boot-storage-autoconf"
 export COLOR_ENABLED="1"
@@ -14,8 +20,7 @@ export CLOCK_ENABLED="0"
 user=$(id -u)
 [ "$user" != "0" ] && printf "You need to run this script as root!\n" && exit 1
 
-# Excluding the common posix userland commands, the script needs 66-which and 66-yeller
-# (from 66-tools), 66-env (from 66) and blkid (from util-linux).
+
 
 detect_fs() {
         # Uses blkid to detect partition TYPEs. The result is the number
@@ -120,3 +125,7 @@ check_and_apply_conf_zpool "$zfs_detected" "$zfs_util_exists" ZFS
 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]"
+
+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