console/serial bootoption: allow manually specifying speed settings.
[grml-autoconfig.git] / autoconfig.functions
index 73cc32e..f55b0d3 100755 (executable)
@@ -575,8 +575,33 @@ 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
+  einfo "Bootoption for serial console detected:"
+
+  local serial="$(getbootparam console=ttyS)"
+  option="${serial##*,}"
+
+  # default to:
+  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
+
+  eindent
+    einfo "Setting baud rate to ${speed}."
+    sed -i "s/%serialspeed%/$speed/" /etc/inittab ;  eend $?
+
+    einfo "Activating console login."
+    sed -i 's/^#grmlserial#//' /etc/inittab ; eend $?
+  eoutdent
+
   /sbin/telinit q
   eend $?
 fi
@@ -1836,20 +1861,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<<EOF
 #!/bin/sh
-# su - $fstabuser -c 'grml-x "$WINDOWMANAGER"'
-sudo -u $fstabuser -i /usr/bin/grml-x $WINDOWMANAGER >>$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 </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 ; /bin/zsh"' >> /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 $?