1 |
commit: 5a3f139a9c28368cc7283f982acba94ea09dc5a1 |
2 |
Author: William Hubbs <williamh <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Feb 11 22:13:36 2011 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun May 1 02:46:13 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/livecd-tools.git;a=commit;h=5a3f139a |
7 |
|
8 |
add fixinittab service |
9 |
|
10 |
This is a port of the fix_inittab function from baselayout-1's version |
11 |
of the livecd-tools. In openrc it is set up as a service which should |
12 |
be added to the sysinit runlevel. |
13 |
|
14 |
--- |
15 |
fixinittab | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 |
livecd-functions.sh | 93 ----------------------------------------------- |
17 |
2 files changed, 100 insertions(+), 93 deletions(-) |
18 |
|
19 |
diff --git a/fixinittab b/fixinittab |
20 |
new file mode 100755 |
21 |
index 0000000..b68be31 |
22 |
--- /dev/null |
23 |
+++ b/fixinittab |
24 |
@@ -0,0 +1,100 @@ |
25 |
+#!/bin/runscript |
26 |
+ |
27 |
+depend() |
28 |
+{ |
29 |
+ before dev |
30 |
+} |
31 |
+ |
32 |
+start() |
33 |
+{ |
34 |
+ if [ "${CDBOOT}" = "" ] |
35 |
+ then |
36 |
+ return 1 |
37 |
+ fi |
38 |
+ |
39 |
+ # Create a backup |
40 |
+ cp -f /etc/inittab /etc/inittab.old |
41 |
+ |
42 |
+ # Comment out current getty settings |
43 |
+ sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab |
44 |
+ sed -i -e '/^s[01]/ s/^/#/' /etc/inittab |
45 |
+ |
46 |
+ # SPARC & HPPA console magic |
47 |
+ if [ "${HOSTTYPE}" = "sparc" -o "${HOSTTYPE}" = "hppa" -o "${HOSTTYPE}" = "ppc64" ] |
48 |
+ then |
49 |
+ # Mount openprom tree for user debugging purposes |
50 |
+ if [ "${HOSTTYPE}" = "sparc" ] |
51 |
+ then |
52 |
+ mount -t openpromfs none /proc/openprom |
53 |
+ fi |
54 |
+ |
55 |
+ # SPARC serial port A, HPPA mux / serial |
56 |
+ if [ -c "/dev/ttyS0" ] |
57 |
+ then |
58 |
+ LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyS0 speed) |
59 |
+ echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyS0 vt100" >> /etc/inittab |
60 |
+ fi |
61 |
+ # HPPA software PDC console (K-models) |
62 |
+ if [ "${LIVECD_CONSOLE}" = "ttyB0" ] |
63 |
+ then |
64 |
+ mknod /dev/ttyB0 c 11 0 |
65 |
+ LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyB0 speed) |
66 |
+ echo "b0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyB0 vt100" >> /etc/inittab |
67 |
+ fi |
68 |
+ # FB / STI console |
69 |
+ if [ -c "/dev/vc/1" -o -c "/dev/tts/1" -o -c "/dev/tty2" ] |
70 |
+ then |
71 |
+ MODEL_NAME=$(cat /proc/cpuinfo |grep "model name"|sed 's/.*: //') |
72 |
+ if [ "${MODEL_NAME}" = "UML" ] |
73 |
+ then |
74 |
+ for x in 0 1 2 3 4 5 6 |
75 |
+ do |
76 |
+ echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab |
77 |
+ done |
78 |
+ else |
79 |
+ for x in 1 2 3 4 5 6 |
80 |
+ do |
81 |
+ echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab |
82 |
+ done |
83 |
+ fi |
84 |
+ fi |
85 |
+ if [ -c "/dev/hvc0" ] |
86 |
+ then |
87 |
+ einfo "Adding hvc console to inittab" |
88 |
+ echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 9600 hvc0 vt320" >> /etc/inittab |
89 |
+ fi |
90 |
+ |
91 |
+ |
92 |
+ # The rest... |
93 |
+ else |
94 |
+ if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ] |
95 |
+ then |
96 |
+ for x in 1 2 3 4 5 6 |
97 |
+ do |
98 |
+ echo "c${x}:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty${x} linux" >> /etc/inittab |
99 |
+ done |
100 |
+ else |
101 |
+ einfo "Adding ${LIVECD_CONSOLE} console to inittab" |
102 |
+ echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} vt100" >> /etc/inittab |
103 |
+ fi |
104 |
+ fi |
105 |
+ |
106 |
+ # EFI-based machines should automatically hook up their console lines |
107 |
+ if dmesg | grep -q '^Adding console on' |
108 |
+ then |
109 |
+ dmesg | grep '^Adding console on' | while read x; do |
110 |
+ line=`echo "$x" | cut -d' ' -f4` |
111 |
+ id=e`echo "$line" | grep -o '.\{1,3\}$'` |
112 |
+ [ "${line}" = "${LIVECD_CONSOLE}" ] && continue # already setup above |
113 |
+ case "$x" in |
114 |
+ *options\ \'[0-9]*) speed=`echo "$x" | sed "s/.*options '//; s/[^0-9].*//"` ;; |
115 |
+ *) speed=9600 ;; # choose a default, only matters if it is serial |
116 |
+ esac |
117 |
+ echo "$id:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${speed} ${line} vt100" >> /etc/inittab |
118 |
+ done |
119 |
+ fi |
120 |
+ |
121 |
+ # force reread of inittab |
122 |
+ telinit q |
123 |
+ return 0 |
124 |
+} |
125 |
|
126 |
diff --git a/livecd-functions.sh b/livecd-functions.sh |
127 |
index 5eac162..81e2f1a 100755 |
128 |
--- a/livecd-functions.sh |
129 |
+++ b/livecd-functions.sh |
130 |
@@ -538,96 +538,3 @@ livecd_read_commandline() { |
131 |
done |
132 |
return 0 |
133 |
} |
134 |
- |
135 |
-livecd_fix_inittab() { |
136 |
- if [ "${CDBOOT}" = "" ] |
137 |
- then |
138 |
- return 1 |
139 |
- fi |
140 |
- |
141 |
- # Create a backup |
142 |
- cp -f /etc/inittab /etc/inittab.old |
143 |
- |
144 |
- # Comment out current getty settings |
145 |
- sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab |
146 |
- sed -i -e '/^s[01]/ s/^/#/' /etc/inittab |
147 |
- |
148 |
- # SPARC & HPPA console magic |
149 |
- if [ "${HOSTTYPE}" = "sparc" -o "${HOSTTYPE}" = "hppa" -o "${HOSTTYPE}" = "ppc64" ] |
150 |
- then |
151 |
- # Mount openprom tree for user debugging purposes |
152 |
- if [ "${HOSTTYPE}" = "sparc" ] |
153 |
- then |
154 |
- mount -t openpromfs none /proc/openprom |
155 |
- fi |
156 |
- |
157 |
- # SPARC serial port A, HPPA mux / serial |
158 |
- if [ -c "/dev/ttyS0" ] |
159 |
- then |
160 |
- LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyS0 speed) |
161 |
- echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyS0 vt100" >> /etc/inittab |
162 |
- fi |
163 |
- # HPPA software PDC console (K-models) |
164 |
- if [ "${LIVECD_CONSOLE}" = "ttyB0" ] |
165 |
- then |
166 |
- mknod /dev/ttyB0 c 11 0 |
167 |
- LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyB0 speed) |
168 |
- echo "b0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyB0 vt100" >> /etc/inittab |
169 |
- fi |
170 |
- # FB / STI console |
171 |
- if [ -c "/dev/vc/1" -o -c "/dev/tts/1" -o -c "/dev/tty2" ] |
172 |
- then |
173 |
- MODEL_NAME=$(cat /proc/cpuinfo |grep "model name"|sed 's/.*: //') |
174 |
- if [ "${MODEL_NAME}" = "UML" ] |
175 |
- then |
176 |
- for x in 0 1 2 3 4 5 6 |
177 |
- do |
178 |
- echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab |
179 |
- done |
180 |
- else |
181 |
- for x in 1 2 3 4 5 6 |
182 |
- do |
183 |
- echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab |
184 |
- done |
185 |
- fi |
186 |
- fi |
187 |
- if [ -c "/dev/hvc0" ] |
188 |
- then |
189 |
- einfo "Adding hvc console to inittab" |
190 |
- echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 9600 hvc0 vt320" >> /etc/inittab |
191 |
- fi |
192 |
- |
193 |
- |
194 |
- # The rest... |
195 |
- else |
196 |
- if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ] |
197 |
- then |
198 |
- for x in 1 2 3 4 5 6 |
199 |
- do |
200 |
- echo "c${x}:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty${x} linux" >> /etc/inittab |
201 |
- done |
202 |
- else |
203 |
- einfo "Adding ${LIVECD_CONSOLE} console to inittab" |
204 |
- echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} vt100" >> /etc/inittab |
205 |
- fi |
206 |
- fi |
207 |
- |
208 |
- # EFI-based machines should automatically hook up their console lines |
209 |
- if dmesg | grep -q '^Adding console on' |
210 |
- then |
211 |
- dmesg | grep '^Adding console on' | while read x; do |
212 |
- line=`echo "$x" | cut -d' ' -f4` |
213 |
- id=e`echo "$line" | grep -o '.\{1,3\}$'` |
214 |
- [ "${line}" = "${LIVECD_CONSOLE}" ] && continue # already setup above |
215 |
- case "$x" in |
216 |
- *options\ \'[0-9]*) speed=`echo "$x" | sed "s/.*options '//; s/[^0-9].*//"` ;; |
217 |
- *) speed=9600 ;; # choose a default, only matters if it is serial |
218 |
- esac |
219 |
- echo "$id:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${speed} ${line} vt100" >> /etc/inittab |
220 |
- done |
221 |
- fi |
222 |
- |
223 |
- # force reread of inittab |
224 |
- kill -HUP 1 |
225 |
- return 0 |
226 |
-} |