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