X-Git-Url: http://git.grml.org/?p=grml-autoconfig.git;a=blobdiff_plain;f=autoconfig.functions;h=a4faa87343f3e5d1462aeb782a5b109a246a8d73;hp=76581c9cd7f82325912b0f64ce932aeac0e5420c;hb=0e4cbb69e71cf942fab3842c4b70c981e80148be;hpb=9fade3196c65a2a915a8c4447f99730edc5106e4 diff --git a/autoconfig.functions b/autoconfig.functions index 76581c9..a4faa87 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -302,7 +302,7 @@ config_language(){ if [ -r /etc/default/locale ] ; then if grep -q "LANG=.*UTF" /etc/default/locale ; then einfo "Setting up unicode environment." - unicode_start 2>>$DEBUG ; eend $? + unicode_start >>$DEBUG 2>&1 ; eend $? fi fi @@ -314,13 +314,15 @@ config_language(){ fi # we have to set up all consoles, therefore loop it over all ttys: - NUM_CONSOLES=$(fgconsole --next-available) - [ -n "$NUM_CONSOLES" ] && NUM_CONSOLES=$(expr ${NUM_CONSOLES} - 1) - [ ${NUM_CONSOLES} -eq 1 ] && NUM_CONSOLES=6 - CUR_CONSOLE=$(fgconsole) - + 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 "Running consolechars for ${CHARMAP}" + RC=0 for vc in $(seq 0 ${NUM_CONSOLES}) ; do consolechars --tty=/dev/tty${vc} -m ${CHARMAP} ; RC=$? done @@ -335,6 +337,7 @@ config_language(){ else if [ -n "$CONSOLEFONT" ] ; then einfo "Running consolechars using ${CONSOLEFONT}" + RC=0 for vc in $(seq 0 ${NUM_CONSOLES}) ; do consolechars --tty=/dev/tty${vc} -f $CONSOLEFONT ; RC=$? done @@ -353,6 +356,10 @@ config_language(){ config_hostname(){ if checkbootparam 'hostname' ; then HOSTNAME="$(getbootparam 'hostname' 2>>$DEBUG)" + if [ -z "$HOSTNAME" ] && [ -x /usr/bin/random-hostname ] ; then + einfo "Generating random hostname as no hostname was specified" + HOSTNAME="$(/usr/bin/random-hostname)" + fi einfo "Setting hostname to $HOSTNAME as requested." grml-hostname $HOSTNAME >>$DEBUG ; RC=$? [ "$RC" = "0" ] && hostname $HOSTNAME @@ -572,9 +579,58 @@ fi # activate serial console {{{ config_console(){ if checkbootparam 'console'; then - einfo "Bootoption for serial console detected, activating console login." - sed -i 's/^#grmlserial#//' /etc/inittab - /sbin/telinit q + local line + local ws + ws=' ' + + einfo "Bootoption for serial console detected:" + + line="$CMDLINE x " + this="" + line="${line#*[$ws]}" + local telinitq="" + while [ -n "$line" ]; do + case "$this" in + console=*) + local serial="$this" + local device="${this%%,*}" + local device="${device##*=}" + if ! echo $serial | grep -q ttyS ; then + ewarn "Warning: console=ttyS... not specified as last console= option. Falling back to set up ttyS0/9600." + sed -i "/^#grmlserial#/iT0:23:respawn:/bin/bash -c \"/sbin/getty -L /dev/ttyS0 -l /usr/bin/zsh-login 9600 vt100 || sleep 30\"" /etc/inittab + eend 0 + else + local option="${serial##*,}" + # default (works for kvm & CO): + local speed="115200,57600,38400,19200,9600,4800,2400,1200"; + # ... unless overriden by command line: + case "$option" in + 115200*) speed=115200 ;; + 57600*) speed=57600 ;; + 38400*) speed=38400 ;; + 19200*) speed=19200 ;; + 9600*) speed=9600 ;; + 4800*) speed=4800 ;; + 2400*) speed=2400 ;; + 1200*) speed=1200 ;; + esac + fi + eindent + einfo "Activating console login on device ${device} with speed ${speed}." + local number="${device#ttyS}" + sed -i "/^#grmlserial#/iT$number:23:respawn:/bin/bash -c \"/sbin/getty -L $device -l /usr/bin/zsh-login $speed vt100 || sleep 30\"" /etc/inittab + eend $? + telinitq="1" + eoutdent + ;; + esac + this="${line%%[$ws]*}" + line="${line#*[$ws]}" + done + + if [ -n "$telinitq" ]; then + /sbin/telinit q + fi eend $? fi } @@ -1359,7 +1415,7 @@ else einfo "Loading modules ${MODULE}" modprobe "$MODULE" >>$DEBUG || modprobe "$MODULE_FALLBACK" >>$DEBUG RC=$? - if [[ $RC == 0 ]]; then + if [[ "$RC" == 0 ]]; then eend 0 else SKIP_CPU_GOVERNOR=1 @@ -1373,6 +1429,7 @@ else if [ -z "$SKIP_CPU_GOVERNOR" ] ; then einfo "Loading cpufreq_ondemand, setting ondemand governor" + RC=0 if modprobe cpufreq_ondemand ; RC=$? ; then for file in $(find /sys/devices/system/cpu/ -name scaling_governor 2>/dev/null) ; do echo ondemand > $file @@ -1832,20 +1889,19 @@ if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; t else einfo "Window manager ${WHITE}${WINDOWMANAGER}${NORMAL} found as bootoption." && eend 0 fi - einfo "Changing to runlevel 5 for starting grml-x ${WINDOWMANAGER}. Just exit X windows system to get full featured consoles." + einfo "Setting up and invoking grml-x ${WINDOWMANAGER}. Just exit X windows system to get full featured consoles." config_userfstab || fstabuser='grml' cat>|/etc/init.d/xstartup<>$DEBUG +su $fstabuser -c "/usr/bin/grml-x $WINDOWMANAGER" EOF chmod 755 /etc/init.d/xstartup # adjust inittab for xstartup if grep -q '^6:' /etc/inittab ; then - sed -i 's|^6:.*|6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /bin/zsh"|' /etc/inittab + sed -i 's|^6:.*|6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /usr/bin/zsh-login" >/dev/tty6 2>\&1 > /etc/inittab + echo '6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /usr/bin/zsh-login" >/dev/tty6 2>&1 < /dev/tty6' >> /etc/inittab fi /sbin/telinit q ; eend $?