X-Git-Url: http://git.grml.org/?p=grml-autoconfig.git;a=blobdiff_plain;f=autoconfig.functions;h=ccf12d673b6131d75d2a0a5f79cfd24174b12f3b;hp=1c5c46b1b45877f88522ae9a91e70eb5f303db51;hb=176568ce0d352cb56b370737c3263eb09eba8e89;hpb=4dca8013673e8de2bf8adc4fa45eb31eda1bc78a diff --git a/autoconfig.functions b/autoconfig.functions index 1c5c46b..ccf12d6 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -540,6 +540,27 @@ config_kernel(){ } # }}} +# {{{ secure boot +config_secureboot(){ + if [ -x /usr/bin/mokutil ] ; then + local secstate=$(mokutil --sb-state 2>/dev/null) # "SecureBoot enabled" + if [ -n "$secstate" ] ; then + einfo "SecureBoot is enabled" ; eend 0 + else + einfo "SecureBoot not detected" ; eend 0 + fi + else + if modprobe efivars &>/dev/null ; then + if od -An -t u1 /sys/firmware/efi/vars/SecureBoot-*/data 2>/dev/null | grep -q 1 ; then + einfo "SecureBoot is enabled" ; eend 0 + else + einfo "SecureBoot not detected" ; eend 0 + fi + fi + fi +} +# }}} + # {{{ timezone config_timezone(){ # don't touch the files if running from harddisk: @@ -569,6 +590,11 @@ config_timezone(){ # 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=' ' @@ -1111,83 +1137,83 @@ 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=' + ' + 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 - 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 [ ${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 } # }}} @@ -1337,10 +1363,6 @@ config_stats() { # {{{ start X window system via grml-x config_x_startup(){ - if $SYSTEMD ; then - ewarn "The startx boot option isn't yet supported via systemd, sorry." ; eend 0 - return - fi # 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 @@ -1355,17 +1377,28 @@ if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; t 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<|/etc/init.d/startx<|/etc/init.d/startx</dev/tty6 2>\&1 /dev/tty6 2>\&1 /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 $? @@ -1623,7 +1656,11 @@ config_swraid(){ 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 'Start mdmonitor' 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:" @@ -1750,11 +1787,19 @@ config_lvm(){ 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-lvmetad' to activate them 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:" - service_wrapper lvm2 start ; eend $? + if $SYSTEMD ; then + service_wrapper lvm2-lvmetad start ; eend $? + else + service_wrapper lvm2 start ; eend $? + fi fi eoutdent fi