Annotation of /alx-src/trunk/tinyalxconfig-ng/init.d/alxsettings
Parent Directory | Revision Log
Revision 489 -
(hide annotations)
(download)
Sun Jun 8 10:05:01 2008 UTC (15 years, 11 months ago) by niro
File size: 17804 byte(s)
Sun Jun 8 10:05:01 2008 UTC (15 years, 11 months ago) by niro
File size: 17804 byte(s)
-added config_driverkits()
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 | 489 | # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/init.d/alxsettings,v 1.14 2008-06-08 10:05:01 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 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain | ||
276 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
277 | |||
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 | echo -e " 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 | echo -e " Graphic settings ..." | ||
321 | # 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 | echo -e " 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 | echo -e " Authentification settings ..." | ||
345 | 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 | echo -e " SSH authentification settings ..." | ||
366 | HOME=/root config_ssh_auth | ||
367 | evaluate_retval | ||
368 | |||
369 | # autostart | ||
370 | echo -e " Autostart settings ..." | ||
371 | mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" | ||
372 | |||
373 | # screensaver | ||
374 | echo -e " Screensaver settings ..." | ||
375 | 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 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain | ||
389 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
390 | |||
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 | echo -e " 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 | echo -e " Graphic settings ..." | ||
431 | # 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 | echo -e " 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 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain | ||
455 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
456 | |||
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 | cat ${ALX_SKELETONS}/fluxbox/init \ | ||
482 | > ${ALX_UNPRIV_HOME}/.fluxbox/init | ||
483 | |||
484 | # fluxbox autostart | ||
485 | cat ${ALX_SKELETONS}/fluxbox/apps \ | ||
486 | > ${ALX_UNPRIV_HOME}/.fluxbox/apps | ||
487 | |||
488 | # fluxbox menu header | ||
489 | cat ${ALX_SKELETONS}/fluxbox/menu.header \ | ||
490 | > ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
491 | |||
492 | # now fix it with proper messages :P | ||
493 | local ver="$(< /etc/mageversion)" | ||
494 | sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" \ | ||
495 | ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
496 | |||
497 | # add a newline (maybe there is no crlf in the header) | ||
498 | echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
499 | |||
500 | # fluxbox menu footer | ||
501 | cat ${ALX_SKELETONS}/fluxbox/menu.footer \ | ||
502 | >> ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
503 | |||
504 | # add a newline (maybe there is no crlf in the footer) | ||
505 | echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
506 | |||
507 | # setup some standart icons (sysinfo.lnk) | ||
508 | # basic config | ||
509 | cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc | ||
510 | |||
511 | # clean desktop icon location | ||
512 | [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop | ||
513 | install -d ${ALX_UNPRIV_HOME}/.xtdesktop | ||
514 | |||
515 | # last but not least gen a icon with some sys informations | ||
516 | local sysinfo | ||
517 | local osversion | ||
518 | local xres | ||
519 | local yres | ||
520 | |||
521 | osversion="$(< /etc/mageversion)" | ||
522 | sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" | ||
523 | |||
524 | # at first boot we got always a resolution of 1024x768-16@60 | ||
525 | # middle of the screen | ||
526 | # (no txt - length required, xtdesk manage that itself) | ||
527 | xres="$((1024 / 2))" | ||
528 | # default y pos (full yres -22 !) | ||
529 | yres="$((768 - 22 ))" | ||
530 | |||
531 | generate_icon \ | ||
532 | --name "${sysinfo}" \ | ||
533 | --command "exit 0" \ | ||
534 | --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ | ||
535 | --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ | ||
536 | --xres "${xres}" \ | ||
537 | --yres "${yres}" \ | ||
538 | --icon-width "1" \ | ||
539 | --icon-height "1" | ||
540 | |||
541 | # create a xinitrc | ||
542 | echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc | ||
543 | |||
544 | # set correct permissions | ||
545 | chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} | ||
546 | chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox | ||
547 | chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox | ||
548 | chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop | ||
549 | chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc | ||
550 | chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc | ||
551 | } | ||
552 | |||
553 | # start|stop | ||
554 | preliminary_network() | ||
555 | { | ||
556 | case $1 in | ||
557 | start) | ||
558 | # keeping like always safe: | ||
559 | niro | 388 | # no network should be started here |
560 | ${rc_base}/init.d/network stop | ||
561 | niro | 386 | |
562 | echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} | ||
563 | # start network configured from /etc/conf.d | ||
564 | niro | 388 | ${rc_base}/init.d/network start |
565 | niro | 386 | ;; |
566 | |||
567 | stop) | ||
568 | echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT} | ||
569 | niro | 388 | ${rc_base}/init.d/network stop |
570 | niro | 386 | ;; |
571 | |||
572 | *) | ||
573 | echo "Usage: preliminary_network {start|stop}" | ||
574 | ;; | ||
575 | esac | ||
576 | } | ||
577 | |||
578 | reset_system_settings() | ||
579 | { | ||
580 | # force load of de kbdkeys | ||
581 | loadkeys -q de | ||
582 | echo | ||
583 | echo -en ${COLRED} | ||
584 | echo -n "*** Warning: you are about to reset *all* local settings on this system!" | ||
585 | echo -e ${COLDEFAULT} | ||
586 | echo "*** Do you really want to continue ?" | ||
587 | echo -n "*** Enter 'yes' to continue, anything else to abort: " | ||
588 | read kbinsert | ||
589 | if [[ ${kbinsert} = yes ]] | ||
590 | then | ||
591 | echo -en ${COLRED} | ||
592 | echo -n "*** OK, you really want it ... killing all settings: " | ||
593 | for i in 3 2 1 now | ||
594 | do | ||
595 | echo -n " ${i}" | ||
596 | sleep 1 | ||
597 | done | ||
598 | echo -e ${COLDEFAULT} | ||
599 | |||
600 | ## reset all settings: | ||
601 | rm -rf ${SETTINGSPATH}/* | ||
602 | rm -f /etc/alxconfig-ng/serial | ||
603 | rm -rf /etc/alxconfig-ng/state | ||
604 | |||
605 | # clear all printers & net-shares | ||
606 | :> /etc/cups/printers.conf | ||
607 | :> /etc/samba/smb.conf | ||
608 | |||
609 | # remove inetd, cups & smb from init | ||
610 | rc-config del inetd &> /dev/null | ||
611 | rc-config del cups &> /dev/null | ||
612 | rc-config del samba &> /dev/null | ||
613 | |||
614 | # remove all user settings | ||
615 | [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} | ||
616 | |||
617 | # remove all ica-sessions | ||
618 | find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm | ||
619 | |||
620 | # remove all old nics and modules configs | ||
621 | find /etc/conf.d -type f -name 'net.*' | xargs rm | ||
622 | find /etc/modules.d -type f -name 'net.*' | xargs rm | ||
623 | |||
624 | # restore default networking | ||
625 | cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 | ||
626 | |||
627 | echo "I am done now, press [Enter] to reboot system ..." | ||
628 | else | ||
629 | echo "Aborted, press [Enter] to reboot system ..." | ||
630 | fi | ||
631 | read | ||
632 | reboot | ||
633 | } | ||
634 | |||
635 | case $1 in | ||
636 | start) | ||
637 | # check for global overrides | ||
638 | [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true | ||
639 | read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true | ||
640 | read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true | ||
641 | |||
642 | # kill all settings if requested | ||
643 | if [[ ${ALX_RESET_SETTINGS} = true ]] | ||
644 | then | ||
645 | reset_system_settings | ||
646 | fi | ||
647 | |||
648 | # retrieve or validate current serial | ||
649 | get_system_serial | ||
650 | if [[ ${ALX_HW_DETECT} = true ]] | ||
651 | then | ||
652 | if [[ ${ALX_FORCED_RECHECK} = true ]] | ||
653 | then | ||
654 | update_settings_in_db | ||
655 | else | ||
656 | import_settings_to_db | ||
657 | fi | ||
658 | import_settings_local | ||
659 | |||
660 | # here we should also exchange the ssh keys | ||
661 | # or the system cannot be rebooted after | ||
662 | # the first start via the alx-webadmin | ||
663 | config_ssh_auth | ||
664 | fi | ||
665 | |||
666 | # now setup system configuration | ||
667 | # alx_setup_or_whatever_it_will_be_called() | ||
668 | [[ ${ALX_HW_DETECT} = false ]] && update_system_settings | ||
669 | |||
670 | # stop at last the preliminary networking (dhcp) | ||
671 | preliminary_network stop | ||
672 | ;; | ||
673 | |||
674 | stop) | ||
675 | # unset_alx_connected #--> now in alxsetstate-rc6 | ||
676 | # ! important !: del systemstate | ||
677 | [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state | ||
678 | ;; | ||
679 | *) | ||
680 | echo "Usage: $0 {start|stop} ..." | ||
681 | ;; | ||
682 | esac | ||
683 |
Properties
Name | Value |
---|---|
svn:executable | * |