diff options
author | William Hubbs <williamh@gentoo.org> | 2011-02-11 16:13:36 -0600 |
---|---|---|
committer | William Hubbs <williamh@gentoo.org> | 2011-04-30 21:46:13 -0500 |
commit | 5a3f139a9c28368cc7283f982acba94ea09dc5a1 (patch) | |
tree | 363d2bd5ae7a3b01545abe7b620e5cc10326b219 | |
parent | migrate most services to the list_services function (diff) | |
download | livecd-tools-5a3f139a9c28368cc7283f982acba94ea09dc5a1.tar.gz livecd-tools-5a3f139a9c28368cc7283f982acba94ea09dc5a1.tar.bz2 livecd-tools-5a3f139a9c28368cc7283f982acba94ea09dc5a1.zip |
add fixinittab service
This is a port of the fix_inittab function from baselayout-1's version
of the livecd-tools. In openrc it is set up as a service which should
be added to the sysinit runlevel.
-rwxr-xr-x | fixinittab | 100 | ||||
-rwxr-xr-x | livecd-functions.sh | 93 |
2 files changed, 100 insertions, 93 deletions
diff --git a/fixinittab b/fixinittab new file mode 100755 index 0000000..b68be31 --- /dev/null +++ b/fixinittab @@ -0,0 +1,100 @@ +#!/bin/runscript + +depend() +{ + before dev +} + +start() +{ + if [ "${CDBOOT}" = "" ] + then + return 1 + fi + + # Create a backup + cp -f /etc/inittab /etc/inittab.old + + # Comment out current getty settings + sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab + sed -i -e '/^s[01]/ s/^/#/' /etc/inittab + + # SPARC & HPPA console magic + if [ "${HOSTTYPE}" = "sparc" -o "${HOSTTYPE}" = "hppa" -o "${HOSTTYPE}" = "ppc64" ] + then + # Mount openprom tree for user debugging purposes + if [ "${HOSTTYPE}" = "sparc" ] + then + mount -t openpromfs none /proc/openprom + fi + + # SPARC serial port A, HPPA mux / serial + if [ -c "/dev/ttyS0" ] + then + LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyS0 speed) + echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyS0 vt100" >> /etc/inittab + fi + # HPPA software PDC console (K-models) + if [ "${LIVECD_CONSOLE}" = "ttyB0" ] + then + mknod /dev/ttyB0 c 11 0 + LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyB0 speed) + echo "b0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyB0 vt100" >> /etc/inittab + fi + # FB / STI console + if [ -c "/dev/vc/1" -o -c "/dev/tts/1" -o -c "/dev/tty2" ] + then + MODEL_NAME=$(cat /proc/cpuinfo |grep "model name"|sed 's/.*: //') + if [ "${MODEL_NAME}" = "UML" ] + then + for x in 0 1 2 3 4 5 6 + do + echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab + done + else + for x in 1 2 3 4 5 6 + do + echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab + done + fi + fi + if [ -c "/dev/hvc0" ] + then + einfo "Adding hvc console to inittab" + echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 9600 hvc0 vt320" >> /etc/inittab + fi + + + # The rest... + else + if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ] + then + for x in 1 2 3 4 5 6 + do + echo "c${x}:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty${x} linux" >> /etc/inittab + done + else + einfo "Adding ${LIVECD_CONSOLE} console to inittab" + echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} vt100" >> /etc/inittab + fi + fi + + # EFI-based machines should automatically hook up their console lines + if dmesg | grep -q '^Adding console on' + then + dmesg | grep '^Adding console on' | while read x; do + line=`echo "$x" | cut -d' ' -f4` + id=e`echo "$line" | grep -o '.\{1,3\}$'` + [ "${line}" = "${LIVECD_CONSOLE}" ] && continue # already setup above + case "$x" in + *options\ \'[0-9]*) speed=`echo "$x" | sed "s/.*options '//; s/[^0-9].*//"` ;; + *) speed=9600 ;; # choose a default, only matters if it is serial + esac + echo "$id:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${speed} ${line} vt100" >> /etc/inittab + done + fi + + # force reread of inittab + telinit q + return 0 +} diff --git a/livecd-functions.sh b/livecd-functions.sh index 5eac162..81e2f1a 100755 --- a/livecd-functions.sh +++ b/livecd-functions.sh @@ -538,96 +538,3 @@ livecd_read_commandline() { done return 0 } - -livecd_fix_inittab() { - if [ "${CDBOOT}" = "" ] - then - return 1 - fi - - # Create a backup - cp -f /etc/inittab /etc/inittab.old - - # Comment out current getty settings - sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab - sed -i -e '/^s[01]/ s/^/#/' /etc/inittab - - # SPARC & HPPA console magic - if [ "${HOSTTYPE}" = "sparc" -o "${HOSTTYPE}" = "hppa" -o "${HOSTTYPE}" = "ppc64" ] - then - # Mount openprom tree for user debugging purposes - if [ "${HOSTTYPE}" = "sparc" ] - then - mount -t openpromfs none /proc/openprom - fi - - # SPARC serial port A, HPPA mux / serial - if [ -c "/dev/ttyS0" ] - then - LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyS0 speed) - echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyS0 vt100" >> /etc/inittab - fi - # HPPA software PDC console (K-models) - if [ "${LIVECD_CONSOLE}" = "ttyB0" ] - then - mknod /dev/ttyB0 c 11 0 - LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyB0 speed) - echo "b0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyB0 vt100" >> /etc/inittab - fi - # FB / STI console - if [ -c "/dev/vc/1" -o -c "/dev/tts/1" -o -c "/dev/tty2" ] - then - MODEL_NAME=$(cat /proc/cpuinfo |grep "model name"|sed 's/.*: //') - if [ "${MODEL_NAME}" = "UML" ] - then - for x in 0 1 2 3 4 5 6 - do - echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab - done - else - for x in 1 2 3 4 5 6 - do - echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab - done - fi - fi - if [ -c "/dev/hvc0" ] - then - einfo "Adding hvc console to inittab" - echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 9600 hvc0 vt320" >> /etc/inittab - fi - - - # The rest... - else - if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ] - then - for x in 1 2 3 4 5 6 - do - echo "c${x}:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty${x} linux" >> /etc/inittab - done - else - einfo "Adding ${LIVECD_CONSOLE} console to inittab" - echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} vt100" >> /etc/inittab - fi - fi - - # EFI-based machines should automatically hook up their console lines - if dmesg | grep -q '^Adding console on' - then - dmesg | grep '^Adding console on' | while read x; do - line=`echo "$x" | cut -d' ' -f4` - id=e`echo "$line" | grep -o '.\{1,3\}$'` - [ "${line}" = "${LIVECD_CONSOLE}" ] && continue # already setup above - case "$x" in - *options\ \'[0-9]*) speed=`echo "$x" | sed "s/.*options '//; s/[^0-9].*//"` ;; - *) speed=9600 ;; # choose a default, only matters if it is serial - esac - echo "$id:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${speed} ${line} vt100" >> /etc/inittab - done - fi - - # force reread of inittab - kill -HUP 1 - return 0 -} |