console/serial bootoption: allow manually specifying speed settings.
authorMichael Prokop <mika@grml.org>
Mon, 31 May 2010 21:59:46 +0000 (23:59 +0200)
committerMichael Prokop <mika@grml.org>
Mon, 31 May 2010 21:59:46 +0000 (23:59 +0200)
autoconfig.functions

index c0c1111..f55b0d3 100755 (executable)
@@ -575,8 +575,33 @@ fi
 # activate serial console {{{
 config_console(){
 if checkbootparam 'console'; then
 # 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
   /sbin/telinit q
   eend $?
 fi