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

Contents of /trunk/livecd-functions.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 128 - (show annotations) (download) (as text)
Fri Mar 16 16:30:29 2007 UTC (7 years, 1 month ago) by wolf31o2
File MIME type: text/x-sh
File size: 17149 byte(s)
Added some quotes, blame agaffney.
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" ]] && source /sbin/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="$(cat ${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="$(cat ${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="$(cat ${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="$(cat ${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="$(cat ${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="$(cat ${iface}.SSID)"
191 if [ -n "${SSID}" ]
192 then
193 echo "# This wireless configuration file was built by net-setup" > /etc/conf.d/wireless
194 WEP="$(cat ${iface}.WEPTYPE)"
195 case ${WEP} in
196 1)
197 WEP_TYPE="$(cat ${iface}.WEPTYPE)"
198 if [ -n "${WEP_TYPE}" ]
199 then
200 WEP_KEY="$(cat ${iface}.WEPKEY)"
201 if [ -n "${WEP_KEY}" ]
202 then
203 SSID_TRANS="$(echo ${SSID//[![:word:]]/_})"
204 case ${WEP_TYPE} in
205 1)
206 echo "key_${SSID_TRANS}=\"${WEP_KEY} enc open\"" >> /etc/conf.d/wireless
207 ;;
208 2)
209 echo "key_${SSID_TRANS}=\"s:${WEP_KEY} enc open\"" >> /etc/conf.d/wireless
210 ;;
211 esac
212 fi
213 fi
214 ;;
215 2)
216 :
217 ;;
218 esac
219 echo "preferred_aps=( \"${SSID}\" )" >> /etc/conf.d/wireless
220 echo "associate_order=\"forcepreferredonly\"" >> /etc/conf.d/wireless
221 fi
222 }
223
224 livecd_config_ip() {
225 cd /tmp/setup.opts
226 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
227 DHCP="$(cat ${iface}.DHCP)"
228 case ${DHCP} in
229 1)
230 /sbin/dhcpcd -n -t 10 -h $(hostname) ${iface} &
231 ;;
232 2)
233 dialog --title "IP address" --inputbox "Please enter an IP address for ${iface}:" 20 50 "192.168.1.1" 2> ${iface}.IP
234 IP="$(cat ${iface}.IP)"
235 BC_TEMP="$(echo $IP|cut -d . -f 1).$(echo $IP|cut -d . -f 2).$(echo $IP|cut -d . -f 3).255"
236 dialog --title "Broadcast address" --inputbox "Please enter a Broadcast address for ${iface}:" 20 50 "${BC_TEMP}" 2> ${iface}.BC
237 BROADCAST="$(cat ${iface}.BC)"
238 dialog --title "Network mask" --inputbox "Please enter a Network Mask for ${iface}:" 20 50 "255.255.255.0" 2> ${iface}.NM
239 NETMASK="$(cat ${iface}.NM)"
240 dialog --title "Gateway" --inputbox "Please enter a Gateway for ${iface} (hit enter for none:)" 20 50 2> ${iface}.GW
241 GATEWAY="$(cat ${iface}.GW)"
242 dialog --title "DNS server" --inputbox "Please enter a name server to use (hit enter for none:)" 20 50 2> ${iface}.DNS
243 DNS="$(cat ${iface}.DNS)"
244 /sbin/ifconfig ${iface} ${IP} broadcast ${BROADCAST} netmask ${NETMASK}
245 if [ -n "${GATEWAY}" ]
246 then
247 /sbin/route add default gw ${GATEWAY} dev ${iface} netmask 0.0.0.0 metric 1
248 fi
249 if [ -n "${DNS}" ]
250 then
251 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
252 SUFFIX="$(cat ${iface}.SUFFIX)"
253 echo "nameserver ${DNS}" > /etc/resolv.conf
254 if [ -n "${SUFFIX}" ]
255 then
256 echo "search ${SUFFIX}" >> /etc/resolv.conf
257 fi
258 fi
259 ;;
260 esac
261 }
262
263 livecd_write_net_conf() {
264 cd /tmp/setup.opts
265 echo "# This network configuration was written by net-setup" > /etc/conf.d/net
266 DHCP="$(cat ${iface}.DHCP)"
267 case ${DHCP} in
268 1)
269 echo "iface_${iface}=\"dhcp\"" >> /etc/conf.d/net
270 ;;
271 2)
272 IP="$(cat ${iface}.IP)"
273 BROADCAST="$(cat ${iface}.BC)"
274 NETMASK="$(cat ${iface}.NM)"
275 GATEWAY="$(cat ${iface}.GW)"
276 if [ -n "${IP}" -a -n "${BROADCAST}" -a -n "${NETMASK}" ]
277 then
278 echo "iface_eth0=\"${IP} broadcast ${BROADCAST} netmask ${NETMASK}\"" >> /etc/conf.d/net
279 if [ -n "${GATEWAY}" ]
280 then
281 echo "gateway=\"${iface}/${GATEWAY}\"" >> /etc/conf.d/net
282 fi
283 fi
284 ;;
285 esac
286 }
287
288 get_ifmac() {
289 local iface=$1
290
291 # Example: 00:01:6f:e1:7a:06
292 cat /sys/class/net/${iface}/address
293 }
294
295
296 get_ifdriver() {
297 local iface=$1
298
299 # Example: ../../../bus/pci/drivers/forcedeth (wanted: forcedeth)
300 local if_driver="$(readlink /sys/class/net/${iface}/device/driver)"
301 basename ${if_driver}
302 }
303
304 get_ifbus() {
305 local iface=$1
306
307 # Example: ../../../bus/pci (wanted: pci)
308 # Example: ../../../../bus/pci (wanted: pci)
309 # Example: ../../../../../../bus/usb (wanted: usb)
310 local if_bus="$(readlink /sys/class/net/${iface}/device/bus)"
311 basename ${if_bus}
312 }
313
314 get_ifproduct() {
315 local iface=$1
316 local bus="$(get_ifbus ${iface})"
317 local if_pciaddr
318 local if_devname
319 local if_usbpath
320 local if_usbmanufacturer
321 local if_usbproduct
322
323 if [[ ${bus} == "pci" ]]; then
324 # Example: ../../../devices/pci0000:00/0000:00:0a.0 (wanted: 0000:00:0a.0)
325 # Example: ../../../devices/pci0000:00/0000:00:09.0/0000:01:07.0 (wanted: 0000:01:07.0)
326 if_pciaddr="$(readlink /sys/class/net/${iface}/device)"
327 if_pciaddr="$(basename ${if_pciaddr})"
328
329 # Example: 00:0a.0 Bridge: nVidia Corporation CK804 Ethernet Controller (rev a3)
330 # (wanted: nVidia Corporation CK804 Ethernet Controller)
331 if_devname="$(lspci -s ${if_pciaddr})"
332 if_devname="${if_devname#*: }"
333 if_devname="${if_devname%(rev *)}"
334 fi
335
336 if [[ ${bus} == "usb" ]]; then
337 if_usbpath="$(readlink /sys/class/net/${iface}/device)"
338 if_usbpath="/sys/class/net/${iface}/$(dirname ${if_usbpath})"
339 if_usbmanufacturer="$(< ${if_usbpath}/manufacturer)"
340 if_usbproduct="$(< ${if_usbpath}/product)"
341
342 [[ -n ${if_usbmanufacturer} ]] && if_devname="${if_usbmanufacturer} "
343 [[ -n ${if_usbproduct} ]] && if_devname="${if_devname}${if_usbproduct}"
344 fi
345
346 if [[ ${bus} == "ieee1394" ]]; then
347 if_devname="IEEE1394 (FireWire) Network Adapter";
348 fi
349
350 echo ${if_devname}
351 }
352
353 get_ifdesc() {
354 local iface=$1
355 desc="$(get_ifproduct ${iface})"
356 if [[ -n ${desc} ]]; then
357 echo $desc
358 return;
359 fi
360
361 desc="$(get_ifdriver ${iface})"
362 if [[ -n ${desc} ]]; then
363 echo $desc
364 return;
365 fi
366
367 desc="$(get_ifmac ${iface})"
368 if [[ -n ${desc} ]]; then
369 echo $desc
370 return;
371 fi
372
373 echo "Unknown"
374 }
375
376 show_ifmenu() {
377 local old_ifs="${IFS}"
378 local opts
379 IFS="
380 "
381 for ifname in $(/sbin/ifconfig -a | grep "^[^ ]"); do
382 ifname="${ifname%% *}"
383 [[ ${ifname} == "lo" ]] && continue
384 opts="${opts} ${ifname} '$(get_ifdesc ${ifname})'"
385 done
386 IFS="${old_ifs}"
387
388 if ! eval dialog --menu \"Please select the interface that you wish to configure from the list below:\" 0 0 0 $opts 2>iface; then
389 exit
390 fi
391
392 iface="$(< iface)"
393 }
394
395 show_ifconfirm() {
396 local iface=$1
397 local if_mac="$(get_ifmac ${iface})"
398 local if_driver="$(get_ifdriver ${iface})"
399 local if_bus="$(get_ifbus ${iface})"
400 local if_product="$(get_ifproduct ${iface})"
401
402 local text="Details for network interface ${iface} are shown below.\n\nInterface name: ${iface}\n"
403 [[ -n ${if_product} ]] && text="${text}Device: ${if_product}\n"
404 [[ -n ${if_mac} ]] && text="${text}MAC address: ${if_mac}\n"
405 [[ -n ${if_driver} ]] && text="${text}Driver: ${if_driver}\n"
406 [[ -n ${if_bus} ]] && text="${text}Bus type: ${if_bus}\n"
407 text="${text}\nIs this the interface that you wish to configure?"
408
409 if ! dialog --title "Interface details" --yesno "${text}" 15 70; then
410 result="no"
411 else
412 result="yes"
413 fi
414 }
415
416 livecd_console_settings() {
417 # scan for a valid baud rate
418 case "$1" in
419 300*)
420 LIVECD_CONSOLE_BAUD=300
421 ;;
422 600*)
423 LIVECD_CONSOLE_BAUD=600
424 ;;
425 1200*)
426 LIVECD_CONSOLE_BAUD=1200
427 ;;
428 2400*)
429 LIVECD_CONSOLE_BAUD=2400
430 ;;
431 4800*)
432 LIVECD_CONSOLE_BAUD=4800
433 ;;
434 9600*)
435 LIVECD_CONSOLE_BAUD=9600
436 ;;
437 14400*)
438 LIVECD_CONSOLE_BAUD=14400
439 ;;
440 19200*)
441 LIVECD_CONSOLE_BAUD=19200
442 ;;
443 28800*)
444 LIVECD_CONSOLE_BAUD=28800
445 ;;
446 38400*)
447 LIVECD_CONSOLE_BAUD=38400
448 ;;
449 57600*)
450 LIVECD_CONSOLE_BAUD=57600
451 ;;
452 115200*)
453 LIVECD_CONSOLE_BAUD=115200
454 ;;
455 esac
456 if [ "${LIVECD_CONSOLE_BAUD}" = "" ]
457 then
458 # If it's a virtual console, set baud to 38400, if it's a serial
459 # console, set it to 9600 (by default anyhow)
460 case ${LIVECD_CONSOLE} in
461 tty[0-9])
462 LIVECD_CONSOLE_BAUD=38400
463 ;;
464 *)
465 LIVECD_CONSOLE_BAUD=9600
466 ;;
467 esac
468 fi
469 export LIVECD_CONSOLE_BAUD
470
471 # scan for a valid parity
472 # If the second to last byte is a [n,e,o] set parity
473 local parity
474 parity=$(echo $1 | rev | cut -b 2-2)
475 case "$parity" in
476 [neo])
477 LIVECD_CONSOLE_PARITY=$parity
478 ;;
479 esac
480 export LIVECD_CONSOLE_PARITY
481
482 # scan for databits
483 # Only set databits if second to last character is parity
484 if [ "${LIVECD_CONSOLE_PARITY}" != "" ]
485 then
486 LIVECD_CONSOLE_DATABITS=$(echo $1 | rev | cut -b 1)
487 fi
488 export LIVECD_CONSOLE_DATABITS
489 return 0
490 }
491
492 livecd_read_commandline() {
493 livecd_get_cmdline || return 1
494
495 for x in ${CMDLINE}
496 do
497 case "${x}" in
498 cdroot)
499 CDBOOT="yes"
500 RC_NO_UMOUNTS="^(/|/dev|/dev/pts|/lib/rcscripts/init.d|/proc|/proc/.*|/sys|/mnt/livecd|/newroot)$"
501 export CDBOOT RC_NO_UMOUNTS
502 ;;
503 cdroot\=*)
504 CDBOOT="yes"
505 RC_NO_UMOUNTS="^(/|/dev|/dev/pts|/lib/rcscripts/init.d|/proc|/proc/.*|/sys|/mnt/livecd|/newroot)$"
506 export CDBOOT RC_NO_UMOUNTS
507 ;;
508 console\=*)
509 local live_console
510 live_console=$(livecd_parse_opt "${x}")
511
512 # Parse the console line. No options specified if
513 # no comma
514 LIVECD_CONSOLE=$(echo ${live_console} | cut -f1 -d,)
515 if [ "${LIVECD_CONSOLE}" = "" ]
516 then
517 # no options specified
518 LIVECD_CONSOLE=${live_console}
519 else
520 # there are options, we need to parse them
521 local livecd_console_opts
522 livecd_console_opts=$(echo ${live_console} | cut -f2 -d,)
523 livecd_console_settings ${livecd_console_opts}
524 fi
525 export LIVECD_CONSOLE
526 ;;
527 esac
528 done
529 return 0
530 }
531
532 livecd_fix_inittab() {
533 if [ "${CDBOOT}" = "" ]
534 then
535 return 1
536 fi
537
538 # Create a backup
539 cp -f /etc/inittab /etc/inittab.old
540
541 # Comment out current getty settings
542 sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab
543 sed -i -e '/^s[01]/ s/^/#/' /etc/inittab
544
545 # SPARC & HPPA console magic
546 if [ "${HOSTTYPE}" = "sparc" -o "${HOSTTYPE}" = "hppa" -o "${HOSTTYPE}" = "ppc64" ]
547 then
548 # Mount openprom tree for user debugging purposes
549 if [ "${HOSTTYPE}" = "sparc" ]
550 then
551 mount -t openpromfs none /proc/openprom
552 fi
553
554 # SPARC serial port A, HPPA mux / serial
555 if [ -c "/dev/ttyS0" ]
556 then
557 LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyS0 speed)
558 echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyS0 vt100" >> /etc/inittab
559 fi
560 # HPPA software PDC console (K-models)
561 if [ "${LIVECD_CONSOLE}" = "ttyB0" ]
562 then
563 mknod /dev/ttyB0 c 11 0
564 LIVECD_CONSOLE_BAUD=$(stty -F /dev/ttyB0 speed)
565 echo "b0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyB0 vt100" >> /etc/inittab
566 fi
567 # FB / STI console
568 if [ -c "/dev/vc/1" -o -c "/dev/tts/1" -o -c "/dev/tty2" ]
569 then
570 MODEL_NAME=$(cat /proc/cpuinfo |grep "model name"|sed 's/.*: //')
571 if [ "${MODEL_NAME}" = "UML" ]
572 then
573 for x in 0 1 2 3 4 5 6
574 do
575 echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab
576 done
577 else
578 for x in 1 2 3 4 5 6
579 do
580 echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab
581 done
582 fi
583 fi
584 if [ -c "/dev/hvc0" ]
585 then
586 einfo "Adding hvc console to inittab"
587 echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 9600 hvc0 vt320" >> /etc/inittab
588 fi
589
590
591 # The rest...
592 else
593 if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ]
594 then
595 for x in 1 2 3 4 5 6
596 do
597 echo "c${x}:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty${x} linux" >> /etc/inittab
598 done
599 else
600 einfo "Adding ${LIVECD_CONSOLE} console to inittab"
601 echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} vt100" >> /etc/inittab
602 fi
603 fi
604
605 # EFI-based machines should automatically hook up their console lines
606 if dmesg | grep -q '^Adding console on'
607 then
608 dmesg | grep '^Adding console on' | while read x; do
609 line=`echo "$x" | cut -d' ' -f4`
610 id=e`echo "$line" | grep -o '.\{1,3\}$'`
611 [ "${line}" = "${LIVECD_CONSOLE}" ] && continue # already setup above
612 case "$x" in
613 *options\ \'[0-9]*) speed=`echo "$x" | sed "s/.*options '//; s/[^0-9].*//"` ;;
614 *) speed=9600 ;; # choose a default, only matters if it is serial
615 esac
616 echo "$id:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${speed} ${line} vt100" >> /etc/inittab
617 done
618 fi
619
620 # force reread of inittab
621 kill -HUP 1
622 return 0
623 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20