summaryrefslogtreecommitdiff
blob: d675b9bd53a677e51b3fb3d84969bfb084d4ee51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/sbin/openrc-run

depend()
{
	after root
}

start()
{
	if [ "${CDBOOT}" = "" ]
	then
		return 1
	fi

	for x in ${CMDLINE} ; do
		case "${x}" in
			secureconsole) SECURECONSOLE="yes";;
    esac
  done

	ebegin "Adjusting inittab"
	# Create a backup
	if [ ! -e /etc/inittab.old ]
	then
		cp -f /etc/inittab /etc/inittab.old
	fi

	# Comment out current getty settings
	sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab
	sed -i -e '/^s[01]/ s/^/#/' /etc/inittab
	sed -i -e '/^b0/ 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 -a root ${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 -a root ${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 $(id -nu 1000 2>/dev/null || echo 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 $(id -nu 1000 2>/dev/null || echo root) tty${x}" >> /etc/inittab
			    done
			fi
		fi
		if [ -c "/dev/hvc0" ]
		then
			eindent
			ebegin "Adding hvc console to inittab ..."
			echo "s0:12345:respawn:/sbin/agetty -a root 9600 hvc0 vt320" >> /etc/inittab
			eend $?
			eoutdent
		fi

	# The rest...
	else
		if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ]
		then
			if [ "${SECURECONSOLE}" = "yes" ]; then
				echo "c1:12345:respawn:/sbin/mingetty --noclear --autologin $(id -nu 1000 2>/dev/null || echo root) tty${x}" >> /etc/inittab
			else
				for x in 1 2 3 4 5 6
				do
					echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin $(id -nu 1000 2>/dev/null || echo root) tty${x}" >> /etc/inittab
				done
			fi
		else
			eindent
			ebegin "Adding ${LIVECD_CONSOLE} console to inittab"
			echo "s0:12345:respawn:/sbin/agetty -a root ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} vt100" >> /etc/inittab
			eend $?
			eoutdent
		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 -a root ${speed} ${line} vt100" >> /etc/inittab
		done
	fi

	# force reread of inittab
	telinit q

	eend 0
}