ar71xx: enable login only on the system console by default
authorGabor Juhos <juhosg@openwrt.org>
Fri, 23 Sep 2011 19:56:38 +0000 (19:56 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Fri, 23 Sep 2011 19:56:38 +0000 (19:56 +0000)
SVN-Revision: 28294

target/linux/ar71xx/base-files/etc/inittab
target/linux/ar71xx/base-files/etc/uci-defaults/inittab-console-fixup [new file with mode: 0755]

index af4bf80dc0cf992e815f093c2f54dd07c321c92d..17f829f6d48acb66bd3a3d66c94252c2750510d5 100644 (file)
@@ -1,4 +1,2 @@
 ::sysinit:/etc/init.d/rcS S boot
 ::shutdown:/etc/init.d/rcS K shutdown
-ttyS0::askfirst:/bin/ash --login
-ttyATH0::askfirst:/bin/ash --login
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/inittab-console-fixup b/target/linux/ar71xx/base-files/etc/uci-defaults/inittab-console-fixup
new file mode 100755 (executable)
index 0000000..4836817
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+
+enable_console_login() {
+       local cons=$1
+       local initline="$cons::askfirst:/bin/ash --login"
+
+       grep -qs "^$initline" /etc/inittab || {
+               echo "$initline" >> /etc/inittab
+               sync
+               kill -HUP 1
+       }
+}
+
+inittab_console_fixup() {
+       for cons in ttyS0 ttyATH0; do
+               grep -qs "console=$cons" /proc/cmdline && {
+                       enable_console_login $cons
+               }
+       done
+}
+
+inittab_console_fixup