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

Contents of /trunk/livecd-functions.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (show annotations) (download) (as text)
Tue Apr 12 21:25:21 2005 UTC (9 years, 5 months ago) by wolf31o2
File MIME type: text/x-sh
File size: 4917 byte(s)
Added bashlogin and livecd-functions.sh from baselayout.  Cleaned up ALSA support in autoconfig.  Made x-setup use new opengl-update feature --dst-prefix.  Fixed WEP key section in net-setup.

1 #!/bin/bash
2 # Copyright 1999-2004 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo/src/livecd-tools/livecd-functions.sh,v 1.1 2005/04/12 21:25:21 wolf31o2 Exp $
5
6 # Global Variables:
7 # CDBOOT -- is booting off CD
8 # LIVECD_CONSOLE -- console that is specified to kernel commandline
9 # -- (ttyS0, tty1, etc). Only defined if passed to kernel
10 # LIVECD_CONSOLE_BAUD -- console baudrate specified
11 # LIVECD_CONSOLE_PARITY -- console parity specified
12 # LIVECD_CONSOLE_DATABITS -- console databits specified
13
14 livecd_parse_opt() {
15 case "$1" in
16 *\=*)
17 echo "$1" | cut -f2 -d=;;
18 esac
19 }
20
21 livecd_console_settings() {
22 # scan for a valid baud rate
23 case "$1" in
24 300*)
25 LIVECD_CONSOLE_BAUD=300
26 ;;
27 600*)
28 LIVECD_CONSOLE_BAUD=600
29 ;;
30 1200*)
31 LIVECD_CONSOLE_BAUD=1200
32 ;;
33 2400*)
34 LIVECD_CONSOLE_BAUD=2400
35 ;;
36 4800*)
37 LIVECD_CONSOLE_BAUD=4800
38 ;;
39 9600*)
40 LIVECD_CONSOLE_BAUD=9600
41 ;;
42 14400*)
43 LIVECD_CONSOLE_BAUD=14400
44 ;;
45 19200*)
46 LIVECD_CONSOLE_BAUD=19200
47 ;;
48 28800*)
49 LIVECD_CONSOLE_BAUD=28800
50 ;;
51 38400*)
52 LIVECD_CONSOLE_BAUD=38400
53 ;;
54 57600*)
55 LIVECD_CONSOLE_BAUD=57600
56 ;;
57 115200*)
58 LIVECD_CONSOLE_BAUD=115200
59 ;;
60 esac
61 if [ "${LIVECD_CONSOLE_BAUD}" = "" ]
62 then
63 # If it's a virtual console, set baud to 38400, if it's a serial
64 # console, set it to 9600 (by default anyhow)
65 case ${LIVECD_CONSOLE} in
66 tty[0-9])
67 LIVECD_CONSOLE_BAUD=38400
68 ;;
69 *)
70 LIVECD_CONSOLE_BAUD=9600
71 ;;
72 esac
73 fi
74 export LIVECD_CONSOLE_BAUD
75
76 # scan for a valid parity
77 # If the second to last byte is a [n,e,o] set parity
78 local parity
79 parity=`echo $1 | rev | cut -b 2-2`
80 case "$parity" in
81 [neo])
82 LIVECD_CONSOLE_PARITY=$parity
83 ;;
84 esac
85 export LIVECD_CONSOLE_PARITY
86
87 # scan for databits
88 # Only set databits if second to last character is parity
89 if [ "${LIVECD_CONSOLE_PARITY}" != "" ]
90 then
91 LIVECD_CONSOLE_DATABITS=`echo $1 | rev | cut -b 1`
92 fi
93 export LIVECD_CONSOLE_DATABITS
94 return 0
95 }
96
97
98 livecd_read_commandline() {
99 local CMDLINE
100
101 # Line to be used for testing only. The formatting of the console=
102 # prompt can be found in /usr/src/linux/Documentation/serial-console.txt
103 # possible cmdline could look like this: CMDLINE="cdroot console=ttyS0,9600n8"
104
105 CMDLINE=`cat /proc/cmdline`
106
107 for x in ${CMDLINE}
108 do
109 case "${x}" in
110 cdroot)
111 CDBOOT="yes"
112 export CDBOOT
113 ;;
114 cdroot\=*)
115 CDBOOT="yes"
116 export CDBOOT
117 ;;
118 console\=*)
119 local live_console
120 live_console=`livecd_parse_opt "${x}"`
121
122 # Parse the console line. No options specified if
123 # no comma
124 LIVECD_CONSOLE=`echo ${live_console} | cut -f1 -d,`
125 if [ "${LIVECD_CONSOLE}" = "" ]
126 then
127 # no options specified
128 LIVECD_CONSOLE=${live_console}
129 else
130 # there are options, we need to parse them
131 local livecd_console_opts
132 livecd_console_opts=`echo ${live_console} | cut -f2 -d,`
133 livecd_console_settings ${livecd_console_opts}
134 fi
135 export LIVECD_CONSOLE
136 ;;
137 esac
138 done
139 return 0
140 }
141
142
143 livecd_fix_inittab() {
144 if [ "${CDBOOT}" = "" ]
145 then
146 return 1
147 fi
148
149 # Comment out current getty settings
150 sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab
151
152 # SPARC & HPPA console magic
153 if [ "${HOSTTYPE}" = "sparc" -o "${HOSTTYPE}" = "hppa" -o "${HOSTTYPE}" = "ppc64" ]
154 then
155 # Mount openprom tree for user debugging purposes
156 if [ "${HOSTTYPE}" = "sparc" ]
157 then
158 mount -t openpromfs none /proc/openprom
159 fi
160
161 # SPARC serial port A, HPPA mux / serial
162 if [ -c "/dev/tts/0" ]
163 then
164 LIVECD_CONSOLE_BAUD=`stty -F /dev/tts/0 speed`
165 echo "s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} tts/0 vt100" >> /etc/inittab
166 fi
167 # HPPA software PDC console (K-models)
168 if [ "${LIVECD_CONSOLE}" = "ttyB0" ]
169 then
170 mknod /dev/ttyB0 c 11 0
171 LIVECD_CONSOLE_BAUD=`stty -F /dev/ttyB0 speed`
172 echo "b0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ttyB0 vt100" >> /etc/inittab
173 fi
174 # FB / STI console
175 if [ -c "/dev/vc/1" ]
176 then
177 for x in 1 2 3 4 5 6
178 do
179 echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab
180 done
181 fi
182 if [ -c "/dev/hvc/0" ]
183 then
184 ln -s /dev/hvc/0 /dev/hvc0
185 echo "c0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 9600 hvc0 vt320" >> /etc/inittab
186 fi
187 # The rest...
188 else
189 if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ]
190 then
191 for x in 1 2 3 4 5 6
192 do
193 echo "c${x}:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty${x} linux" >> /etc/inittab
194 done
195 else
196 if [ -c "/dev/hvc/0" ]
197 then
198 ln -s /dev/hvc/0 /dev/hvc0
199 echo "c0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 9600 hvc0 vt320" >> /etc/inittab
200 else
201 echo "c0:12345:respawn:/sbin/agetty -nl /bin/bashlogin ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} vt100" >> /etc/inittab
202 fi
203 fi
204 fi
205 return 0
206 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20