2012-03-02 19:32:28 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# console - virtual consoles plugin for postplug
|
2013-04-05 14:23:43 +02:00
|
|
|
# Copyright (c) 2012-2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
2012-03-02 19:32:28 +01:00
|
|
|
|
2013-04-05 14:19:03 +02:00
|
|
|
# systemd: no need to manage inittab
|
|
|
|
[ -d /run/systemd ] && exit 0
|
|
|
|
|
2012-03-02 19:32:28 +01:00
|
|
|
if [ $UID != 0 ]; then
|
|
|
|
echo "$0: must be superuser." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
TTYs=`grep "^[0-9]:" /etc/inittab | sed "s|.*\(tty[^[:space:]]*\).*|\1|"`
|
|
|
|
|
|
|
|
for t in $TTYs; do
|
|
|
|
case $t in
|
|
|
|
tty[0-9]*)
|
|
|
|
[ -e /dev/tty ] && continue;
|
|
|
|
sed -i "s|\([0-9].*$t .*\)|#\1|" /etc/inittab
|
|
|
|
TTYchanged=1
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
tty*)
|
|
|
|
if [ ! -e /dev/$t -o "`setserial /dev/$t | grep 'UART: unknown' 2>/dev/null`" ]; then
|
|
|
|
sed -i "s|\([0-9].*$t .*\)|#\1|" /etc/inittab
|
|
|
|
TTYchanged=1
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
[ "$TTYchanged" ] && telinit q
|
|
|
|
|
|
|
|
exit 0
|