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