ARCH="$(uname -m)"
umask 022
-# old linuxrc version:
-[ -d /cdrom ] && export LIVECD_PATH=/cdrom
-# initramfs layout until around December 2012:
-[ -d /live/image ] && export LIVECD_PATH=/live/image
-# initramfs layout since around December 2012:
-[ -d /lib/live/mount/medium ] && export LIVECD_PATH=/lib/live/mount/medium
+# initramfs layout since December 2012, backwards compatibility:
+[ -d /lib/live/mount/medium ] && export LIVECD_PATH='/lib/live/mount/medium'
+# initramfs layout since December 2018:
+[ -d /run/live/medium ] && export LIVECD_PATH='/run/live/medium'
# Ignore these signals in non-interactive mode: INT, TERM, SEGV
[ -z "$PS1" ] && trap "" 2 3 11
+if [ "$(cat /proc/1/comm 2>/dev/null)" = "systemd" ] ; then
+ SYSTEMD=true
+else
+ SYSTEMD=false
+fi
+
+service_wrapper() {
+ if [ "$#" -lt 2 ] ; then
+ echo "Usage: service_wrapper <service> <action> [background]" >&2
+ return 1
+ fi
+
+ local service="$1"
+ local action="$2"
+ local background="$3"
+
+ if $SYSTEMD ; then
+ systemctl "$action" "$service"
+ else
+ if [ "${background:-}" = "background" ] ; then
+ /etc/init.d/"$service" "$action" &
+ else
+ /etc/init.d/"$service" "$action"
+ fi
+ fi
+}
+
# zsh stuff
iszsh(){
if [ -n "$ZSH_VERSION" ] ; then
VIRTUALBOX=false
VMWARE=false
-if vmware-detect &>/dev/null; then
+if virt-what 2>/dev/null | grep -q 'vmware' || \
+ imvirt 2>/dev/null | grep -i "vmware" ; then
VIRTUAL=true; VMWARE=true; VIRTUAL_ENV='VMware'
-elif [ "$(virt-what 2>/dev/null)" = "kvm" ] || \
- [ "$(imvirt 2>/dev/null)" = "KVM" ] ; then
+fi
+
+if virt-what 2>/dev/null | grep -q 'kvm' || \
+ [ "$(imvirt 2>/dev/null)" = "KVM" ] ; then
VIRTUAL=true; KVM=true; VIRTUAL_ENV='KVM'
-elif [ "$(virt-what 2>/dev/null)" = "virtualbox" ] || \
- [ "$(imvirt 2>/dev/null)" = "VirtualBox" ] ; then
+fi
+
+if virt-what 2>/dev/null | grep -q 'virtualbox' || \
+ [ "$(imvirt 2>/dev/null)" = "VirtualBox" ] ; then
VIRTUAL=true; VIRTUALBOX=true; VIRTUAL_ENV='VirtualBox'
fi
# }}}
# {{{ source lsb-functions , color handling
if checkbootparam 'nocolor'; then
- RC_NOCOLOR=yes
. /etc/grml/lsb-functions
einfo "Disabling colors in bootsequence as requested on commandline." ; eend 0
else
. /etc/grml/lsb-functions
- . /etc/grml_colors
fi
# }}}
-# {{{ debug
-config_debug(){
- checkbootparam 'debug' && BOOTDEBUG="yes"
- checkbootparam "BOOT_IMAGE=debug" && BOOTDEBUG="yes"
-
- rundebugshell(){
- if [ -n "$BOOTDEBUG" ]; then
- einfo "Starting intermediate shell stage $stage as requested by \"debug\" option."
- if [ grep -q "debug=noscreen" "$CMDLINE" ] ; then
- einfo "Notice that the shell does not provide job handling: ctrl-z, bg and fg won't work!"
- einfo "Just exit the shell to continue boot process..."
- /bin/zsh
- else
- eindent
- if [ -r /etc/grml/screenrc ] ; then
- einfo "Starting GNU screen to be able to use a full featured shell environment."
- einfo "Just exit the shells (and therefore screen) to continue boot process..."
- /bin/zsh -c "screen -c /etc/grml/screenrc"
- else
- einfo "Notice that the shell does not provide job handling: ctrl-z, bg and fg won't work!"
- einfo "Just exit the shell to continue boot process..."
- /bin/zsh
- fi
- eoutdent
- fi
- fi
- }
-}
-# }}}
-
# {{{ log
config_log(){
if checkbootparam 'log' || checkbootparam 'debug' ; then
export DEBUG="/tmp/grml.log.`date +%Y%m%d`"
- touch $DEBUG
- einfo "Bootparameter log found. Log files: ${DEBUG} and /var/log/boot"
- eindent
- einfo "Starting bootlogd." # known to be *very* unreliable :(
- bootlogd -r -c >>$DEBUG 2>&1 ; eend $?
- eoutdent
+ touch "${DEBUG}"
+ einfo "Bootparameter log found, debug log file from grml-autoconfig available at '${DEBUG}'"
else
DEBUG="/dev/null"
fi
### {{{ language configuration / localization
config_language(){
- einfo "Activating language settings:"
- eindent
+ einfo "Activating language settings:"
+ eindent
- # people can specify $LANGUAGE and $CONSOLEFONT in a config file
- [ -r /etc/grml/autoconfig ] && . /etc/grml/autoconfig
+ # people can specify $LANGUAGE and $CONSOLEFONT in a config file
+ [ -r /etc/grml/autoconfig ] && . /etc/grml/autoconfig
- # check for bootoption which overrides config from /etc/grml/autoconfig
- BOOT_LANGUAGE="$(getbootparam 'lang' 2>>$DEBUG)"
- [ -n "$BOOT_LANGUAGE" ] && LANGUAGE="$BOOT_LANGUAGE"
+ # check for bootoption which overrides config from /etc/grml/autoconfig
+ BOOT_LANGUAGE="$(getbootparam 'lang' 2>>$DEBUG)"
+ [ -n "$BOOT_LANGUAGE" ] && LANGUAGE="$BOOT_LANGUAGE"
- # set default to 'en' in live-cd mode iff $LANGUAGE is not set yet
- if [ -z "$INSTALLED" ] ; then
+ # set default to 'en' in live-cd mode iff $LANGUAGE is not set yet
+ if [ -z "$INSTALLED" ] ; then
[ -n "$LANGUAGE" ] || LANGUAGE='en'
- fi
+ fi
- if [ -x /usr/sbin/grml-setlang ] ; then
- # if bootoption lang is used update /etc/default/locale accordingly
- if [ -n "$BOOT_LANGUAGE" ] ; then
- /usr/sbin/grml-setlang "$LANGUAGE"
- # otherwise default to lang=en
- else
- /usr/sbin/grml-setlang "en"
- fi
- fi
+ if [ -x /usr/sbin/grml-setlang ] ; then
+ # if bootoption lang is used update /etc/default/locale accordingly
+ if [ -n "$BOOT_LANGUAGE" ] ; then
+ /usr/sbin/grml-setlang "$LANGUAGE"
+ # otherwise default to lang=en
+ else
+ /usr/sbin/grml-setlang "en"
+ fi
+ fi
- # set console font
- if [ -z "$CONSOLEFONT" ] ; then
- if ! checkbootparam 'nodefaultfont' >>$DEBUG 2>&1 ; then
- if [ -r /usr/share/consolefonts/Uni3-Terminus16.psf.gz ] ; then
+ if ! $SYSTEMD ; then
+ # set console font
+ if [ -z "$CONSOLEFONT" ] ; then
+ if ! checkbootparam 'nodefaultfont' >>$DEBUG 2>&1 ; then
+ if [ -r /usr/share/consolefonts/Uni3-Terminus16.psf.gz ] ; then
CONSOLEFONT='Uni3-Terminus16'
- else
- ewarn "/usr/share/consolefonts/Uni3-Terminus16.psf.gz not available. Please upgrade package console-terminus." ; eend 1
- fi
- if ! hasfb ; then
+ else
+ ewarn "/usr/share/consolefonts/Uni3-Terminus16.psf.gz not available. Please upgrade package console-setup-linux." ; eend 1
+ fi
+ if ! hasfb ; then
CONSOLEFONT='Lat15-Terminus16'
- fi
+ fi
+ fi
fi
- fi
-
- # export it now, so error messages get translated, too
- [ -r /etc/default/locale ] && . /etc/default/locale
- export LANG LANGUAGE
-
- # configure keyboard layout, read in already set values first:
- [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
-
- # now allow keyboard override by boot commandline for later use:
- KKEYBOARD="$(getbootparam 'keyboard' 2>>$DEBUG)"
- [ -n "$KKEYBOARD" ] && KEYTABLE="$KKEYBOARD"
- # notce: de/at is a bad choice, so take de-latin1-nodeadkeys instead:
- [[ "$KKEYBOARD" == 'de' ]] && KEYTABLE=de-latin1-nodeadkeys
- [[ "$KKEYBOARD" == 'at' ]] && KEYTABLE=de-latin1-nodeadkeys
-
- # modify /etc/sysconfig/keyboard only in live-cd mode:
- if [ -z "$INSTALLED" ] ; then
-
- local LANGUAGE="$BOOT_LANGUAGE"
- . /etc/grml/language-functions
- # allow setting xkeyboard explicitly different than console keyboard
- KXKEYBOARD="$(getbootparam 'xkeyboard' 2>>$DEBUG)"
- if [ -n "$KXKEYBOARD" ]; then
- XKEYBOARD="$KXKEYBOARD"
- KDEKEYBOARD="$KXKEYBOARD"
- elif [ -n "$KKEYBOARD" ]; then
- XKEYBOARD="$KKEYBOARD"
- KDEKEYBOARD="$KKEYBOARD"
- fi
-
- # duplicate of previous code to make sure /etc/grml/language-functions
- # does not overwrite our values....
- # now allow keyboard override by boot commandline for later use:
- KKEYBOARD="$(getbootparam 'keyboard' 2>>$DEBUG)"
- [ -n "$KKEYBOARD" ] && KEYTABLE="$KKEYBOARD"
- # notce: de/at is a bad choice, so take de-latin1-nodeadkeys instead:
- [[ "$KKEYBOARD" == 'de' ]] && KEYTABLE=de-latin1-nodeadkeys
- [[ "$KKEYBOARD" == 'at' ]] && KEYTABLE=de-latin1-nodeadkeys
-
- # write keyboard related variables to file for later use
- [ -d /etc/sysconfig ] || mkdir /etc/sysconfig
- if ! [ -e /etc/sysconfig/keyboard ] ; then
- echo "KEYTABLE=\"$KEYTABLE\"" > /etc/sysconfig/keyboard
- echo "XKEYBOARD=\"$XKEYBOARD\"" >> /etc/sysconfig/keyboard
- echo "KDEKEYBOARD=\"$KDEKEYBOARD\"" >> /etc/sysconfig/keyboard
- echo "KDEKEYBOARDS=\"$KDEKEYBOARDS\"" >> /etc/sysconfig/keyboard
- fi
- fi
+ fi # not running systemd
+
+ # export it now, so error messages get translated, too
+ [ -r /etc/default/locale ] && . /etc/default/locale
+ export LANG LANGUAGE
+
+ if $SYSTEMD ; then
+ local KEYBOARD
+ KEYBOARD="$(getbootparam 'keyboard' 2>>$DEBUG)"
+ [ -n "$KEYBOARD" ] || KEYBOARD="$LANGUAGE"
+ # "symbols/en" doesn't exist, so rewrite to "us"
+ [[ "$KEYBOARD" == 'en' ]] && KEYBOARD="us"
+
+ if [ -r /etc/default/keyboard ] ; then
+ sed -i "s/^XKBLAYOUT=.*/XKBLAYOUT=\"$KEYBOARD\"/" /etc/default/keyboard
+
+ case "$KEYBOARD" in
+ de|at)
+ sed -i "s/^XKBVARIANT=.*/XKBVARIANT=\"nodeadkeys\"/" /etc/default/keyboard
+ ;;
+ esac
- [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
+ fi
+ service_wrapper console-setup restart >>$DEBUG 2>&1 ; eend $?
+ else # not running systemd, keeing for backwards compatibility:
+ # configure keyboard layout, read in already set values first:
+ [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
+
+ # now allow keyboard override by boot commandline for later use:
+ KKEYBOARD="$(getbootparam 'keyboard' 2>>$DEBUG)"
+ [ -n "$KKEYBOARD" ] && KEYTABLE="$KKEYBOARD"
+ # notce: de/at is a bad choice, so take de-latin1-nodeadkeys instead:
+ [[ "$KKEYBOARD" == 'de' ]] && KEYTABLE=de-latin1-nodeadkeys
+ [[ "$KKEYBOARD" == 'at' ]] && KEYTABLE=de-latin1-nodeadkeys
+
+ # modify /etc/sysconfig/keyboard only in live-cd mode:
+ if [ -z "$INSTALLED" ] ; then
+
+ local LANGUAGE="$BOOT_LANGUAGE"
+ . /etc/grml/language-functions
+ # allow setting xkeyboard explicitly different than console keyboard
+ KXKEYBOARD="$(getbootparam 'xkeyboard' 2>>$DEBUG)"
+ if [ -n "$KXKEYBOARD" ]; then
+ XKEYBOARD="$KXKEYBOARD"
+ KDEKEYBOARD="$KXKEYBOARD"
+ elif [ -n "$KKEYBOARD" ]; then
+ XKEYBOARD="$KKEYBOARD"
+ KDEKEYBOARD="$KKEYBOARD"
+ fi
- # activate unicode console if running within utf8 environment
- if [ -r /etc/default/locale ] ; then
- if grep -q "LANG=.*UTF" /etc/default/locale ; then
- einfo "Setting up unicode environment."
- unicode_start >>$DEBUG 2>&1 ; eend $?
+ # duplicate of previous code to make sure /etc/grml/language-functions
+ # does not overwrite our values....
+ # now allow keyboard override by boot commandline for later use:
+ KKEYBOARD="$(getbootparam 'keyboard' 2>>$DEBUG)"
+ [ -n "$KKEYBOARD" ] && KEYTABLE="$KKEYBOARD"
+ # notce: de/at is a bad choice, so take de-latin1-nodeadkeys instead:
+ [[ "$KKEYBOARD" == 'de' ]] && KEYTABLE=de-latin1-nodeadkeys
+ [[ "$KKEYBOARD" == 'at' ]] && KEYTABLE=de-latin1-nodeadkeys
+
+ # write keyboard related variables to file for later use
+ [ -d /etc/sysconfig ] || mkdir /etc/sysconfig
+ if ! [ -e /etc/sysconfig/keyboard ] ; then
+ echo "KEYTABLE=\"$KEYTABLE\"" > /etc/sysconfig/keyboard
+ echo "XKEYBOARD=\"$XKEYBOARD\"" >> /etc/sysconfig/keyboard
+ echo "KDEKEYBOARD=\"$KDEKEYBOARD\"" >> /etc/sysconfig/keyboard
+ echo "KDEKEYBOARDS=\"$KDEKEYBOARDS\"" >> /etc/sysconfig/keyboard
+ fi
fi
- fi
- # Set default keyboard before interactive setup
- if [ -n "$KEYTABLE" ] ; then
- einfo "Running loadkeys for ${WHITE}${KEYTABLE}${NORMAL} in background"
- loadkeys -q $KEYTABLE &
- eend $?
- fi
+ [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
+ fi
- # we have to set up all consoles, therefore loop it over all ttys:
- NUM_CONSOLES=$(fgconsole --next-available 2>/dev/null)
- if [ -n "$NUM_CONSOLES" ] ; then
- NUM_CONSOLES=$(expr ${NUM_CONSOLES} - 1)
- [ ${NUM_CONSOLES} -eq 1 ] && NUM_CONSOLES=6
- fi
- CUR_CONSOLE=$(fgconsole 2>/dev/null)
- if [ -x "$(which setfont)" ] ; then
- use_setfont=true
- elif [ -x "$(which consolechars)" ] ; then
- use_consolechars=true
- else
- eerror "Neither setfont nor consolechars tool present, can not set font."
- eend 1
- return 1
- fi
+ if ! $SYSTEMD ; then
+ # we have to set up all consoles, therefore loop it over all ttys:
+ NUM_CONSOLES=$(fgconsole --next-available 2>/dev/null)
+ if [ -n "$NUM_CONSOLES" ] ; then
+ NUM_CONSOLES=$(expr ${NUM_CONSOLES} - 1)
+ [ ${NUM_CONSOLES} -eq 1 ] && NUM_CONSOLES=6
+ fi
+ CUR_CONSOLE=$(fgconsole 2>/dev/null)
- if [ -n "$CHARMAP" ] ; then
- einfo "Setting font to ${CHARMAP}"
- RC=0
- for vc in $(seq 0 ${NUM_CONSOLES}) ; do
+ if [ -x "$(which setfont)" ] ; then
+ use_setfont=true
+ elif [ -x "$(which consolechars)" ] ; then
+ use_consolechars=true
+ else
+ eerror "Neither setfont nor consolechars tool present, can not set font."
+ eend 1
+ return 1
+ fi
+
+ if [ -n "$CHARMAP" ] ; then
+ einfo "Setting font to ${CHARMAP}"
+ RC=0
+ for vc in $(seq 0 ${NUM_CONSOLES}) ; do
if $use_setfont ; then
setfont -C /dev/tty${vc} $CHARMAP ; RC=$?
elif $use_consolechars ; then
consolechars --tty=/dev/tty${vc} -m ${CHARMAP} ; RC=$?
fi
- done
- if [ -n "$CUR_CONSOLE" ] ; then
- [ "$CUR_CONSOLE" != "serial" ] && chvt $CUR_CONSOLE
+ done
+ if [ -n "$CUR_CONSOLE" ] ; then
+ [ "$CUR_CONSOLE" != "serial" ] && chvt $CUR_CONSOLE
+ fi
+ eend $RC
fi
- eend $RC
- fi
- if checkbootparam 'noconsolefont' ; then
- ewarn "Skipping setting console font as requested on boot commandline." ; eend 0
- else
- if [ -n "$CONSOLEFONT" ] ; then
- einfo "Setting font to ${CONSOLEFONT}"
- RC=0
- for vc in $(seq 0 ${NUM_CONSOLES}) ; do
- if $use_setfont ; then
- setfont -C /dev/tty${vc} ${CONSOLEFONT} ; RC=$?
- elif $use_consolechars ; then
- consolechars --tty=/dev/tty${vc} -f ${CONSOLEFONT} ; RC=$?
- fi
- done
- if [ -n "$CUR_CONSOLE" ] ; then
+ if checkbootparam 'noconsolefont' ; then
+ ewarn "Skipping setting console font as requested on boot commandline." ; eend 0
+ else
+ if [ -n "$CONSOLEFONT" ] ; then
+ einfo "Setting font to ${CONSOLEFONT}"
+ RC=0
+ for vc in $(seq 0 ${NUM_CONSOLES}) ; do
+ if $use_setfont ; then
+ setfont -C /dev/tty${vc} ${CONSOLEFONT} ; RC=$?
+ elif $use_consolechars ; then
+ consolechars --tty=/dev/tty${vc} -f ${CONSOLEFONT} ; RC=$?
+ fi
+ done
+ if [ -n "$CUR_CONSOLE" ] ; then
[ "$CUR_CONSOLE" != "serial" ] && chvt $CUR_CONSOLE
- fi
- eend $RC
+ fi
+ eend $RC
+ fi
fi
- fi
- eoutdent
+ # Set default keyboard before interactive setup
+ if [ -n "$KEYTABLE" ] ; then
+ einfo "Running loadkeys for ${WHITE}${KEYTABLE}${NORMAL} in background"
+ loadkeys -q $KEYTABLE &
+ eend $?
+ fi
+
+ # activate unicode console if running within utf8 environment
+ if [ -r /etc/default/locale ] ; then
+ if grep -q "LANG=.*UTF" /etc/default/locale ; then
+ einfo "Setting up unicode environment."
+ unicode_start ; eend $?
+ fi
+ fi
+ fi # not running systemd
+
+ eoutdent
}
# }}}
if [ -z "$INSTALLED" ]; then
# The default hardware clock timezone is stated as representing local time.
UTC="--localtime"
- grep -q "^UTC=" /etc/default/rcS || echo "UTC=no" >> /etc/default/rcS
- checkbootparam 'utc' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=yes|" /etc/default/rcS
- checkbootparam 'gmt' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=yes|" /etc/default/rcS
- checkbootparam 'localtime' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=no|" /etc/default/rcS
- grep -q -i "^UTC=yes" /etc/default/rcS && UTC="-u"
+
+ if [ -f /etc/default/rcS ] ; then
+ grep -q "^UTC=" /etc/default/rcS || echo "UTC=no" >> /etc/default/rcS
+ checkbootparam 'utc' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=yes|" /etc/default/rcS
+ checkbootparam 'gmt' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=yes|" /etc/default/rcS
+ checkbootparam 'localtime' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=no|" /etc/default/rcS
+ grep -q -i "^UTC=yes" /etc/default/rcS && UTC="-u"
+ # recent initscripts package versions don't ship /etc/default/rcS anymore, instead rely on /etc/adjtime
+ elif [ -f /etc/adjtime ] ; then
+ checkbootparam 'utc' >>$DEBUG 2>&1 && sed -i "s/^LOCAL/UTC/" /etc/adjtime
+ checkbootparam 'gmt' >>$DEBUG 2>&1 && sed -i "s/^LOCAL/UTC/" /etc/adjtime
+ checkbootparam 'localtime' >>$DEBUG 2>&1 && sed -i "s/^UTC$/LOCAL/" /etc/adjtime
+ grep -q "^UTC$" /etc/adjtime && UTC="-u"
+ fi
+
# hwclock uses the TZ variable
KTZ="$(getbootparam 'tz' 2>>$DEBUG)"
[ -z "$KTZ" ] && [ -r /etc/timezone ] && KTZ=$(cat /etc/timezone)
}
# }}}
+# {{{ secure boot
+# helper function to check whether we're running under (enabled) Secure Boot
+running_under_secureboot() {
+ # systemd does this for us, but if we are not running under systemd then mokutil
+ # doesn't work as needed as it relies on /sys/firmware/efi/efivars (while
+ # /sys/firmware/efi/vars would exist)
+ if ! $SYSTEMD ; then
+ if modprobe efivarfs &>/dev/null ; then
+ mount -t efivarfs efivarfs /sys/firmware/efi/efivars
+ fi
+ fi
+
+ if [[ -x "$(command -v mokutil)" ]] ; then
+ if mokutil --sb-state 2>/dev/null | grep -q 'SecureBoot enabled' ; then
+ return 0
+ else
+ return 1
+ fi
+ else
+ if modprobe efivarfs &>/dev/null ; then
+ if od -An -t u1 /sys/firmware/efi/vars/SecureBoot-*/data 2>/dev/null | grep -q 1 ; then
+ return 0
+ else
+ return 1
+ fi
+ fi
+ fi
+}
+
+config_secureboot(){
+ if running_under_secureboot ; then
+ einfo "SecureBoot is enabled" ; eend 0
+ else
+ einfo "SecureBoot not detected" ; eend 0
+ fi
+}
+# }}}
+
# {{{ timezone
config_timezone(){
# don't touch the files if running from harddisk:
# activate serial console {{{
config_console(){
if checkbootparam 'console'; then
+ # this hack is no longer necessary with systemd
+ if $SYSTEMD ; then
+ return
+ fi
+
local line
local ws
ws=' '
# {{{ ACPI
config_acpi(){
-if checkbootparam 'noacpi'; then
- ewarn "ACPI: Not loading modules as requested by boot option \"noacpi\"." ; eend 0
-elif checkbootparam 'nogrmlacpi' ; then
- ewarn "ACPI: Not loading modules as requested by boot option \"nogrmlacpi\"." ; eend 0
-elif [ ! -d /proc/acpi ] ; then
- ewarn "ACPI: Kernel support not present." ; eend 0
-else
- einfo "ACPI: Loading modules (disable with boot option noacpi / nogrmlacpi): "
- eindent
- found=""
- for a in /lib/modules/$KERNEL/kernel/drivers/acpi/*; do
- basename="${a##*/}"
- basename="${basename%%.*}"
- case "$basename" in *_acpi)
- egrep -qi "${basename%%_acpi}" /proc/acpi/dsdt 2>>$DEBUG || continue ;;
+ if $SYSTEMD ; then
+ echo "systemd detected, no acpi(d) stuff needed." >>"$DEBUG"
+ return
+ fi
+
+ if checkbootparam 'noacpi'; then
+ ewarn "ACPI: Not loading modules as requested by boot option \"noacpi\"." ; eend 0
+ elif checkbootparam 'nogrmlacpi' ; then
+ ewarn "ACPI: Not loading modules as requested by boot option \"nogrmlacpi\"." ; eend 0
+ elif [ ! -d /proc/acpi ] ; then
+ ewarn "ACPI: Kernel support not present." ; eend 0
+ else
+ einfo "ACPI: Loading modules (disable with boot option noacpi / nogrmlacpi): "
+ eindent
+ found=""
+ for a in /lib/modules/$KERNEL/kernel/drivers/acpi/*; do
+ basename="${a##*/}"
+ basename="${basename%%.*}"
+ case "$basename" in *_acpi)
+ egrep -qi "${basename%%_acpi}" /proc/acpi/dsdt 2>>$DEBUG || continue ;;
esac
modprobe $basename >>$DEBUG 2>&1 && found="yes"
local BASE="$BASE $basename"
fi
if ! pgrep acpid >/dev/null ; then
einfo "Starting acpi daemon."
- /etc/init.d/acpid start >>$DEBUG 2>&1 ; eend $?
+ service_wrapper acpid.socket start >>$DEBUG 2>&1 ; eend $?
+ service_wrapper acpid start >>$DEBUG 2>&1 ; eend $?
else
ewarn "acpi daemon already running."
eend 0
# {{{ Start brltty
config_brltty() {
if checkbootparam 'brltty' ; then
- [ -x /lib/brltty/brltty.sh ] && /lib/brltty/brltty.sh
+ einfo "Starting brltty service as requested on boot commandline."
+ service_wrapper brltty start ; eend $?
fi
}
# }}}
else
einfo "Found CPU: `awk -F: '/^processor/{printf " Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>>$DEBUG` " ; eend 0
fi
-
-# no cpufreq setup inside VirtualBox
-if $VIRTUALBOX ; then
- einfo 'Virtual Box detected, skipping cpufreq setup.' ; eend 0
- return 0
-fi
-
-if [ -x /etc/init.d/loadcpufreq ] ; then
- einfo "Trying to set up cpu frequency scaling:"
- eindent
- SKIP_CPU_GOVERNOR=''
- LOADCPUFREQ=$(mktemp)
- /etc/init.d/loadcpufreq start >"$LOADCPUFREQ" 2>&1 ; RC=$?
- if grep -q FATAL "$LOADCPUFREQ" ; then
- eindent
- SKIP_CPU_GOVERNOR=1
- oldIFS="$IFS"
- IFS="
-"
- for line in $(grep FATAL "$LOADCPUFREQ" | sed 's/.*FATAL: //; s/ (.*)//') ; do
- eerror "$line" ; eend $RC
- done
- IFS="$oldIFS"
- eoutdent
- elif grep -q done "$LOADCPUFREQ" ; then
- MODULE=$(grep done "$LOADCPUFREQ" | sed 's/.*done (\(.*\))./\1/')
- if [ -n "$MODULE" -a "$MODULE" != none ]; then
- einfo "Loading cpufreq kernel module $MODULE" ; eend 0
- else
- SKIP_CPU_GOVERNOR=1
- ewarn "Could not find an appropriate kernel module for cpu frequency scaling." ; eend 1
- fi
- fi
-
- rm -f "$LOADCPUFREQ"
-
- if [ -z "$SKIP_CPU_GOVERNOR" ] ; then
- if [ -r /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors ] ; then
- if ! grep -q ondemand /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors ; then
- einfo "Ondemand governor not available for CPU(s), not modifying governor configuration"
- else
- einfo "Setting ondemand governor"
- RC=0
- for file in $(find /sys/devices/system/cpu/ -name scaling_governor 2>/dev/null) ; do
- echo ondemand > $file || RC=1
- done
- eend $RC
- fi
- fi
- fi
-
- eoutdent
-fi
}
# }}}
fi
einfo "Starting secure shell server in background for root and user $localuser"
- /etc/init.d/rmnologin start >>$DEBUG 2>>$DEBUG
- /etc/init.d/ssh start >>$DEBUG 2>>$DEBUG &
+ service_wrapper haveged start >>$DEBUG 2>>$DEBUG
+ service_wrapper rmnologin start >>$DEBUG 2>>$DEBUG
+ service_wrapper ssh start background >>$DEBUG 2>>$DEBUG
eend $?
fi
# {{{ Sound
config_mixer () {
- if ! [ -x /usr/bin/amixer ] ; then
- eerror "amixer binary not available. Can not set sound volumes therefore."
- eend 1
- else
- if ! [ -r /proc/asound/cards ] ; then
- ewarn "No soundcard present, skipping mixer settings therefore."
- eend 0
- return
+ if ! [ -x /usr/bin/amixer ] ; then
+ logger -t grml-autoconfig "amixer binary not available"
+ return
+ fi
+
+ if ! [ -r /proc/asound/cards ] ; then
+ ewarn "No soundcard present, skipping mixer settings therefore."
+ eend 0
+ return
+ fi
+
+ for card in $(cat /proc/asound/cards| grep -e '^\s*[0-9]' | awk '{print $1}') ; do
+ einfo "Configuring soundcard \"$(awk -F\[ '/^ *'$card' \[/{ FS=" "; $0=$2; print $1}' < /proc/asound/cards)\""
+ eindent
+
+ if checkbootparam 'vol' ; then
+ VOL="$(getbootparam 'vol' 2>>$DEBUG)"
+ if [ -z "$VOL" ] ; then
+ eerror "Bootoption vol found but no volume level/parameter given. Using defaults (75%)."
+ VOL='75'
+ eend 1
fi
+ else
+ VOL='75'
+ fi
- for card in $(cat /proc/asound/cards| grep -e '^\s*[0-9]' | awk '{print $1}') ; do
- einfo "Configuring soundcard \"$(awk -F\[ '/^ *'$card' \[/{ FS=" "; $0=$2; print $1}' < /proc/asound/cards)\""
- eindent
+ if checkbootparam 'nosound' ; then
+ einfo "Muting sound devices on request."
+ ERROR=$(amixer -q set Master mute)
+ RC=$?
+ if [ -n "$ERROR" ] ; then
+ eindent
+ eerror "Problem muting sound devices: $ERROR"
+ eoutdent
+ fi
+ eend $RC
+ elif [ -z "$INSTALLED" ] ; then
+ einfo "Setting mixer volumes to level ${WHITE}${VOL}${NORMAL}."
- if checkbootparam 'vol' ; then
- VOL="$(getbootparam 'vol' 2>>$DEBUG)"
- if [ -z "$VOL" ] ; then
- eerror "Bootoption vol found but no volume level/parameter given. Using defaults (75%)."
- VOL='75'
- eend 1
- fi
- else
- VOL='75'
- fi
-
- if checkbootparam 'nosound' ; then
- einfo "Muting sound devices on request."
- ERROR=$(amixer -q set Master mute)
- RC=$?
- if [ -n "$ERROR" ] ; then
- eindent
- eerror "Problem muting sound devices: $ERROR"
- eoutdent
- fi
- eend $RC
- elif [ -z "$INSTALLED" ] ; then
- einfo "Setting mixer volumes to level ${WHITE}${VOL}${NORMAL}."
+ if checkbootparam 'micvol' ; then
+ MICVOL="$(getbootparam 'micvol' 2>>$DEBUG)"
+ einfo "Setting microphone to ${WHITE}${MICVOL}${NORMAL}."
+ else
+ MICVOL=0
+ fi
- if checkbootparam 'micvol' ; then
- MICVOL="$(getbootparam 'micvol' 2>>$DEBUG)"
- einfo "Setting microphone to ${WHITE}${MICVOL}${NORMAL}."
- else
- MICVOL=0
- fi
+ CONTROLS=$(amixer -c $card scontrols | awk -F"Simple mixer control " '{print $2}')
+ IFSOLD=${IFS:-}
+ IFS=$'\n'
+ for CONTROL in ${=CONTROLS} ; do
+ # such devices can not be controlled with amixer ... unmute
+ [[ "$CONTROL" == *Console* ]] && continue
- CONTROLS=$(amixer -c $card scontrols | awk -F"Simple mixer control " '{print $2}')
- IFSOLD=${IFS:-}
- IFS='
-'
- for CONTROL in ${=CONTROLS} ; do
- # such devices can not be controlled with amixer ... unmute
- [[ "$CONTROL" == *Console* ]] && continue
-
- if ! echo "${CONTROL}" | grep -q -i "mic" ; then
- if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*pswitch' ; then
- amixer -c $card -q set "${CONTROL}" unmute
- fi
- if amixer -c $card sget "${CONTROL}" | grep -q -P 'Capabilities:.*(pvolume| volume)' ; then
- amixer -c $card -q set "${CONTROL}" "${VOL}"%
- fi
- fi
+ if ! echo "${CONTROL}" | grep -q -i "mic" ; then
+ if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*pswitch' ; then
+ amixer -c $card -q set "${CONTROL}" unmute
+ fi
+ if amixer -c $card sget "${CONTROL}" | grep -q -P 'Capabilities:.*(pvolume| volume)' ; then
+ amixer -c $card -q set "${CONTROL}" "${VOL}"%
+ fi
+ fi
- if [ ${MICVOL} -ne 0 ] ; then
- if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*cswitch' ; then
- amixer -c $card -q set "${CONTROL}" unmute
- fi
- if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*cvolume' ; then
- amixer -c $card -q set "${CONTROL}" $MICVOL%
- fi
- eend $?
- fi
- done
- IFS=$IFSOLD
- fi # checkbootparam 'nosound'
- eoutdent
+ if [ ${MICVOL} -ne 0 ] ; then
+ if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*cswitch' ; then
+ amixer -c $card -q set "${CONTROL}" unmute
+ fi
+ if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*cvolume' ; then
+ amixer -c $card -q set "${CONTROL}" $MICVOL%
+ fi
+ eend $?
+ fi
done
- fi
+ IFS=$IFSOLD
+ fi # checkbootparam 'nosound'
+ eoutdent
+ done
}
# }}}
if checkbootparam 'nosyslog'; then
ewarn "Not starting syslog daemon as requested on boot commandline." ; eend 0
else
- SYSLOGD=''
- [ -x /etc/init.d/syslog-ng ] && SYSLOGD='syslog-ng'
- [ -x /etc/init.d/rsyslog ] && SYSLOGD='rsyslog'
- [ -x /etc/init.d/dsyslog ] && SYSLOGD='dsyslog'
- [ -x /etc/init.d/sysklogd ] && SYSLOGD='sysklogd'
- [ -x /etc/init.d/inetutils-syslogd ] && SYSLOGD='inetutils-syslogd'
-
- if [ -z "$SYSLOGD" ] ; then
- eerror "No syslog daemon found." ; eend 1
- else
- einfo "Starting $SYSLOGD in background."
- /etc/init.d/$SYSLOGD start >>$DEBUG &
- eend 0
- fi
+ einfo "Starting rsyslog in background."
+ service_wrapper rsyslog start >>$DEBUG
+ eend 0
fi
}
# }}}
# {{{ gpm
config_gpm(){
- if checkbootparam 'nogpm'; then
- ewarn "Not starting GPM as requested on boot commandline." ; eend 0
- else
- if ! [ -r /dev/input/mice ] ; then
+ if checkbootparam 'nogpm'; then
+ ewarn "Not starting GPM as requested on boot commandline." ; eend 0
+ else
+ if ! [ -r /dev/input/mice ] ; then
eerror "No mouse found - not starting GPM." ; eend 1
- else
+ else
einfo "Starting gpm in background."
- /etc/init.d/gpm start >>$DEBUG &
- # ( while [ ! -e /dev/psaux ]; do sleep 5; done; /etc/init.d/gpm start >>$DEBUG ) &
+ service_wrapper gpm start background >>$DEBUG
eend 0
- fi
- fi
+ fi
+ fi
}
# }}}
# if they contain the keyword "DO_NO_RUN_IN_BACKGROUND".
if grep -q 'DO_NO_RUN_IN_BACKGROUND' "/etc/init.d/${service}" 2>>$DEBUG ; then
einfo "Starting service ${service}."
- /etc/init.d/${service} start >>$DEBUG
+ service_wrapper "${service}" start >>$DEBUG
else
einfo "Starting service ${service} in background."
- /etc/init.d/${service} start >>$DEBUG &
+ service_wrapper "${service}" start background >>$DEBUG
fi
done
eend $?
}
# }}}
-# {{{ stats
-config_stats() {
- if ! checkbootparam 'nostats' ; then
- BASE_URL="http://stats.grml.org/report/"
- ACTION_NAME=Boot
-
- HOST_ID=$(cat /proc/sys/kernel/random/boot_id)
-
- grep -q " lm " /proc/cpuinfo && HAS_64BIT="1" || HAS_64BIT="0"
- DATE_STRING=$(date +'h=%H&m=%M&s=%S')
- [ -e /etc/grml_version ] && VERSION=$(cat /etc/grml_version) || \
- VERSION=$(lsb_release -d | awk -F: '{gsub(/^[ \t]+/, "", $2); print $2}')
-
- PARAMS="$( echo "$CMDLINE" | sed -e 's/=[^ ]*/=x/g' | tr " " "\n"|sort|tr "\n" " " )"
-
- echo "$CMDLINE" | grep -q -e "fetch" -e "nfsroot" && BOOT="remote"
- [ -z "$BOOT" ] && BOOT="local"
-
- ADDITIONAL_PARAMS=""
- ( [ -n "$COLUMNS" ] && [ -n "$LINES" ] ) && \
- ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS&res=$((COLUMNS * 8))x$((LINES * 16))"
-
- URI='$BASE_URL?action=${ACTION_NAME}\&$DATE_STRING\&unique_id=${HOST_ID}\&support_64bit=$HAS_64BIT\&version=$VERSION\&bootup=$BOOT\¶ms=$PARAMS$ADDITIONAL_PARAMS'
-
- get_remote_file "$URI" "/dev/null" >/dev/null 2>&1 &!
- fi
-}
-# }}}
-
# {{{ start X window system via grml-x
config_x_startup(){
+
+
# make sure we start X only if startx is used *before* a nostartx option
# so it's possible to disable automatic X startup using nostart
if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; then
fi
einfo "Setting up and invoking grml-x ${WINDOWMANAGER}. Just exit X windows system to get full featured consoles."
config_userlocal
- cat>|/etc/init.d/xstartup<<EOF
+ if $SYSTEMD ; then
+ if [ -n "$WINDOWMANAGER" ] ; then
+ mkdir -p /var/run/grml-x/
+ echo "$WINDOWMANAGER" > /var/run/grml-x/window-manager
+ fi
+ chvt 7
+ return
+ fi
+ cat>|/etc/init.d/startx<<EOF
#!/bin/sh
-su $localuser -c "/usr/bin/grml-x ${WINDOWMANAGER}"
+su "${localuser}" -c "/usr/bin/grml-x ${WINDOWMANAGER}"
EOF
- chmod 755 /etc/init.d/xstartup
+ chmod 755 /etc/init.d/startx
- # adjust inittab for xstartup
+ # adjust inittab for startx
if grep -q '^6:' /etc/inittab ; then
- sed -i 's|^6:.*|6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /usr/share/grml-scripts/run-welcome" >/dev/tty6 2>\&1 </dev/tty6|' /etc/inittab
+ sed -i 's|^6:.*|6:2345:respawn:/bin/zsh --login -c "/etc/init.d/startx ; /usr/share/grml-scripts/run-welcome" >/dev/tty6 2>\&1 </dev/tty6|' /etc/inittab
else # just append tty6 to inittab if no definition is present:
- echo '6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /usr/share/grml-scripts/run-welcome" >/dev/tty6 2>&1 < /dev/tty6' >> /etc/inittab
+ echo '6:2345:respawn:/bin/zsh --login -c "/etc/init.d/startx ; /usr/share/grml-scripts/run-welcome" >/dev/tty6 2>&1 < /dev/tty6' >> /etc/inittab
fi
/sbin/telinit q ; eend $?
if ! checkbootparam 'swraid' ; then
eindent
- einfo "Just run 'Start mdadm-raid' to assemble md arrays or boot using 'swraid' as bootoption for autostart."
+ if $SYSTEMD ; then
+ einfo "Just run 'mdadm --assemble --scan' to assemble md arrays or boot using 'swraid' as bootoption for autostart."
+ else
+ einfo "Just run 'Start mdadm-raid' to assemble md arrays or boot using 'swraid' as bootoption for autostart."
+ fi
eoutdent
else
einfo "Bootoption swraid found. Searching for software RAID arrays:"
eindent
IFSOLD=${IFS:-}
- IFS='
-'
- for line in $(mdadm --assemble --scan --auto=yes --symlink=no 2>&1) ; do
+ IFS=$'\n'
+ for line in $(mdadm --assemble --scan 2>&1) ; do
case $line in
*'No arrays found'*)
ewarn "$line" ; eend 0
ewarn "No active arrays found" ; eend 0
else
IFSOLD=${IFS:-}
- IFS='
-'
+ IFS=$'\n'
for line in $(grep '^md[0-9]' /proc/mdstat) ; do
einfo "active arrays: $line" ; eend 0
done
fi
if ! [ -x /sbin/dmraid ] ; then
- eerror "dmraid not available, can not execute it." ; eend 1
+ ewarn "dmraid not available, can not execute it." ; eend 1
return
fi
[ -n "$1" ] || return 1
IFSOLD=${IFS:-}
- IFS='
-'
+ IFS=$'\n'
eindent
for line in $(dmraid $1 ; echo errcode:$?); do
if checkbootparam 'nolvm' ; then
ewarn "Skipping LVM code as requested on boot commandline." ; eend 0
else
- # Debian etch provides /etc/init.d/lvm only, newer suites provide /etc/init.d/lvm2
- if ! [ -x /sbin/lvm -a -x /sbin/lvdisplay ] || ! [ -x /etc/init.d/lvm2 -o -x /etc/init.d/lvm ] ; then
+ if ! [ -x /sbin/lvm ] ; then
eerror "LVM not available, can not execute it." ; eend 1
else
if lvdisplay 2>&1 | grep -v 'No volume groups found' >/dev/null 2>&1 ; then
einfo "You seem to have logical volumes (LVM) on your system."
eindent
- einfo "Just run 'Start lvm2' to activate them or boot using 'lvm' as bootoption for autostart."
+ if $SYSTEMD ; then
+ einfo "Just run 'Start lvm2-pvscan@name' to activate LV or VG 'name' or boot using 'lvm' as bootoption for autostart."
+ else
+ einfo "Just run 'Start lvm2' to activate them or boot using 'lvm' as bootoption for autostart."
+ fi
eend 0
if checkbootparam 'lvm' ; then
- einfo "Bootoption LVM found. Searching for logical volumes:"
- /etc/init.d/lvm2 start ; eend $?
+ if $SYSTEMD ; then
+ einfo "Bootoption LVM found, enabling related services."
+ if [ -r /etc/init.d/lvm2-lvmetad ] ; then
+ service_wrapper lvm2-lvmetad start ; eend $?
+ fi
+ if [ -r /etc/init.d/lvm2-lvmpolld ] ; then
+ service_wrapper lvm2-lvmpolld start ; eend $?
+ fi
+ einfo "Searching for logical volumes and enabling them:"
+ vgchange -ay ; eend $?
+ else
+ einfo "Bootoption LVM found. Searching for logical volumes and enabling them:"
+ service_wrapper lvm2 start ; eend $?
+ fi
fi
eoutdent
fi
# {{{ virtualbox shared folders
config_virtualbox_shared_folders() {
-if $VIRTUALBOX ; then
- einfo "VirtualBox detected, trying to set up Shared Folders."
- if ! modinfo vboxsf &>/dev/null ; then
- ewarn "vboxsf driver not present, not setting up VirtualBox Shared Folders."
- eend 0
- elif ! [ -x /usr/sbin/VBoxService ] ; then
- ewarn "virtualbox-guest-utils not installed, not setting up VirtualBox Shared Folders."
- eend 0
+ if ! $VIRTUALBOX ; then
+ return
+ fi
+
+ if checkbootparam 'novboxsf' ; then
+ ewarn "Skipping VirtualBox Shared Folders setup as requested on boot commandline." ; eend 0
else
- eindent
+ einfo "VirtualBox detected, trying to set up Shared Folders."
+ if ! modinfo vboxsf &>/dev/null ; then
+ ewarn "vboxsf driver not present, not setting up VirtualBox Shared Folders."
+ eend 0
+ elif ! [ -x /usr/sbin/VBoxService ] ; then
+ ewarn "virtualbox-guest-utils not installed, not setting up VirtualBox Shared Folders."
+ eend 0
+ else
+ eindent
einfo "Loading vboxsf driver."
lsmod | grep -q vboxsf || modprobe vboxsf
config_userfstab
- einfo "Adding $fstabuser to group vboxsf."
- adduser grml vboxsf &>/dev/null
+ einfo "Adding user ${fstabuser:-grml} to group vboxsf."
+ adduser "${fstabuser:-grml}" vboxsf >>"${DEBUG}" 2>&1
eend $?
einfo "Starting VBoxService."
vbautomation="$(getbootparam 'vbautomation' 2>>$DEBUG)"
fi
- if ! VBoxControl sharedfolder list | egrep -q "^[0-9]+ - ${vbautomation}$" ; then
+ if ! VBoxControl sharedfolder list | egrep -q "^[0-9]+ - ${vbautomation}(\s+|$)" ; then
ewarn "No automount shared folder '$vbautomation' available"
eend 0
else
fi
fi
- eoutdent
+ eoutdent
+ fi
fi
-fi
+}
+# }}}
+
+# {{{ VirtualBox application
+config_virtualbox_setup() {
+ if checkbootparam 'novbox' ; then
+ ewarn "Skipping VirtualBox setup as requested on boot commandline." ; eend 0
+ return
+ fi
+
+ if ! [ -x /usr/bin/VBox ] ; then
+ return
+ fi
+
+ if running_under_secureboot ; then
+ ewarn "VirtualBox service can not be started as running under enabled Secure Boot." ; eend 0
+ return
+ fi
+
+ einfo "VirtualBox service detected, trying to set up."
+ service_wrapper vboxdrv restart >>"${DEBUG}" 2>&1 ; eend $?
+
+ config_userfstab
+
+ einfo "Adding user ${fstabuser:-grml} to group vboxusers."
+ adduser "${fstabuser:-grml}" vboxusers >>"${DEBUG}" 2>&1
+ eend $?
}
# }}}
if checkbootparam 'distri'; then
DISTRI="$(getbootparam 'distri' 2>>$DEBUG)"
if [ -r "${LIVECD_PATH}"/desktop/"$DISTRI".jpg ] ; then
- [ -n "$BOOTDEBUG" ] && einfo "Debug: bootoption distri found and file ${LIVECD_PATH}/desktop/${DISTRI} present" && eend 0
# make sure the desktop.jpg file is not a symlink, so copying does not file then
[ -L /usr/share/grml/desktop.jpg ] && rm /usr/share/grml/desktop.jpg
cp "${LIVECD_PATH}"/desktop/"$DISTRI".jpg /usr/share/grml/desktop.jpg