/[livecd-tools]/trunk/livecd-functions.sh
Gentoo

Contents of /trunk/livecd-functions.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 133 - (show annotations) (download) (as text)
Tue Oct 30 20:59:55 2007 UTC (7 years, 1 month ago) by wolf31o2
File MIME type: text/x-sh
File size: 17278 byte(s)
Added a small fix for bug #111972 and also doing some minor clean up.
1 #!/bin/bash
2
3 # Global Variables:
4 # CDBOOT -- is booting off CD
5 # LIVECD_CONSOLE -- console that is specified on commandline
6 # -- (ttyS0, etc) Only defined if passed to kernel
7 # LIVECD_CONSOLE_BAUD -- console baudrate specified
8 # LIVECD_CONSOLE_PARITY -- console parity specified
9 # LIVECD_CONSOLE_DATABITS -- console databits specified
10
11 [[ ${RC_GOT_FUNCTIONS} != "yes" ]] && [[ -e /etc/init.d/functions.sh ]] && source /etc/init.d/functions.sh
12
13 livecd_parse_opt() {
14 case "$1" in
15 *\=*)
16 echo "$1" | cut -f2 -d=
17 ;;
18 esac
19 }
20
21 livecd_check_root() {
22 if [ "$(whoami)" != "root" ]
23 then
24 echo "ERROR: must be root to continue"
25 return 1
26 fi
27 }
28
29 livecd_get_cmdline() {
30 echo "0" > /proc/sys/kernel/printk
31 CMDLINE=$(cat /proc/cmdline)
32 export CMDLINE
33 }
34
35 no_gl() {
36 # einfo "If you have a card that you know is supported by either the ATI or"
37 # einfo "NVIDIA binary drivers, please file a bug with the output of lspci"
38 # einfo "on http://bugs.gentoo.org so we can resolve this."
39 GLTYPE=xorg-x11
40 }
41
42 ati_gl() {
43 einfo "ATI card detected."
44 if [ -e /usr/lib/xorg/modules/drivers/fglrx_drv.so ] \
45 || [ -e /usr/lib/modules/drivers/fglrx_drv.so ]
46 then
47 # sed -i \
48 # -e 's/ati/fglrx/' \
49 # -e 's/radeon/fglrx/' \
50 # -e 's/r300/fglrx/' \
51 # /etc/X11/xorg.conf
52 GLTYPE=ati
53 else
54 GLTYPE=xorg-x11
55 fi
56 }
57
58 nv_gl() {
59 einfo "NVIDIA card detected."
60 if [ -e /usr/lib/xorg/modules/drivers/nvidia_drv.so ] \
61 || [ -e /usr/lib/modules/drivers/nvidia_drv.so ]
62 then
63 GLTYPE=nvidia
64 else
65 GLTYPE=xorg-x11
66 fi
67 }
68
69 nv_no_gl() {
70 einfo "NVIDIA card detected."
71 echo
72 if [ -e /usr/lib/xorg/modules/drivers/nvidia_drv.so ] \
73 || [ -e /usr/lib/modules/drivers/nvidia_drv.so ]
74 then
75 einfo "This card is not supported by the latest version of the NVIDIA"
76 einfo "binary drivers. Switching to the X server's driver instead."
77 fi
78 GLTYPE=xorg-x11
79 sed -i 's/nvidia/nv/' /etc/X11/xorg.conf
80 }
81
82 get_video_cards() {
83 [ -x /sbin/lspci ] && VIDEO_CARDS=$(/sbin/lspci | grep ' VGA ')
84 [ -x /usr/sbin/lspci ] && VIDEO_CARDS=$(/usr/sbin/lspci | grep ' VGA ')
85 NUM_CARDS=$(echo ${VIDEO_CARDS} | wc -l)
86 if [ ${NUM_CARDS} -eq 1 ]
87 then
88 NVIDIA=$(echo ${VIDEO_CARDS} | grep "nVidia Corporation")
89 ATI=$(echo ${VIDEO_CARDS} | grep "ATI Technologies")
90 if [ -n "${NVIDIA}" ]
91 then
92 NVIDIA_CARD=$(echo ${NVIDIA} | awk 'BEGIN {RS=" "} /(NV|nv|G|C)[0-9]+/ {print $1}' | cut -d. -f1 | sed 's/ //' | sed 's:[^0-9]::g')
93 # NVIDIA Model reference:
94 # http://en.wikipedia.org/wiki/Comparison_of_NVIDIA_Graphics_Processing_Units
95 if [ -n "${NVIDIA_CARD}" ]
96 then
97 if [ $(echo ${NVIDIA_CARD} | cut -dV -f2) -ge 17 ]
98 then
99 nv_gl
100 elif [ $(echo ${NVIDIA_CARD} | cut -dG -f2) -ge 70 ]
101 then
102 nv_gl
103 elif [ $(echo ${NVIDIA_CARD} | cut -dV -f2) -eq 11 ]
104 then
105 nv_gl
106 elif [ $(echo ${NVIDIA_CARD} | cut -dC -f2) -ge 50 ]
107 then
108 nv_gl
109 else
110 nv_no_gl
111 fi
112 else
113 no_gl
114 fi
115 elif [ -n "${ATI}" ]
116 then
117 ATI_CARD=$(echo ${ATI} | awk 'BEGIN {RS=" "} /(R|RV|RS)[0-9]+/ {print $1}' | sed -e 's/[^0-9]//g')
118 if [ $(echo ${ATI_CARD} | grep S) ]
119 then
120 ATI_CARD_S=$(echo ${ATI_CARD} | cut -dS -f2)
121 elif [ $(echo ${ATI_CARD} | grep V) ]
122 then
123 ATI_CARD_V=$(echo ${ATI_CARD} | cut -dV -f2)
124 else
125 ATI_CARD=$(echo ${ATI_CARD} | cut -dR -f2)
126 fi
127 if [ -n "${ATI_CARD_S}" ] && [ ${ATI_CARD_S} -ge 350 ]
128 then
129 ati_gl
130 elif [ -n "${ATI_CARD_V}" ] && [ ${ATI_CARD_V} -ge 250 ]
131 then
132 ati_gl
133 elif [ -n "${ATI_CARD}" ] && [ ${ATI_CARD} -ge 200 ]
134 then
135 ati_gl
136 else
137 no_gl
138 fi
139 else
140 no_gl
141 fi
142 fi
143 }
144
145 livecd_config_wireless() {
146 cd /tmp/setup.opts
147 [ -x /usr/sbin/iwconfig ] && iwconfig=/usr/sbin/iwconfig
148 [ -x /sbin/iwconfig ] && iwconfig=/sbin/iwconfig
149 dialog --title "SSID" --inputbox "Please enter your SSID, or leave blank for selecting the nearest open network" 20 50 2> ${iface}.SSID
150 SSID=$(tail -n 1 ${iface}.SSID)
151 if [ -n "${SSID}" ]
152 then
153 dialog --title "WEP (Part 1)" --menu "Does your network use encryption?" 20 60 7 1 "Yes" 2 "No" 2> ${iface}.WEP
154 WEP=$(tail -n 1 ${iface}.WEP)
155 case ${WEP} in
156 1)
157 dialog --title "WEP (Part 2)" --menu "Are you entering your WEP key in HEX or ASCII?" 20 60 7 1 "HEX" 2 "ASCII" 2> ${iface}.WEPTYPE
158 WEP_TYPE=$(tail -n 1 ${iface}.WEPTYPE)
159 case ${WEP_TYPE} in
160 1)
161 dialog --title "WEP (Part 3)" --inputbox "Please enter your WEP key in the form of XXXX-XXXX-XX for 64-bit or XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XX for 128-bit" 20 50 2> ${iface}.WEPKEY
162 WEP_KEY=$(tail -n 1 ${iface}.WEPKEY)
163 if [ -n "${WEP_KEY}" ]
164 then
165 ${iwconfig} ${iface} essid "${SSID}"
166 ${iwconfig} ${iface} key "${WEP_KEY}"
167 fi
168 ;;
169 2)
170 dialog --title "WEP (Part 3)" --inputbox "Please enter your WEP key in ASCII form. This should be 5 or 13 characters for either 64-bit or 128-bit encryption, repectively" 20 50 2> ${iface}.WEPKEY
171 WEP_KEY=$(tail -n 1 ${iface}.WEPKEY)
172 if [ -n "${WEP_KEY}" ]
173 then
174 ${iwconfig} ${iface} essid "${SSID}"
175 ${iwconfig} ${iface} key "s:${WEP_KEY}"
176 fi
177 ;;
178 esac
179 ;;
180 2)
181 ${iwconfig} ${iface} essid "${SSID}"
182 ${iwconfig} ${iface} key off
183 ;;
184 esac
185 fi
186 }
187
188 livecd_write_wireless_conf() {
189 cd /tmp/setup.opts
190 SSID=$(tail -n 1 ${iface}.SSID)
191 if [ -n "${SSID}" ]
192 then
193 echo "" >> /etc/conf.d/net
194 echo "# This wireless configuration file was built by net-setup" > /etc/conf.d/net
195 WEP=$(tail -n 1 ${iface}.WEPTYPE)
196 case ${WEP} in
197 1)
198 WEP_TYPE=$(tail -n 1 ${iface}.WEPTYPE)
199 if [ -n "${WEP_TYPE}" ]
200 then
201 WEP_KEY=$(tail -n 1 ${iface}.WEPKEY)
202 if [ -n "${WEP_KEY}" ]
203 then
204 SSID_TRANS=$(echo ${SSID//[![:word:]]/_})
205 case ${WEP_TYPE} in
206 1)
207 echo "key_${SSID_TRANS}=\"${WEP_KEY} enc open\"" >> /etc/conf.d/net
208 ;;
209 2)
210 echo "key_${SSID_TRANS}=\"s:${WEP_KEY} enc open\"" >> /etc/conf.d/net
211 ;;
212 esac
213 fi
214 fi
215 ;;
216 2)
217 :
218 ;;
219 esac
220 echo "preferred_aps=( \"${SSID}\" )" >> /etc/conf.d/net
221 echo "associate_order=\"forcepreferredonly\"" >> /etc/conf.d/net
222 fi
223 }
224
225 livecd_config_ip() {
226 cd /tmp/setup.opts
227 dialog --title "TCP/IP setup" --menu "You can use DHCP to automatically configure a network interface or you can specify an IP and related settings manually. Choose one option:" 20 60 7 1 "Use DHCP to auto-detect my network settings" 2 "Specify an IP address manually" 2> ${iface}.DHCP
228 DHCP=$(tail -n 1 ${iface}.DHCP)
229 case ${DHCP} in
230 1)
231 /sbin/dhcpcd -n -t 10 -h $(hostname) ${iface} &
232 ;;
233 2)
234 dialog --title "IP address" --inputbox "Please enter an IP address for ${iface}:" 20 50 "192.168.1.1" 2> ${iface}.IP
235 IP=$(tail -n 1 ${iface}.IP)
236 BC_TEMP=$(echo $IP|cut -d . -f 1).$(echo $IP|cut -d . -f 2).$(echo $IP|cut -d . -f 3).255
237 dialog --title "Broadcast address" --inputbox "Please enter a Broadcast address for ${iface}:" 20 50 "${BC_TEMP}" 2> ${iface}.BC
238 BROADCAST=$(tail -n 1 ${iface}.BC)
239 dialog --title "Network mask" --inputbox "Please enter a Network Mask for ${iface}:" 20 50 "255.255.255.0" 2> ${iface}.NM
240 NETMASK=$(tail -n 1 ${iface}.NM)
241 dialog --title "Gateway" --inputbox "Please enter a Gateway for ${iface} (hit enter for none:)" 20 50 2> ${iface}.GW
242 GATEWAY=$(tail -n 1 ${iface}.GW)
243 dialog --title "DNS server" --inputbox "Please enter a name server to use (hit enter for none:)" 20 50 2> ${iface}.DNS
244 DNS=$(tail -n 1 ${iface}.DNS)
245 /sbin/ifconfig ${iface} ${IP} broadcast ${BROADCAST} netmask ${NETMASK}
246 if [ -n "${GATEWAY}" ]
247 then
248 /sbin/route add default gw ${GATEWAY} dev ${iface} netmask 0.0.0.0 metric 1
249 fi
250 if [ -n "${DNS}" ]
251 then
252 dialog --title "DNS Search Suffix" --inputbox "Please enter any domains which you would like to search on DNS queries (hit enter for none:)" 20 50 2> ${iface}.SUFFIX
253 SUFFIX=$(tail -n 1 ${iface}.SUFFIX)
254 echo "nameserver ${DNS}" > /etc/resolv.conf
255 if [ -n "${SUFFIX}" ]
256 then
257 echo "search ${SUFFIX}" >> /etc/resolv.conf
258 fi
259 fi
260 ;;
261 esac
262 }
263
264 livecd_write_net_conf() {
265 cd /tmp/setup.opts
266 echo "" > /etc/conf.d/net
267 echo "# This network configuration was written by net-setup" > /etc/conf.d/net
268 DHCP=$(tail -n 1 ${iface}.DHCP)
269 case ${DHCP} in
270 1)
271 echo "config_${iface}=\"dhcp\"" >> /etc/conf.d/net
272 ;;
273 2)
274 IP=$(tail -n 1 ${iface}.IP)
275 BROADCAST=$(tail -n 1 ${iface}.BC)
276 NETMASK=$(tail -n 1 ${iface}.NM)
277 GATEWAY=$(tail -n 1 ${iface}.GW)
278 if [ -n "${IP}" -a -n "${BROADCAST}" -a -n "${NETMASK}" ]
279 then
280 echo "config_${iface}=( \"${IP} broadcast ${BROADCAST} netmask ${NETMASK}\" )" >> /etc/conf.d/net
281 if [ -n "${GATEWAY}" ]
282 then
283 echo "routes_${iface}=( \"default via ${GATEWAY}\" )" >> /etc/conf.d/net
284 fi
285 fi
286 ;;
287 esac
288 }
289
290 get_ifmac() {
291 local iface=$1
292
293 # Example: 00:01:6f:e1:7a:06
294 cat /sys/class/net/${iface}/address
295 }
296
297
298 get_ifdriver() {
299 local iface=$1
300
301 # Example: ../../../bus/pci/drivers/forcedeth (wanted: forcedeth)
302 local if_driver=$(readlink /sys/class/net/${iface}/device/driver)
303 basename ${if_driver}
304 }
305
306 get_ifbus() {
307 local iface=$1
308
309 # Example: ../../../bus/pci (wanted: pci)
310 # Example: ../../../../bus/pci (wanted: pci)
311 # Example: ../../../../../../bus/usb (wanted: usb)
312 local if_bus=$(readlink /sys/class/net/${iface}/device/bus)
313 basename ${if_bus}
314 }
315
316 get_ifproduct() {
317 local iface=$1
318 local bus=$(get_ifbus ${iface})
319 local if_pciaddr
320 local if_devname
321 local if_usbpath
322 local if_usbmanufacturer
323 local if_usbproduct
324
325 if [[ ${bus} == "pci" ]]
326 then
327 # Example: ../../../devices/pci0000:00/0000:00:0a.0 (wanted: 0000:00:0a.0)
328 # Example: ../../../devices/pci0000:00/0000:00:09.0/0000:01:07.0 (wanted: 0000:01:07.0)
329 if_pciaddr=$(readlink /sys/class/net/${iface}/device)
330 if_pciaddr=$(basename ${if_pciaddr})
331
332 # Example: 00:0a.0 Bridge: nVidia Corporation CK804 Ethernet Controller (rev a3)
333 # (wanted: nVidia Corporation CK804 Ethernet Controller)
334 if_devname=$(lspci -s ${if_pciaddr})
335 if_devname=${if_devname#*: }
336 if_devname=${if_devname%(rev *)}
337 fi
338
339 if [[ ${bus} == "usb" ]]
340 then
341 if_usbpath=$(readlink /sys/class/net/${iface}/device)
342 if_usbpath=/sys/class/net/${iface}/$(dirname ${if_usbpath})
343 if_usbmanufacturer=$(< ${if_usbpath}/manufacturer)
344 if_usbproduct=$(< ${if_usbpath}/product)
345
346 [[ -n ${if_usbmanufacturer} ]] && if_devname="${if_usbmanufacturer} "
347 [[ -n ${if_usbproduct} ]] && if_devname="${if_devname}${if_usbproduct}"
348 fi
349
350 if [[ ${bus} == "ieee1394" ]]
351 then
352 if_devname="IEEE1394 (FireWire) Network Adapter";
353 fi
354
355 echo ${if_devname}
356 }
357
358 get_ifdesc() {
359 local iface=$1
360 desc=$(get_ifproduct ${iface})
361 if [[ -n ${desc} ]]
362 then
363 echo $desc
364 return;
365 fi
366
367 desc=$(get_ifdriver ${iface})
368 if [[ -n ${desc} ]]
369 then
370 echo $desc
371 return;
372 fi
373
374 desc=$(get_ifmac ${iface})
375 if [[ -n ${desc} ]]
376 then
377 echo $desc
378 return;
379 fi
380
381 echo "Unknown"
382 }
383
384 show_ifmenu() {
385 local old_ifs="${IFS}"
386 local opts
387 IFS="
388 "
389 for ifname in $(/sbin/ifconfig -a | grep "^[^ ]"); do
390 ifname="${ifname%% *}"
391 [[ ${ifname} == "lo" ]] && continue
392 opts="${opts} ${ifname} '$(get_ifdesc ${ifname})'"
393 done
394 IFS="${old_ifs}"
395
396 if ! eval dialog --menu "Please select the interface that you wish to configure from the list below:" 0 0 0 $opts 2>iface
397 then
398 exit
399 fi
400
401 iface=$(< iface)
402 }
403
404 show_ifconfirm() {
405 local iface=$1
406 local if_mac=$(get_ifmac ${iface})
407 local if_driver=$(get_ifdriver ${iface})
408 local if_bus=$(get_ifbus ${iface})
409 local if_product=$(get_ifproduct ${iface})
410
411 local text="Details for network interface ${iface} are shown below.\n\nInterface name: ${iface}\n"
412 [[ -n ${if_product} ]] && text="${text}Device: ${if_product}\n"
413 [[ -n ${if_mac} ]] && text="${text}MAC address: ${if_mac}\n"
414 [[ -n ${if_driver} ]] && text="${text}Driver: ${if_driver}\n"
415 [[ -n ${if_bus} ]] && text="${text}Bus type: ${if_bus}\n"
416 text="${text}\nIs this the interface that you wish to configure?"
417
418 if ! dialog --title "Interface details" --yesno "${text}" 15 70
419 then
420 result="no"
421 else
422 result="yes"
423 fi
424 }
425
426 livecd_console_settings() {
427 # scan for a valid baud rate
428 case "$1" in
429 300*)
430 LIVECD_CONSOLE_BAUD=300
431 ;;
432 600*)
433 LIVECD_CONSOLE_BAUD=600
434 ;;
435 1200*)
436 LIVECD_CONSOLE_BAUD=1200
437 ;;
438 2400*)
439 LIVECD_CONSOLE_BAUD=2400
440 ;;
441 4800*)
442 LIVECD_CONSOLE_BAUD=4800
443 ;;
444 9600*)
445 LIVECD_CONSOLE_BAUD=9600
446 ;;
447 14400*)
448 LIVECD_CONSOLE_BAUD=14400
449 ;;
450 19200*)
451 LIVECD_CONSOLE_BAUD=19200
452 ;;
453 28800*)
454 LIVECD_CONSOLE_BAUD=28800
455 ;;
456 38400*)
457 LIVECD_CONSOLE_BAUD=38400
458 ;;
459 57600*)
460 LIVECD_CONSOLE_BAUD=57600
461 ;;
462 115200*)
463 LIVECD_CONSOLE_BAUD=115200
464 ;;
465 esac
466 if [ "${LIVECD_CONSOLE_BAUD}" = "" ]
467 then
468 # If it's a virtual console, set baud to 38400, if it's a serial
469 # console, set it to 9600 (by default anyhow)
470 case ${LIVECD_CONSOLE} in
471 tty[0-9])
472 LIVECD_CONSOLE_BAUD=38400
473 ;;
474 *)
475 LIVECD_CONSOLE_BAUD=9600
476 ;;
477 esac
478 fi
479 export LIVECD_CONSOLE_BAUD
480
481 # scan for a valid parity
482 # If the second to last byte is a [n,e,o] set parity
483 local parity
484 parity=$(echo $1 | rev | cut -b 2-2)
485 case "$parity" in
486 [neo])
487 LIVECD_CONSOLE_PARITY=$parity
488 ;;
489 esac
490 export LIVECD_CONSOLE_PARITY
491
492 # scan for databits
493 # Only set databits if second to last character is parity
494 if [ "${LIVECD_CONSOLE_PARITY}" != "" ]
495 then
496 LIVECD_CONSOLE_DATABITS=$(echo $1 | rev | cut -b 1)
497 fi
498 export LIVECD_CONSOLE_DATABITS
499 return 0
500 }
501
502 livecd_read_commandline() {
503 livecd_get_cmdline || return 1
504
505 for x in ${CMDLINE}
506 do
507 case "${x}" in
508 cdroot)
509 CDBOOT="yes"
510 RC_NO_UMOUNTS="^(/|/dev|/dev/pts|/lib/rcscripts/init.d|/proc|/proc/.*|/sys|/mnt/livecd|/newroot)$"
511 export CDBOOT RC_NO_UMOUNTS
512 ;;
513 cdroot\=*)
514 CDBOOT="yes"
515 RC_NO_UMOUNTS="^(/|/dev|/dev/pts|/lib/rcscripts/init.d|/proc|/proc/.*|/sys|/mnt/livecd|/newroot)$"
516 export CDBOOT RC_NO_UMOUNTS
517 ;;
518 console\=*)
519 local live_console
520 live_console=$(livecd_parse_opt "${x}")
521
522 # Parse the console line. No options specified if
523 # no comma
524 LIVECD_CONSOLE=$(echo ${live_console} | cut -f1 -d,)
525 if [ "${LIVECD_CONSOLE}" = "" ]
526 then
527 # no options specified
528 LIVECD_CONSOLE=${live_console}
529 else
530 # there are options, we need to parse them
531 local livecd_console_opts
532 livecd_console_opts=$(echo ${live_console} | cut -f2 -d,)
533 livecd_console_settings ${livecd_console_opts}
534 fi
535 export LIVECD_CONSOLE
536 ;;
537 esac
538 done
539 return 0
540 }
541
542 livecd_fix_inittab() {
543 if [ "${CDBOOT}" = "" ]
544 then
545 return 1
546 fi
547
548 # Create a backup
549 cp -f /etc/inittab /etc/inittab.old
550
551 # Comment out current getty settings
552 sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab
553 sed -i -e '/^s[01]/ s/^/#/' /etc/inittab
554
555 # SPARC & HPPA console magic
556 if [ "${HOSTTYPE}" = "sparc" -o "${HOSTTYPE}" = "hppa" -o "${HOSTTYPE}" = "ppc64" ]
557 then
558 # Mount openprom tree for user debugging purposes
559 if [ "${HOSTTYPE}" = "sparc" ]
560 then
561 mount -t openpromfs none /proc/openprom
562 fi
563
564 # SPARC serial port A, HPPA mux / serial
565 if [ -c "/dev/ttyS0" ]
566 then
567 LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyS0 speed)
568 echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyS0 vt100" >> /etc/inittab
569 fi
570 # HPPA software PDC console (K-models)
571 if [ "${LIVECD_CONSOLE}" = "ttyB0" ]
572 then
573 mknod /dev/ttyB0 c 11 0
574 LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyB0 speed)
575 echo "b0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyB0 vt100" >> /etc/inittab
576 fi
577 # FB / STI console
578 if [ -c "/dev/vc/1" -o -c "/dev/tts/1" -o -c "/dev/tty2" ]
579 then
580 MODEL_NAME=$(cat /proc/cpuinfo |grep "model name"|sed 's/.*: //')
581 if [ "${MODEL_NAME}" = "UML" ]
582 then
583 for x in 0 1 2 3 4 5 6
584 do
585 echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab
586 done
587 else
588 for x in 1 2 3 4 5 6
589 do
590 echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab
591 done
592 fi
593 fi
594 if [ -c "/dev/hvc0" ]
595 then
596 einfo "Adding hvc console to inittab"
597 echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 9600 hvc0 vt320" >> /etc/inittab
598 fi
599
600
601 # The rest...
602 else
603 if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ]
604 then
605 for x in 1 2 3 4 5 6
606 do
607 echo "c${x}:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty${x} linux" >> /etc/inittab
608 done
609 else
610 einfo "Adding ${LIVECD_CONSOLE} console to inittab"
611 echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} vt100" >> /etc/inittab
612 fi
613 fi
614
615 # EFI-based machines should automatically hook up their console lines
616 if dmesg | grep -q '^Adding console on'
617 then
618 dmesg | grep '^Adding console on' | while read x; do
619 line=`echo "$x" | cut -d' ' -f4`
620 id=e`echo "$line" | grep -o '.\{1,3\}$'`
621 [ "${line}" = "${LIVECD_CONSOLE}" ] && continue # already setup above
622 case "$x" in
623 *options\ \'[0-9]*) speed=`echo "$x" | sed "s/.*options '//; s/[^0-9].*//"` ;;
624 *) speed=9600 ;; # choose a default, only matters if it is serial
625 esac
626 echo "$id:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${speed} ${line} vt100" >> /etc/inittab
627 done
628 fi
629
630 # force reread of inittab
631 kill -HUP 1
632 return 0
633 }

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20