service_wrapper() {
if [ "$#" -lt 2 ] ; then
- echo "Usage: service_wrapper <service> <action>" >&2
+ 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
- /etc/init.d/"$service" "$action"
+ if [ "${background:-}" = "background" ] ; then
+ /etc/init.d/"$service" "$action" &
+ else
+ /etc/init.d/"$service" "$action"
+ fi
fi
}
if vmware-detect &>/dev/null; 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
# }}}
[ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
- # 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 $?
- 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
# we have to set up all consoles, therefore loop it over all ttys:
NUM_CONSOLES=$(fgconsole --next-available 2>/dev/null)
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
+
+ # 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
+
eoutdent
}
# }}}
# {{{ secure boot
config_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 efivars &>/dev/null ; then
+ mount -t efivarfs efivarfs /sys/firmware/efi/efivars
+ fi
+ fi
+
if [ -x /usr/bin/mokutil ] ; then
local secstate=$(mokutil --sb-state 2>/dev/null) # "SecureBoot enabled"
if [ -n "$secstate" ] ; then
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
- ewarn "loadcpufreq init script not available, ignoring cpu frequency scaling."
- eend 0
- return 0
-else
- 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"
+ service_wrapper haveged start >>$DEBUG 2>>$DEBUG
service_wrapper rmnologin start >>$DEBUG 2>>$DEBUG
- service_wrapper ssh start >>$DEBUG 2>>$DEBUG &
+ service_wrapper ssh start background >>$DEBUG 2>>$DEBUG
eend $?
fi
CONTROLS=$(amixer -c $card scontrols | awk -F"Simple mixer control " '{print $2}')
IFSOLD=${IFS:-}
- IFS='
- '
+ IFS=$'\n'
for CONTROL in ${=CONTROLS} ; do
# such devices can not be controlled with amixer ... unmute
[[ "$CONTROL" == *Console* ]] && continue
ewarn "Not starting syslog daemon as requested on boot commandline." ; eend 0
else
einfo "Starting rsyslog in background."
- service_wrapper rsyslog start >>$DEBUG &
+ service_wrapper rsyslog start >>$DEBUG
eend 0
fi
}
eerror "No mouse found - not starting GPM." ; eend 1
else
einfo "Starting gpm in background."
- service_wrapper 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
service_wrapper "${service}" start >>$DEBUG
else
einfo "Starting service ${service} in background."
- service_wrapper "${service}" start >>$DEBUG &
+ service_wrapper "${service}" start background >>$DEBUG
fi
done
eend $?
einfo "Setting up and invoking grml-x ${WINDOWMANAGER}. Just exit X windows system to get full featured consoles."
config_userlocal
if $SYSTEMD ; then
- cat>|/etc/init.d/startx<<EOF
-#!/bin/sh
-chgrp tty \${TTY}
-chmod g=rw \${TTY}
-sudo -u "${localuser}" /usr/bin/grml-x ${WINDOWMANAGER}
-EOF
- chmod 755 /etc/init.d/startx
- chvt 6
+ 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
if ! checkbootparam 'swraid' ; then
eindent
if $SYSTEMD ; then
- einfo "Just run 'Start mdmonitor' to assemble md arrays or boot using 'swraid' as bootoption for autostart."
+ 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
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
[ -n "$1" ] || return 1
IFSOLD=${IFS:-}
- IFS='
-'
+ IFS=$'\n'
eindent
for line in $(dmraid $1 ; echo errcode:$?); do
einfo "You seem to have logical volumes (LVM) on your system."
eindent
if $SYSTEMD ; then
- einfo "Just run 'Start lvm2-lvmetad' to activate them or boot using 'lvm' as bootoption for autostart."
+ 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:"
+ einfo "Bootoption LVM found. Searching for logical volumes and enabling them:"
if $SYSTEMD ; then
- service_wrapper lvm2-lvmetad start ; eend $?
+ service_wrapper lvm2-lvmetad start
+ vgchange -ay
+ eend $?
else
service_wrapper lvm2 start ; eend $?
fi