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