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