X-Git-Url: https://git.grml.org/?p=grml-autoconfig.git;a=blobdiff_plain;f=autoconfig.functions;h=90bc6bd2a948566cf099f17f65a9634301d45f58;hp=ccf12d673b6131d75d2a0a5f79cfd24174b12f3b;hb=2b4bfb74c4c727f74f03f53c142b983a07a7b949;hpb=176568ce0d352cb56b370737c3263eb09eba8e89 diff --git a/autoconfig.functions b/autoconfig.functions index ccf12d6..90bc6bd 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -31,17 +31,22 @@ fi service_wrapper() { if [ "$#" -lt 2 ] ; then - echo "Usage: service_wrapper " >&2 + echo "Usage: service_wrapper [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 } @@ -201,36 +206,6 @@ else 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 @@ -542,6 +517,14 @@ config_kernel(){ # {{{ 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 + modprobe efivars + mount -t efivarfs efivarfs /sys/firmware/efi/efivars + fi + if [ -x /usr/bin/mokutil ] ; then local secstate=$(mokutil --sb-state 2>/dev/null) # "SecureBoot enabled" if [ -n "$secstate" ] ; then @@ -922,8 +905,7 @@ else eindent SKIP_CPU_GOVERNOR=1 oldIFS="$IFS" - IFS=" -" + IFS=$'\n' for line in $(grep FATAL "$LOADCPUFREQ" | sed 's/.*FATAL: //; s/ (.*)//') ; do eerror "$line" ; eend $RC done @@ -993,7 +975,7 @@ if checkbootparam 'ssh' ; then einfo "Starting secure shell server in background for root and user $localuser" service_wrapper rmnologin start >>$DEBUG 2>>$DEBUG - service_wrapper ssh start >>$DEBUG 2>>$DEBUG & + service_wrapper ssh start background >>$DEBUG 2>>$DEBUG eend $? fi @@ -1185,8 +1167,7 @@ config_mixer () { 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 @@ -1223,7 +1204,7 @@ config_syslog(){ 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 } @@ -1238,8 +1219,7 @@ config_gpm(){ 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 @@ -1260,7 +1240,7 @@ config_services(){ 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 $? @@ -1331,35 +1311,6 @@ config_netscript() { } # }}} -# {{{ 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(){ @@ -1378,14 +1329,11 @@ if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; t 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< /var/run/grml-x/window-manager + fi + chvt 7 return fi cat>|/etc/init.d/startx<&1) ; do + IFS=$'\n' + for line in $(mdadm --assemble --scan 2>&1) ; do case $line in *'No arrays found'*) ewarn "$line" ; eend 0 @@ -1688,8 +1635,7 @@ config_swraid(){ 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 @@ -1723,8 +1669,7 @@ config_dmraid(){ [ -n "$1" ] || return 1 IFSOLD=${IFS:-} - IFS=' -' + IFS=$'\n' eindent for line in $(dmraid $1 ; echo errcode:$?); do @@ -1788,15 +1733,17 @@ config_lvm(){ 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 @@ -2015,7 +1962,6 @@ config_distri(){ 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