Annotation of /alx-src/branches/alxconf_20060908/init.d/alxsettings
Parent Directory | Revision Log
Revision 368 -
(hide annotations)
(download)
Tue Oct 11 12:10:15 2005 UTC (18 years, 11 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/init.d/alxsettings
File size: 22869 byte(s)
Tue Oct 11 12:10:15 2005 UTC (18 years, 11 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/init.d/alxsettings
File size: 22869 byte(s)
create now missing xinitrc
1 | niro | 221 | #!/bin/bash |
2 | |||
3 | # <niro@magellan-linux.de> | ||
4 | |||
5 | #%rlevels: 7:s 0:k 6:k | ||
6 | #%start: 41 | ||
7 | #%stop: 01 | ||
8 | |||
9 | #deps | ||
10 | #%needs: | ||
11 | #%before: | ||
12 | #%after: | ||
13 | |||
14 | niro | 368 | # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.27 2005-10-11 12:10:15 niro Exp $ |
15 | niro | 227 | |
16 | niro | 221 | # checks first if the client was already configured and if it has an valid serial |
17 | # if not it runs the autoconfiguration script | ||
18 | # these settings will be used for client setup | ||
19 | # | ||
20 | # if client was valid it first will check if his settings against the server | ||
21 | # if no changes are at server side they will be kept, if yes the get updated. | ||
22 | # the server settings has higher priority. | ||
23 | |||
24 | source /etc/sysconfig/rc | ||
25 | source $rc_functions | ||
26 | |||
27 | niro | 282 | # mysql settings |
28 | niro | 226 | source /etc/alxconfig-ng/config.rc |
29 | niro | 282 | |
30 | # helper functions | ||
31 | niro | 226 | source /usr/lib/alxconfig-ng/functions/mysqlfunctions |
32 | niro | 227 | source /usr/lib/alxconfig-ng/functions/serial_functions |
33 | niro | 257 | source /usr/lib/alxconfig-ng/functions/config_modules |
34 | niro | 226 | source /usr/lib/alxconfig-ng/functions/config_network |
35 | source /usr/lib/alxconfig-ng/functions/config_printers | ||
36 | niro | 239 | source /usr/lib/alxconfig-ng/functions/config_sessions |
37 | niro | 226 | source /usr/lib/alxconfig-ng/functions/config_x11 |
38 | niro | 248 | source /usr/lib/alxconfig-ng/functions/config_auth |
39 | niro | 252 | source /usr/lib/alxconfig-ng/functions/config_ssh_auth |
40 | niro | 221 | |
41 | niro | 282 | # check if mysql is available |
42 | niro | 221 | [ -x /usr/bin/mysql ] && MYSQL_ALX=true |
43 | |||
44 | niro | 282 | # other needed vars |
45 | niro | 221 | ALX_HW_DETECT=false |
46 | niro | 282 | ALX_FORCED_RECHECK=false |
47 | niro | 337 | ALX_RESET_SETTINGS=false |
48 | ALX_CONFD_NETWORKING=false | ||
49 | niro | 221 | |
50 | niro | 282 | # unset vars which may kill us |
51 | niro | 221 | unset ALX_SERIAL ALX_STATE |
52 | |||
53 | |||
54 | niro | 282 | # setup needed directories |
55 | niro | 226 | [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
56 | niro | 221 | |
57 | |||
58 | niro | 337 | # read_cmdline ${item} |
59 | read_cmdline() | ||
60 | { | ||
61 | local i | ||
62 | |||
63 | for i in $(< /proc/cmdline) | ||
64 | do | ||
65 | [[ ${i} = $1 ]] && return 0 | ||
66 | done | ||
67 | |||
68 | return 1 | ||
69 | } | ||
70 | |||
71 | update_system_settings() | ||
72 | { | ||
73 | niro | 226 | echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
74 | niro | 221 | |
75 | niro | 257 | # get the modules settings |
76 | # ! is the first thing that must be configured ! | ||
77 | config_modules | ||
78 | |||
79 | niro | 226 | # imports network settings from db |
80 | config_networking | ||
81 | |||
82 | # imports x11 settings from db | ||
83 | config_x11 | ||
84 | |||
85 | niro | 248 | # imports session settings from db |
86 | niro | 239 | config_sessions |
87 | niro | 226 | |
88 | # imports printer settings from db | ||
89 | config_printing | ||
90 | niro | 248 | |
91 | # imports auth settings from db | ||
92 | config_auth | ||
93 | niro | 252 | |
94 | # exchange ssh rsa keys | ||
95 | niro | 265 | HOME=/root config_ssh_auth |
96 | niro | 221 | } |
97 | |||
98 | niro | 337 | get_system_serial() |
99 | { | ||
100 | niro | 350 | local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE |
101 | niro | 221 | |
102 | niro | 350 | if [[ ${ALX_CONFD_NETWORKING} = true ]] |
103 | then | ||
104 | ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)" | ||
105 | else | ||
106 | ALX_IFACE="eth0" | ||
107 | fi | ||
108 | |||
109 | niro | 282 | # check if serial file exists |
110 | niro | 337 | if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]] |
111 | niro | 221 | then |
112 | niro | 226 | source /etc/alxconfig-ng/serial |
113 | |||
114 | niro | 282 | # start preliminary networking (dhcp) |
115 | niro | 295 | preliminary_network start |
116 | niro | 226 | |
117 | niro | 295 | # check if mysql server is reachable |
118 | # if not abort this script | ||
119 | if ! reach_mysql_server | ||
120 | then | ||
121 | preliminary_network stop | ||
122 | exit 1 | ||
123 | fi | ||
124 | |||
125 | niro | 348 | CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') |
126 | CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) | ||
127 | niro | 221 | CUR_MTIME=$(date +%s) |
128 | niro | 226 | |
129 | niro | 221 | echo -e ${COLOREDSTAR} "Trying to validate my serial ..." |
130 | niro | 226 | |
131 | niro | 282 | # nice serial output |
132 | niro | 221 | $CURS_UP |
133 | $SET_WCOL | ||
134 | echo "[ SN: ${ALX_SERIAL} ]" | ||
135 | |||
136 | if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}" | ||
137 | then | ||
138 | ALX_STATE="ok" | ||
139 | else | ||
140 | niro | 307 | # abort on non valid serial |
141 | niro | 221 | ALX_STATE="invalid serial" |
142 | niro | 307 | echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
143 | show_invalid_serial_msg | ||
144 | exit 1 | ||
145 | niro | 221 | fi |
146 | |||
147 | else | ||
148 | niro | 282 | # run hardware detection |
149 | niro | 221 | echo |
150 | niro | 337 | if [[ ${ALX_FORCED_RECHECK} = true ]] |
151 | niro | 282 | then |
152 | niro | 295 | echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} |
153 | niro | 282 | else |
154 | echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} | ||
155 | fi | ||
156 | niro | 221 | ALX_HW_DETECT=true |
157 | /etc/init.d/hwdetect start | ||
158 | niro | 226 | |
159 | niro | 282 | # set hostname to alx_default_hostname |
160 | # use old hostname if this is a forced re-check | ||
161 | niro | 337 | [[ ${ALX_FORCED_RECHECK} = true ]] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)" |
162 | niro | 221 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
163 | HOSTNAME="${ALX_DEFAULT_HOSTNAME}" | ||
164 | niro | 226 | |
165 | niro | 282 | # update the hostname on the system for sure |
166 | niro | 230 | echo "${HOSTNAME}" > /etc/hostname |
167 | niro | 226 | |
168 | niro | 282 | # start preliminary networking (dhcp) |
169 | niro | 221 | preliminary_network start |
170 | niro | 226 | |
171 | niro | 295 | # check if mysql server is reachable |
172 | # if not abort this script | ||
173 | if ! reach_mysql_server | ||
174 | then | ||
175 | preliminary_network stop | ||
176 | exit 1 | ||
177 | fi | ||
178 | |||
179 | niro | 221 | CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
180 | CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) | ||
181 | CUR_MTIME=$(date +%s) | ||
182 | niro | 226 | |
183 | niro | 282 | # abort now if this is a forced re-check |
184 | niro | 337 | if [[ ${ALX_FORCED_RECHECK} = true ]] |
185 | niro | 282 | then |
186 | # but first check the serial | ||
187 | source /etc/alxconfig-ng/serial | ||
188 | |||
189 | echo -e ${COLOREDSTAR} "Trying to validate my serial ..." | ||
190 | |||
191 | # nice serial output | ||
192 | $CURS_UP | ||
193 | $SET_WCOL | ||
194 | echo "[ SN: ${ALX_SERIAL} ]" | ||
195 | |||
196 | if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}" | ||
197 | then | ||
198 | ALX_STATE="ok" | ||
199 | else | ||
200 | niro | 307 | # abort on non valid serial |
201 | niro | 282 | ALX_STATE="invalid serial" |
202 | niro | 307 | echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
203 | show_invalid_serial_msg | ||
204 | exit 1 | ||
205 | niro | 282 | fi |
206 | |||
207 | # write current state to temp file | ||
208 | echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state | ||
209 | niro | 337 | [ -f /hardware-auto-detection ] && rm /hardware-auto-detection |
210 | niro | 282 | |
211 | # now export ALX_FORCED_RECHECK=true | ||
212 | # that the setting will be updated not inserted ! | ||
213 | export ALX_FORCED_RECHECK=true | ||
214 | return 0 | ||
215 | fi | ||
216 | |||
217 | niro | 221 | echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
218 | niro | 226 | |
219 | niro | 313 | # request a new serial; one command now (cause must be done in the same session) |
220 | niro | 348 | ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); |
221 | niro | 314 | select last_insert_id();") |
222 | niro | 221 | |
223 | niro | 337 | if [[ ${ALX_SERIAL} != NULL ]] |
224 | niro | 221 | then |
225 | niro | 282 | # nice serial output |
226 | niro | 221 | $CURS_UP |
227 | $SET_WCOL | ||
228 | echo "[ SN: ${ALX_SERIAL} ]" | ||
229 | niro | 226 | |
230 | niro | 348 | # set ALX_STATE to ok so everybody knows that everything was ok |
231 | niro | 221 | ALX_STATE=ok |
232 | niro | 226 | |
233 | echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial | ||
234 | echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial | ||
235 | |||
236 | niro | 221 | evaluate_retval |
237 | else | ||
238 | niro | 282 | # print false (works only if this is the first statement here) |
239 | niro | 221 | evaluate_retval |
240 | niro | 226 | |
241 | niro | 282 | # set ALX_STATE to error so everybody sees there was an error |
242 | niro | 221 | ALX_STATE=error |
243 | niro | 226 | |
244 | niro | 282 | # show an error that no new serial was found |
245 | # nice serial output | ||
246 | niro | 221 | $CURS_UP |
247 | $SET_WCOL | ||
248 | echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]" | ||
249 | fi | ||
250 | fi | ||
251 | niro | 226 | |
252 | niro | 282 | # write current state to temp file |
253 | niro | 226 | echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
254 | niro | 348 | echo "ALX_IFACE=${ALX_IFACE}" >> /etc/alxconfig-ng/state/state |
255 | niro | 221 | } |
256 | |||
257 | |||
258 | niro | 337 | check_is_configured() |
259 | { | ||
260 | niro | 226 | if [ -f /etc/alxconfig-ng/state/configured ] |
261 | niro | 221 | then |
262 | export ALX_CONFIGURED=true | ||
263 | else | ||
264 | export ALX_CONFIGURED=false | ||
265 | fi | ||
266 | } | ||
267 | |||
268 | |||
269 | # imports current settings to the database resolved by the hardware detection | ||
270 | niro | 337 | import_settings_to_db() |
271 | { | ||
272 | niro | 282 | # note: networking is always 'dhcp' if hw was autodetected |
273 | # note: default_domain/hostname is set in config.rc | ||
274 | niro | 229 | |
275 | niro | 282 | # to be safe, we do some sanity checks |
276 | niro | 221 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
277 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
278 | niro | 229 | |
279 | niro | 282 | # vars used by hwdetect |
280 | niro | 221 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
281 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER | ||
282 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE | ||
283 | niro | 229 | |
284 | niro | 282 | # get setting from hwdetect |
285 | niro | 221 | source /etc/sysconfig/hwsetup/knoppix |
286 | source /etc/sysconfig/hwsetup/mouse | ||
287 | niro | 229 | |
288 | niro | 221 | echo |
289 | echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} | ||
290 | niro | 229 | |
291 | niro | 282 | # network |
292 | niro | 221 | echo -e " Network settings ..." |
293 | niro | 337 | if [[ ${ALX_CONFD_NETWORKING} = true ]] |
294 | then | ||
295 | # get settings | ||
296 | #source ${rc_base}/init.d/network &> /dev/null | ||
297 | for iface in $(onboot_interface_list ${network_settings}/net.*) | ||
298 | do | ||
299 | [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue | ||
300 | echo "WARNING: only importing settings for interface [ ${iface} ] !" | ||
301 | source ${network_settings}/net.${iface} || exit 1 | ||
302 | NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" | ||
303 | |||
304 | niro | 348 | mysqldo "insert into cfg_network( |
305 | niro | 337 | hostname, |
306 | serial, | ||
307 | module, | ||
308 | domain, | ||
309 | networking, | ||
310 | netmask, | ||
311 | dns, | ||
312 | gateway, | ||
313 | broadcast, | ||
314 | ip, | ||
315 | forcemacto, | ||
316 | wireless_bitrate, | ||
317 | wireless_channel, | ||
318 | wireless_essid, | ||
319 | wireless_frequency, | ||
320 | wireless_mode, | ||
321 | wireless_nick, | ||
322 | wireless_auth_mode, | ||
323 | wireless_key_length, | ||
324 | wireless_key, | ||
325 | wireless_key_ascii | ||
326 | ) | ||
327 | values( | ||
328 | '${ALX_DEFAULT_HOSTNAME}', | ||
329 | '${ALX_SERIAL}', | ||
330 | '${NETCARD_DRIVER}', | ||
331 | '${ALX_DEFAULT_DOMAIN}', | ||
332 | '${NETWORKING}', | ||
333 | '${NETMASK}', | ||
334 | '${NAMESERVER}', | ||
335 | '${GATEWAY}', | ||
336 | '${BROADCAST}', | ||
337 | '${IP}', | ||
338 | '${FORCE_MAC_TO}', | ||
339 | '${WIRELESS_BITRATE}', | ||
340 | '${WIRELESS_CHANNEL}', | ||
341 | '${WIRELESS_ESSID}', | ||
342 | '${WIRELESS_FREQUENCY}', | ||
343 | '${WIRELESS_MODE}', | ||
344 | '${WIRELESS_NICK}', | ||
345 | '${WIRELESS_AUTH_MODE}', | ||
346 | '${WIRELESS_KEY_LENGTH}', | ||
347 | '${WIRELESS_KEY}', | ||
348 | '${WIRELESS_KEY_ASCII}' | ||
349 | );" | ||
350 | |||
351 | # only insert the *FIRST* iface | ||
352 | break | ||
353 | done | ||
354 | else | ||
355 | niro | 348 | mysqldo "insert into cfg_network( |
356 | niro | 337 | hostname, |
357 | serial, | ||
358 | module, | ||
359 | domain, | ||
360 | networking | ||
361 | ) | ||
362 | values( | ||
363 | '${ALX_DEFAULT_HOSTNAME}', | ||
364 | '${ALX_SERIAL}', | ||
365 | '${NETCARD_DRIVER}', | ||
366 | '${ALX_DEFAULT_DOMAIN}', | ||
367 | 'dhcp' | ||
368 | );" | ||
369 | fi | ||
370 | niro | 221 | evaluate_retval |
371 | niro | 229 | |
372 | niro | 282 | # xserver |
373 | niro | 221 | echo -e " Graphic settings ..." |
374 | niro | 282 | # xserver general |
375 | niro | 348 | ( mysqldo "insert into cfg_graphic( |
376 | niro | 221 | serial, |
377 | module, | ||
378 | resolution, | ||
379 | niro | 229 | depth, |
380 | monitorid | ||
381 | niro | 221 | ) |
382 | values( | ||
383 | '${ALX_SERIAL}', | ||
384 | '${XMODULE}', | ||
385 | '1024x768', | ||
386 | niro | 229 | '16', |
387 | '0' | ||
388 | niro | 252 | );"; ) |
389 | evaluate_retval | ||
390 | niro | 229 | |
391 | niro | 221 | # input |
392 | niro | 252 | echo -e " Input settings ..." |
393 | niro | 348 | mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');" |
394 | niro | 221 | evaluate_retval |
395 | niro | 252 | |
396 | # auth | ||
397 | niro | 348 | echo -e " Authentification settings ..." |
398 | mysqldo "insert into client_auth( | ||
399 | niro | 252 | serial, |
400 | username, | ||
401 | shell, | ||
402 | vnc, | ||
403 | samba, | ||
404 | station | ||
405 | ) | ||
406 | values( | ||
407 | '${ALX_SERIAL}', | ||
408 | '${ALX_UNPRIV_USER}', | ||
409 | '', | ||
410 | '', | ||
411 | '', | ||
412 | '' | ||
413 | );" | ||
414 | evaluate_retval | ||
415 | |||
416 | niro | 263 | # exchange ssh rsa keys - the first boot needs this ! |
417 | # or no reboot will work via the webadmin | ||
418 | niro | 348 | echo -e " SSH authentification settings ..." |
419 | niro | 264 | HOME=/root config_ssh_auth |
420 | niro | 263 | evaluate_retval |
421 | |||
422 | niro | 348 | # autostart |
423 | niro | 252 | echo -e " Autostart settings ..." |
424 | niro | 348 | mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
425 | |||
426 | # screensaver | ||
427 | echo -e " Screensaver settings ..." | ||
428 | mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" | ||
429 | |||
430 | niro | 252 | evaluate_retval |
431 | niro | 221 | } |
432 | |||
433 | niro | 282 | # imports current settings to the database resolved by the hardware detection |
434 | niro | 337 | update_settings_in_db() |
435 | { | ||
436 | niro | 282 | # note: networking is always 'dhcp' if hw was autodetected |
437 | # note: default_domain/hostname is set in config.rc or exported | ||
438 | # note: we updating only hardware settings here ! | ||
439 | |||
440 | # to be safe, we do some sanity checks | ||
441 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain | ||
442 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
443 | |||
444 | # vars used by hwdetect | ||
445 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME | ||
446 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER | ||
447 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE | ||
448 | |||
449 | # get setting from hwdetect | ||
450 | source /etc/sysconfig/hwsetup/knoppix | ||
451 | source /etc/sysconfig/hwsetup/mouse | ||
452 | |||
453 | echo | ||
454 | echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT} | ||
455 | |||
456 | # network | ||
457 | echo -e " Network settings ..." | ||
458 | niro | 337 | if [[ ${ALX_CONFD_NETWORKING} = true ]] |
459 | then | ||
460 | # get settings | ||
461 | #source ${rc_base}/init.d/network &> /dev/null | ||
462 | for iface in $(onboot_interface_list ${network_settings}/net.*) | ||
463 | do | ||
464 | [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue | ||
465 | echo "WARNING: only importing settings for interface [ ${iface} ] !" | ||
466 | source ${network_settings}/net.${iface} || exit 1 | ||
467 | NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" | ||
468 | niro | 282 | |
469 | niro | 348 | mysqldo "update cfg_network set |
470 | niro | 337 | hostname='${ALX_DEFAULT_HOSTNAME}', |
471 | module='${NETCARD_DRIVER}', | ||
472 | domain='${ALX_DEFAULT_DOMAIN}', | ||
473 | networking='${NETWORKING}', | ||
474 | netmask='${NETMASK}', | ||
475 | dns='${NAMESERVER}', | ||
476 | gateway='${GATEWAY}', | ||
477 | broadcast='${BROADCAST}', | ||
478 | ip='${IP}', | ||
479 | forcemacto='${FORCE_MAC_TO}', | ||
480 | wireless_bitrate='${WIRELESS_BITRATE}', | ||
481 | wireless_channel='${WIRELESS_CHANNEL}', | ||
482 | wireless_essid='${WIRELESS_ESSID}', | ||
483 | wireless_frequency='${WIRELESS_FREQUENCY}', | ||
484 | wireless_mode='${WIRELESS_MODE}', | ||
485 | wireless_nick='${WIRELESS_NICK}', | ||
486 | wireless_auth_mode='${WIRELESS_AUTH_MODE}', | ||
487 | wireless_key_length='${WIRELESS_KEY_LENGTH}', | ||
488 | wireless_key='${WIRELESS_KEY}', | ||
489 | wireless_key_ascii='${WIRELESS_KEY_ASCII}' | ||
490 | where serial=${ALX_SERIAL};" | ||
491 | |||
492 | # only insert the *FIRST* iface | ||
493 | break | ||
494 | done | ||
495 | else | ||
496 | niro | 348 | mysqldo "update cfg_network set |
497 | niro | 337 | hostname='${ALX_DEFAULT_HOSTNAME}', |
498 | module='${NETCARD_DRIVER}', | ||
499 | domain='${ALX_DEFAULT_DOMAIN}', | ||
500 | networking='dhcp' | ||
501 | where serial=${ALX_SERIAL};" | ||
502 | fi | ||
503 | niro | 282 | evaluate_retval |
504 | |||
505 | # xserver | ||
506 | echo -e " Graphic settings ..." | ||
507 | # xserver general | ||
508 | niro | 348 | mysqldo "update cfg_graphic set |
509 | niro | 282 | module='${XMODULE}', |
510 | resolution='1024x768', | ||
511 | depth='16', | ||
512 | monitorid='0' | ||
513 | where serial=${ALX_SERIAL};" | ||
514 | evaluate_retval | ||
515 | |||
516 | # input | ||
517 | echo -e " Input settings ..." | ||
518 | niro | 348 | mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};" |
519 | niro | 282 | evaluate_retval |
520 | } | ||
521 | |||
522 | niro | 221 | # imports current settings to the local system resolved by the hardware detection |
523 | niro | 337 | # we only need the network settings |
524 | import_settings_local() | ||
525 | { | ||
526 | niro | 282 | # note: networking is always 'dhcp' if hw was autodetected |
527 | # note: default_domain/hostname is set in config.rc | ||
528 | niro | 226 | |
529 | niro | 282 | # to be safe, we do some sanity checks |
530 | niro | 221 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
531 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
532 | niro | 226 | |
533 | niro | 282 | # vars used by hwdetect |
534 | niro | 221 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
535 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER | ||
536 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE | ||
537 | |||
538 | niro | 282 | # get setting from hwdetect |
539 | niro | 221 | source /etc/sysconfig/hwsetup/knoppix |
540 | niro | 226 | |
541 | niro | 221 | echo |
542 | echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} | ||
543 | |||
544 | niro | 337 | if [[ ${ALX_CONFD_NETWORKING} = false ]] |
545 | then | ||
546 | #[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} | ||
547 | #echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules | ||
548 | niro | 221 | |
549 | niro | 337 | # set an device alias for modprobe.conf |
550 | [ ! -d /etc/modules.d ] && install -d /etc/modules.d | ||
551 | echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0 | ||
552 | |||
553 | # regenerate modprobe.conf | ||
554 | [ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf" | ||
555 | evaluate_retval | ||
556 | fi | ||
557 | |||
558 | niro | 282 | # set system state to 'already configured' |
559 | niro | 226 | touch /etc/alxconfig-ng/state/configured |
560 | niro | 252 | |
561 | niro | 313 | # if only an recheck was forced than abort now |
562 | [[ ${ALX_FORCED_RECHECK} = true ]] && return 0 | ||
563 | |||
564 | niro | 275 | # create a fresh fluxbox directory |
565 | [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox | ||
566 | install -d ${ALX_UNPRIV_HOME}/.fluxbox | ||
567 | |||
568 | # now generate fluxbox config files | ||
569 | |||
570 | # fluxbox main config | ||
571 | cat ${ALX_SKELETONS}/fluxbox/init \ | ||
572 | > ${ALX_UNPRIV_HOME}/.fluxbox/init | ||
573 | |||
574 | niro | 319 | # fluxbox autostart |
575 | cat ${ALX_SKELETONS}/fluxbox/apps \ | ||
576 | > ${ALX_UNPRIV_HOME}/.fluxbox/apps | ||
577 | |||
578 | niro | 275 | # fluxbox menu header |
579 | cat ${ALX_SKELETONS}/fluxbox/menu.header \ | ||
580 | > ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
581 | |||
582 | niro | 297 | # now fix it with proper messages :P |
583 | local ver="$(< /etc/mageversion)" | ||
584 | sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" \ | ||
585 | ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
586 | |||
587 | niro | 275 | # add a newline (maybe there is no crlf in the header) |
588 | echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
589 | |||
590 | # fluxbox menu footer | ||
591 | cat ${ALX_SKELETONS}/fluxbox/menu.footer \ | ||
592 | >> ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
593 | |||
594 | # add a newline (maybe there is no crlf in the footer) | ||
595 | echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
596 | |||
597 | niro | 313 | |
598 | # setup some standart icons (sysinfo.lnk) | ||
599 | # basic config | ||
600 | cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc | ||
601 | |||
602 | # clean desktop icon location | ||
603 | [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop | ||
604 | install -d ${ALX_UNPRIV_HOME}/.xtdesktop | ||
605 | |||
606 | # last but not least gen a icon with some sys informations | ||
607 | local sysinfo | ||
608 | local osversion | ||
609 | local xres | ||
610 | local yres | ||
611 | |||
612 | osversion="$(< /etc/mageversion)" | ||
613 | sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" | ||
614 | |||
615 | # at first boot we got always a resolution of 1024x768-16@60 | ||
616 | # middle of the screen | ||
617 | # (no txt - length required, xtdesk manage that itself) | ||
618 | xres="$((1024 / 2))" | ||
619 | # default y pos (full yres -22 !) | ||
620 | yres="$((768 - 22 ))" | ||
621 | |||
622 | generate_icon \ | ||
623 | --name "${sysinfo}" \ | ||
624 | --command "exit 0" \ | ||
625 | --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ | ||
626 | --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ | ||
627 | --xres "${xres}" \ | ||
628 | --yres "${yres}" \ | ||
629 | --icon-width "1" \ | ||
630 | --icon-height "1" | ||
631 | |||
632 | niro | 368 | # create a xinitrc |
633 | echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc | ||
634 | |||
635 | niro | 282 | # set correct permissions |
636 | chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} | ||
637 | chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox | ||
638 | chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox | ||
639 | niro | 348 | chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
640 | chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc | ||
641 | niro | 368 | chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc |
642 | niro | 221 | } |
643 | |||
644 | niro | 282 | # start|stop |
645 | niro | 337 | preliminary_network() |
646 | { | ||
647 | niro | 221 | local module |
648 | niro | 226 | |
649 | if [ -f /etc/alxconfig-ng/state/configured ] | ||
650 | niro | 221 | then |
651 | niro | 337 | # compat for old clients |
652 | if [ -f ${SETTINGSPATH}/modules ] | ||
653 | then | ||
654 | # get module name | ||
655 | module=$(cat ${SETTINGSPATH}/modules) | ||
656 | modprobe ${module} | ||
657 | fi | ||
658 | niro | 221 | else |
659 | niro | 282 | # vars used by hwdetect |
660 | niro | 221 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
661 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER | ||
662 | niro | 226 | |
663 | niro | 282 | # get setting from hwdetect |
664 | niro | 221 | source /etc/sysconfig/hwsetup/knoppix |
665 | modprobe ${NETCARD_DRIVER} | ||
666 | fi | ||
667 | niro | 226 | |
668 | niro | 221 | case $1 in |
669 | start) | ||
670 | # keeping like always safe: | ||
671 | # no network should be startet here, | ||
672 | # so we can delete all pid files if one exists | ||
673 | if ps -A|grep dhcpcd > /dev/null | ||
674 | then | ||
675 | echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT} | ||
676 | dhcpcd -k | ||
677 | sleep 1 | ||
678 | else | ||
679 | rm -f /var/run/dhcpcd-eth?.pid | ||
680 | fi | ||
681 | niro | 348 | [[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \ |
682 | ${rc_base}/init.d/network stop | ||
683 | niro | 226 | |
684 | niro | 337 | echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} |
685 | niro | 226 | |
686 | niro | 337 | # start network configured from /etc/conf.d |
687 | if [[ ${ALX_CONFD_NETWORKING} = true ]] | ||
688 | then | ||
689 | ${rc_base}/init.d/network start | ||
690 | else | ||
691 | echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT} | ||
692 | # -t 10 timeout of 10 secs | ||
693 | dhcpcd -t 10 &> /dev/null | ||
694 | evaluate_retval | ||
695 | fi | ||
696 | niro | 221 | ;; |
697 | niro | 226 | |
698 | niro | 221 | stop) |
699 | niro | 337 | echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT} |
700 | if [[ ${ALX_CONFD_NETWORKING} = true ]] | ||
701 | then | ||
702 | ${rc_base}/init.d/network stop | ||
703 | else | ||
704 | echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT} | ||
705 | ifconfig eth0 down | ||
706 | fi | ||
707 | niro | 221 | if ps -A|grep dhcpcd > /dev/null |
708 | then | ||
709 | dhcpcd -z &> /dev/null | ||
710 | fi | ||
711 | evaluate_retval | ||
712 | ;; | ||
713 | niro | 226 | |
714 | niro | 221 | *) |
715 | echo "Usage: preliminary_network {start|stop}" | ||
716 | ;; | ||
717 | esac | ||
718 | } | ||
719 | |||
720 | niro | 337 | reset_system_settings() |
721 | { | ||
722 | # force load of de kbdkeys | ||
723 | loadkeys -q de | ||
724 | echo | ||
725 | echo -en ${COLRED} | ||
726 | echo -n "*** Warning: you are about to reset *all* local settings on this system!" | ||
727 | echo -e ${COLDEFAULT} | ||
728 | echo "*** Do you really want to continue ?" | ||
729 | echo -n "*** Enter 'yes' to continue, anything else to abort: " | ||
730 | read kbinsert | ||
731 | if [[ ${kbinsert} = yes ]] | ||
732 | then | ||
733 | echo -en ${COLRED} | ||
734 | echo -n "*** OK, you really want it ... killing all settings: " | ||
735 | for i in 3 2 1 now | ||
736 | do | ||
737 | echo -n " ${i}" | ||
738 | sleep 1 | ||
739 | done | ||
740 | echo -e ${COLDEFAULT} | ||
741 | |||
742 | ## reset all settings: | ||
743 | rm -rf ${SETTINGSPATH}/* | ||
744 | rm -f /etc/alxconfig-ng/serial | ||
745 | rm -rf /etc/alxconfig-ng/state | ||
746 | |||
747 | niro | 357 | # clear all printers & net-shares |
748 | :> /etc/cups/printers.conf | ||
749 | :> /etc/samba/smb.conf | ||
750 | |||
751 | # remove inetd, cups & smb from init | ||
752 | rc-config del inetd &> /dev/null | ||
753 | rc-config del cups &> /dev/null | ||
754 | rc-config del samba &> /dev/null | ||
755 | |||
756 | # remove all user settings | ||
757 | [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} | ||
758 | |||
759 | # remove all ica-sessions | ||
760 | niro | 359 | find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm |
761 | niro | 357 | |
762 | # remove all old nics and modules configs | ||
763 | find /etc/conf.d -type f -name 'net.*' | xargs rm | ||
764 | find /etc/modules.d -type f -name 'net.*' | xargs rm | ||
765 | |||
766 | # restore default networking | ||
767 | cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 | ||
768 | |||
769 | niro | 337 | echo "I am done now, press [Enter] to reboot system ..." |
770 | niro | 348 | else |
771 | echo "Aborted, press [Enter] to reboot system ..." | ||
772 | niro | 337 | fi |
773 | niro | 348 | read |
774 | reboot | ||
775 | niro | 337 | } |
776 | |||
777 | onboot_interface_list() | ||
778 | { | ||
779 | local file | ||
780 | local devices | ||
781 | local iface | ||
782 | |||
783 | # get list of all devices | ||
784 | for file in $@ | ||
785 | do | ||
786 | if [[ $(read_value ONBOOT ${file}) = yes ]] | ||
787 | then | ||
788 | iface="$(basename ${file} | sed s/net.//)" | ||
789 | # exclude backup files | ||
790 | case "${iface}" in | ||
791 | *~) ;; | ||
792 | *) devices="${devices} $(basename ${file} | sed s/net.//)" ;; | ||
793 | esac | ||
794 | fi | ||
795 | done | ||
796 | |||
797 | echo "${devices}" | ||
798 | } | ||
799 | |||
800 | niro | 348 | # read values from net.* files |
801 | niro | 337 | read_value() |
802 | { | ||
803 | local var="$1" | ||
804 | local file="$2" | ||
805 | local value | ||
806 | |||
807 | # local all possible vars | ||
808 | # global | ||
809 | local ONBOOT | ||
810 | local NETWORKING | ||
811 | |||
812 | # static | ||
813 | local IP | ||
814 | local NETMASK | ||
815 | local BROADCAST | ||
816 | local NETWORKING | ||
817 | local FORCE_MAC_TO | ||
818 | |||
819 | # dhcp | ||
820 | local DHCP_PROG | ||
821 | local DHCP_START | ||
822 | local DHCP_STOP | ||
823 | |||
824 | # default gw | ||
825 | local GATEWAY | ||
826 | local GATEWAY_IF | ||
827 | |||
828 | # wireless extensions | ||
829 | local WIRELESS_AP | ||
830 | local WIRELESS_AUTH_MODE | ||
831 | local WIRELESS_BITRATE | ||
832 | local WIRELESS_CHANNEL | ||
833 | local WIRELESS_DEFAULT_KEY | ||
834 | local WIRELESS_ESSID | ||
835 | local WIRELESS_FREQUENCY | ||
836 | local WIRELESS_KEY | ||
837 | local WIRELESS_KEY_ASCII | ||
838 | local WIRELESS_KEY_0 | ||
839 | local WIRELESS_KEY_1 | ||
840 | local WIRELESS_KEY_2 | ||
841 | local WIRELESS_KEY_3 | ||
842 | local WIRELESS_KEY_LENGTH | ||
843 | local WIRELESS_MODE | ||
844 | local WIRELESS_NICK | ||
845 | local WIRELESS_NWID | ||
846 | local WIRELESS_POWER | ||
847 | |||
848 | source ${file} | ||
849 | eval value=\$$(echo ${var}) | ||
850 | echo "${value}" | ||
851 | } | ||
852 | |||
853 | niro | 221 | case $1 in |
854 | start) | ||
855 | niro | 337 | # check for global overrides |
856 | [ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true | ||
857 | [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true | ||
858 | read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true | ||
859 | read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true | ||
860 | |||
861 | # kill all settings if requested | ||
862 | if [[ ${ALX_RESET_SETTINGS} = true ]] | ||
863 | then | ||
864 | reset_system_settings | ||
865 | fi | ||
866 | |||
867 | niro | 282 | # retrieve or validate current serial |
868 | niro | 221 | get_system_serial |
869 | niro | 282 | if [[ ${ALX_HW_DETECT} = true ]] |
870 | niro | 221 | then |
871 | niro | 282 | if [[ ${ALX_FORCED_RECHECK} = true ]] |
872 | then | ||
873 | update_settings_in_db | ||
874 | else | ||
875 | import_settings_to_db | ||
876 | fi | ||
877 | niro | 221 | import_settings_local |
878 | niro | 252 | |
879 | # here we should also exchange the ssh keys | ||
880 | # or the system cannot be rebooted after | ||
881 | # the first start via the alx-webadmin | ||
882 | config_ssh_auth | ||
883 | niro | 221 | fi |
884 | niro | 252 | |
885 | niro | 282 | # now setup system configuration |
886 | # alx_setup_or_whatever_it_will_be_called() | ||
887 | niro | 348 | [[ ${ALX_HW_DETECT} = false ]] && update_system_settings |
888 | niro | 221 | |
889 | niro | 282 | # stop at last the preliminary networking (dhcp) |
890 | niro | 221 | preliminary_network stop |
891 | ;; | ||
892 | niro | 282 | |
893 | niro | 221 | stop) |
894 | niro | 282 | # unset_alx_connected #--> now in alxsetstate-rc6 |
895 | niro | 221 | # ! important !: del systemstate |
896 | niro | 226 | [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state |
897 | niro | 221 | sleep 0.1 |
898 | ;; | ||
899 | *) | ||
900 | echo "Usage: $0 {start|stop} ..." | ||
901 | ;; | ||
902 | esac | ||
903 | niro | 252 |
Properties
Name | Value |
---|---|
svn:executable | * |