2 # Copyright 2021 mobinmob <mobinmob@disroot.org>
3 # Use of this source code is governed by the 2-Clause BSD License
4 # that can be found in the LICENSE file.
5 # SPDX short identifier: BSD-2-Clause
7 # This script reads a **valid** rc.conf and writes the values to the
8 # corresponding configuration options in the boot@system environment file.
10 # Script must run as root.
12 [ "$user" != "0" ] && printf "You need to run this script as root! \n" && exit 1
25 # Variables for 66-yeller
26 export PROG="66boot-storage-autoconf"
27 export COLOR_ENABLED="1"
28 export CLOCK_ENABLED="0"
31 # Set configuration value ${3} from ${1} to ${2}
32 # ${1} is the conf option from /etc/rc.conf
33 # ${2} is the conf option from the boot@ conf file
34 # ${3} is the value from the /etc/rc.conf option/var
37 66-env -t boot -r "${2}"=!"${3}" boot@system
38 66-yeller %g "${2} set to [${3}]." %n
44 [ -r /etc/hostname ] && export HOSTNAME1="$( cat /etc/hostname )"
48 66-env -t boot -r HOSTNAME=!"${1}" boot@system
49 66-yeller %g "HOSTNAME set to [${1}]." %n
50 elif [ -n "$HOSTNAME1" ]
52 66-env -t boot -r HOSTNAME=!"$HOSTNAME1" boot@system
53 66-yeller %g "HOSTNAME set to [$HOSTNAME1]." %n
54 elif [ -z "${1}" ] && [ -z "$HOSTNAME1" ]
56 66-env -t boot -r HOSTNAME=!void-live boot@system
57 66-yeller -W %b "No HOSTNAME set, reverting
58 to the default [void-live]." %n
63 # Same positional args as apply_conf_from_to
66 if [ ${3} -lt 11 ] && [ ${3} -gt 0 ]
68 apply_conf_from_to "${1}" "${2}" "${3}"
70 66-env -t boot -r TTY=!4 boot@system
71 66-yeller -W %b "${3} TTYS is not valid as a tty number,
72 reverting to the default [4]." %n
76 66-env -t boot -r TTY=!4 boot@system
77 66-yeller -F %r "TTY number not set, reverting
78 to the default [4]." %n
85 set_hostname "$HOSTNAME"
86 apply_conf_from_to TIMEZONE TZ "$TIMEZONE"
87 apply_conf_from_to HARDWARECLOCK HARDWARECLOCK "$HARDWARECLOCK"
88 apply_conf_from_to KEYMAP KEYMAP "$KEYMAP"
89 apply_conf_from_to FONT_MAP FONT_MAP "$FONT_MAP"
90 apply_conf_from_to FONT FONT "$FONT"
91 apply_conf_from_to FONT_UNIMAP FONT_UNIMAP "$FONT_UNIMAP"
92 set_ttys TTYS TTY "$TTYS"