11 |
#%before: |
#%before: |
12 |
#%after: |
#%after: |
13 |
|
|
14 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.16 2005-08-18 07:39:00 niro Exp $ |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.27 2005-10-11 12:10:15 niro Exp $ |
15 |
|
|
16 |
# checks first if the client was already configured and if it has an valid serial |
# checks first if the client was already configured and if it has an valid serial |
17 |
# if not it runs the autoconfiguration script |
# if not it runs the autoconfiguration script |
37 |
source /usr/lib/alxconfig-ng/functions/config_x11 |
source /usr/lib/alxconfig-ng/functions/config_x11 |
38 |
source /usr/lib/alxconfig-ng/functions/config_auth |
source /usr/lib/alxconfig-ng/functions/config_auth |
39 |
source /usr/lib/alxconfig-ng/functions/config_ssh_auth |
source /usr/lib/alxconfig-ng/functions/config_ssh_auth |
40 |
|
source /usr/lib/alxconfig-ng/functions/config_versions |
41 |
|
|
42 |
# check if mysql is available |
# check if mysql is available |
43 |
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
45 |
# other needed vars |
# other needed vars |
46 |
ALX_HW_DETECT=false |
ALX_HW_DETECT=false |
47 |
ALX_FORCED_RECHECK=false |
ALX_FORCED_RECHECK=false |
48 |
|
ALX_RESET_SETTINGS=false |
49 |
|
ALX_CONFD_NETWORKING=false |
50 |
|
|
51 |
# unset vars which may kill us |
# unset vars which may kill us |
52 |
unset ALX_SERIAL ALX_STATE |
unset ALX_SERIAL ALX_STATE |
56 |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
57 |
|
|
58 |
|
|
59 |
update_system_settings(){ |
# read_cmdline ${item} |
60 |
|
read_cmdline() |
61 |
|
{ |
62 |
|
local i |
63 |
|
|
64 |
|
for i in $(< /proc/cmdline) |
65 |
|
do |
66 |
|
[[ ${i} = $1 ]] && return 0 |
67 |
|
done |
68 |
|
|
69 |
|
return 1 |
70 |
|
} |
71 |
|
|
72 |
|
update_system_settings() |
73 |
|
{ |
74 |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
75 |
|
|
76 |
# get the modules settings |
# get the modules settings |
94 |
|
|
95 |
# exchange ssh rsa keys |
# exchange ssh rsa keys |
96 |
HOME=/root config_ssh_auth |
HOME=/root config_ssh_auth |
97 |
|
|
98 |
|
# import version info |
99 |
|
config_version |
100 |
} |
} |
101 |
|
|
102 |
get_system_serial(){ |
get_system_serial() |
103 |
|
{ |
104 |
|
local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE |
105 |
|
|
106 |
local CUR_IP CUR_MAC CUR_MTIME |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
107 |
|
then |
108 |
|
ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)" |
109 |
|
else |
110 |
|
ALX_IFACE="eth0" |
111 |
|
fi |
112 |
|
|
113 |
# check if serial file exists |
# check if serial file exists |
114 |
if [ -f /etc/alxconfig-ng/serial ] && [ ! -f /hardware-auto-detection ] |
if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]] |
115 |
then |
then |
116 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
117 |
|
|
126 |
exit 1 |
exit 1 |
127 |
fi |
fi |
128 |
|
|
129 |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') |
130 |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) |
131 |
CUR_MTIME=$(date +%s) |
CUR_MTIME=$(date +%s) |
132 |
|
|
133 |
echo -e ${COLOREDSTAR} "Trying to validate my serial ..." |
echo -e ${COLOREDSTAR} "Trying to validate my serial ..." |
141 |
then |
then |
142 |
ALX_STATE="ok" |
ALX_STATE="ok" |
143 |
else |
else |
144 |
|
# abort on non valid serial |
145 |
ALX_STATE="invalid serial" |
ALX_STATE="invalid serial" |
146 |
|
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
147 |
|
show_invalid_serial_msg |
148 |
|
exit 1 |
149 |
fi |
fi |
150 |
|
|
151 |
else |
else |
152 |
# run hardware detection |
# run hardware detection |
153 |
echo |
echo |
154 |
if [ -f /hardware-auto-detection ] |
if [[ ${ALX_FORCED_RECHECK} = true ]] |
155 |
then |
then |
156 |
echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} |
157 |
else |
else |
162 |
|
|
163 |
# set hostname to alx_default_hostname |
# set hostname to alx_default_hostname |
164 |
# use old hostname if this is a forced re-check |
# use old hostname if this is a forced re-check |
165 |
[ -f /hardware-auto-detection ] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)" |
[[ ${ALX_FORCED_RECHECK} = true ]] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)" |
166 |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
167 |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
168 |
|
|
185 |
CUR_MTIME=$(date +%s) |
CUR_MTIME=$(date +%s) |
186 |
|
|
187 |
# abort now if this is a forced re-check |
# abort now if this is a forced re-check |
188 |
if [ -f /hardware-auto-detection ] |
if [[ ${ALX_FORCED_RECHECK} = true ]] |
189 |
then |
then |
190 |
# but first check the serial |
# but first check the serial |
191 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
201 |
then |
then |
202 |
ALX_STATE="ok" |
ALX_STATE="ok" |
203 |
else |
else |
204 |
|
# abort on non valid serial |
205 |
ALX_STATE="invalid serial" |
ALX_STATE="invalid serial" |
206 |
|
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
207 |
|
show_invalid_serial_msg |
208 |
|
exit 1 |
209 |
fi |
fi |
210 |
|
|
211 |
# write current state to temp file |
# write current state to temp file |
212 |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
213 |
rm /hardware-auto-detection |
[ -f /hardware-auto-detection ] && rm /hardware-auto-detection |
214 |
|
|
215 |
# now export ALX_FORCED_RECHECK=true |
# now export ALX_FORCED_RECHECK=true |
216 |
# that the setting will be updated not inserted ! |
# that the setting will be updated not inserted ! |
220 |
|
|
221 |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
222 |
|
|
223 |
# request new serial |
# request a new serial; one command now (cause must be done in the same session) |
224 |
# ALX_REG_DATE="$(date +%F)" |
ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); |
225 |
|
select last_insert_id();") |
226 |
|
|
227 |
# we're using the mtime now (better for vaildating the serial) |
if [[ ${ALX_SERIAL} != NULL ]] |
|
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"insert into client_serials( |
|
|
mtime, |
|
|
mac |
|
|
) |
|
|
values( |
|
|
'${CUR_MTIME}', |
|
|
'${CUR_MAC}' |
|
|
);" |
|
|
|
|
|
# then validate and retrieve serial |
|
|
|
|
|
### warning must be changed that only the LAST ID will be fetched, ### |
|
|
### or you get error if the computer name and date are the same ### |
|
|
### you have more than one serial number then ### |
|
|
|
|
|
# select highest id only (added max) |
|
|
ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'") |
|
|
|
|
|
if [ "${ALX_SERIAL}" != NULL ] |
|
228 |
then |
then |
229 |
# nice serial output |
# nice serial output |
230 |
$CURS_UP |
$CURS_UP |
231 |
$SET_WCOL |
$SET_WCOL |
232 |
echo "[ SN: ${ALX_SERIAL} ]" |
echo "[ SN: ${ALX_SERIAL} ]" |
233 |
|
|
234 |
# set ALX_STATE to ok so everybody that everything was ok |
# set ALX_STATE to ok so everybody knows that everything was ok |
235 |
ALX_STATE=ok |
ALX_STATE=ok |
236 |
|
|
237 |
echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial |
echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial |
255 |
|
|
256 |
# write current state to temp file |
# write current state to temp file |
257 |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
258 |
|
echo "ALX_IFACE=${ALX_IFACE}" >> /etc/alxconfig-ng/state/state |
259 |
} |
} |
260 |
|
|
261 |
|
|
262 |
check_is_configured() { |
check_is_configured() |
263 |
|
{ |
264 |
if [ -f /etc/alxconfig-ng/state/configured ] |
if [ -f /etc/alxconfig-ng/state/configured ] |
265 |
then |
then |
266 |
export ALX_CONFIGURED=true |
export ALX_CONFIGURED=true |
271 |
|
|
272 |
|
|
273 |
# imports current settings to the database resolved by the hardware detection |
# imports current settings to the database resolved by the hardware detection |
274 |
import_settings_to_db() { |
import_settings_to_db() |
275 |
|
{ |
276 |
# note: networking is always 'dhcp' if hw was autodetected |
# note: networking is always 'dhcp' if hw was autodetected |
277 |
# note: default_domain/hostname is set in config.rc |
# note: default_domain/hostname is set in config.rc |
278 |
|
|
294 |
|
|
295 |
# network |
# network |
296 |
echo -e " Network settings ..." |
echo -e " Network settings ..." |
297 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
298 |
"insert into cfg_network( |
then |
299 |
hostname, |
# get settings |
300 |
serial, |
#source ${rc_base}/init.d/network &> /dev/null |
301 |
module, |
for iface in $(onboot_interface_list ${network_settings}/net.*) |
302 |
domain, |
do |
303 |
networking |
[[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue |
304 |
) |
echo "WARNING: only importing settings for interface [ ${iface} ] !" |
305 |
values( |
source ${network_settings}/net.${iface} || exit 1 |
306 |
'${ALX_DEFAULT_HOSTNAME}', |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
307 |
'${ALX_SERIAL}', |
|
308 |
'${NETCARD_DRIVER}', |
mysqldo "insert into cfg_network( |
309 |
'${ALX_DEFAULT_DOMAIN}', |
hostname, |
310 |
'dhcp' |
serial, |
311 |
);" |
module, |
312 |
|
domain, |
313 |
|
networking, |
314 |
|
netmask, |
315 |
|
dns, |
316 |
|
gateway, |
317 |
|
broadcast, |
318 |
|
ip, |
319 |
|
forcemacto, |
320 |
|
wireless_bitrate, |
321 |
|
wireless_channel, |
322 |
|
wireless_essid, |
323 |
|
wireless_frequency, |
324 |
|
wireless_mode, |
325 |
|
wireless_nick, |
326 |
|
wireless_auth_mode, |
327 |
|
wireless_key_length, |
328 |
|
wireless_key, |
329 |
|
wireless_key_ascii |
330 |
|
) |
331 |
|
values( |
332 |
|
'${ALX_DEFAULT_HOSTNAME}', |
333 |
|
'${ALX_SERIAL}', |
334 |
|
'${NETCARD_DRIVER}', |
335 |
|
'${ALX_DEFAULT_DOMAIN}', |
336 |
|
'${NETWORKING}', |
337 |
|
'${NETMASK}', |
338 |
|
'${NAMESERVER}', |
339 |
|
'${GATEWAY}', |
340 |
|
'${BROADCAST}', |
341 |
|
'${IP}', |
342 |
|
'${FORCE_MAC_TO}', |
343 |
|
'${WIRELESS_BITRATE}', |
344 |
|
'${WIRELESS_CHANNEL}', |
345 |
|
'${WIRELESS_ESSID}', |
346 |
|
'${WIRELESS_FREQUENCY}', |
347 |
|
'${WIRELESS_MODE}', |
348 |
|
'${WIRELESS_NICK}', |
349 |
|
'${WIRELESS_AUTH_MODE}', |
350 |
|
'${WIRELESS_KEY_LENGTH}', |
351 |
|
'${WIRELESS_KEY}', |
352 |
|
'${WIRELESS_KEY_ASCII}' |
353 |
|
);" |
354 |
|
|
355 |
|
# only insert the *FIRST* iface |
356 |
|
break |
357 |
|
done |
358 |
|
else |
359 |
|
mysqldo "insert into cfg_network( |
360 |
|
hostname, |
361 |
|
serial, |
362 |
|
module, |
363 |
|
domain, |
364 |
|
networking |
365 |
|
) |
366 |
|
values( |
367 |
|
'${ALX_DEFAULT_HOSTNAME}', |
368 |
|
'${ALX_SERIAL}', |
369 |
|
'${NETCARD_DRIVER}', |
370 |
|
'${ALX_DEFAULT_DOMAIN}', |
371 |
|
'dhcp' |
372 |
|
);" |
373 |
|
fi |
374 |
evaluate_retval |
evaluate_retval |
375 |
|
|
376 |
# xserver |
# xserver |
377 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
378 |
# xserver general |
# xserver general |
379 |
( mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
( mysqldo "insert into cfg_graphic( |
|
"insert into cfg_graphic( |
|
380 |
serial, |
serial, |
381 |
module, |
module, |
382 |
resolution, |
resolution, |
383 |
depth, |
depth, |
384 |
monitorid |
refresh_rate |
385 |
) |
) |
386 |
values( |
values( |
387 |
'${ALX_SERIAL}', |
'${ALX_SERIAL}', |
388 |
'${XMODULE}', |
'${XMODULE}', |
389 |
'1024x768', |
'1024x768', |
390 |
'16', |
'16', |
391 |
'0' |
'60' |
392 |
);"; ) |
);"; ) |
393 |
evaluate_retval |
evaluate_retval |
394 |
|
|
395 |
# input |
# input |
396 |
echo -e " Input settings ..." |
echo -e " Input settings ..." |
397 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');" |
|
"insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');" |
|
398 |
evaluate_retval |
evaluate_retval |
399 |
|
|
400 |
# auth |
# auth |
401 |
echo -e " Authentifcation settings ..." |
echo -e " Authentification settings ..." |
402 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into client_auth( |
|
"insert into client_auth( |
|
403 |
serial, |
serial, |
404 |
username, |
username, |
405 |
shell, |
shell, |
419 |
|
|
420 |
# exchange ssh rsa keys - the first boot needs this ! |
# exchange ssh rsa keys - the first boot needs this ! |
421 |
# or no reboot will work via the webadmin |
# or no reboot will work via the webadmin |
422 |
echo -e " SSH authentifcation settings ..." |
echo -e " SSH authentification settings ..." |
423 |
HOME=/root config_ssh_auth |
HOME=/root config_ssh_auth |
424 |
evaluate_retval |
evaluate_retval |
425 |
|
|
426 |
# input |
# autostart |
427 |
echo -e " Autostart settings ..." |
echo -e " Autostart settings ..." |
428 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
429 |
"insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
|
430 |
|
# screensaver |
431 |
|
echo -e " Screensaver settings ..." |
432 |
|
mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" |
433 |
|
|
434 |
|
# version info |
435 |
|
local alx_os |
436 |
|
local alx_utils |
437 |
|
alx_os="$(< /etc/mageversion)" |
438 |
|
alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" |
439 |
|
alx_utils="${alx_utils/alxconfig-ng-alx-}" |
440 |
|
mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')" |
441 |
|
|
442 |
evaluate_retval |
evaluate_retval |
443 |
} |
} |
444 |
|
|
445 |
# imports current settings to the database resolved by the hardware detection |
# imports current settings to the database resolved by the hardware detection |
446 |
update_settings_in_db() { |
update_settings_in_db() |
447 |
|
{ |
448 |
# note: networking is always 'dhcp' if hw was autodetected |
# note: networking is always 'dhcp' if hw was autodetected |
449 |
# note: default_domain/hostname is set in config.rc or exported |
# note: default_domain/hostname is set in config.rc or exported |
450 |
# note: we updating only hardware settings here ! |
# note: we updating only hardware settings here ! |
467 |
|
|
468 |
# network |
# network |
469 |
echo -e " Network settings ..." |
echo -e " Network settings ..." |
470 |
|
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
471 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
then |
472 |
"update cfg_network set |
# get settings |
473 |
hostname='${ALX_DEFAULT_HOSTNAME}', |
#source ${rc_base}/init.d/network &> /dev/null |
474 |
module='${NETCARD_DRIVER}', |
for iface in $(onboot_interface_list ${network_settings}/net.*) |
475 |
domain='${ALX_DEFAULT_DOMAIN}', |
do |
476 |
networking='dhcp' |
[[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue |
477 |
where serial=${ALX_SERIAL};" |
echo "WARNING: only importing settings for interface [ ${iface} ] !" |
478 |
|
source ${network_settings}/net.${iface} || exit 1 |
479 |
|
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
480 |
|
|
481 |
|
mysqldo "update cfg_network set |
482 |
|
hostname='${ALX_DEFAULT_HOSTNAME}', |
483 |
|
module='${NETCARD_DRIVER}', |
484 |
|
domain='${ALX_DEFAULT_DOMAIN}', |
485 |
|
networking='${NETWORKING}', |
486 |
|
netmask='${NETMASK}', |
487 |
|
dns='${NAMESERVER}', |
488 |
|
gateway='${GATEWAY}', |
489 |
|
broadcast='${BROADCAST}', |
490 |
|
ip='${IP}', |
491 |
|
forcemacto='${FORCE_MAC_TO}', |
492 |
|
wireless_bitrate='${WIRELESS_BITRATE}', |
493 |
|
wireless_channel='${WIRELESS_CHANNEL}', |
494 |
|
wireless_essid='${WIRELESS_ESSID}', |
495 |
|
wireless_frequency='${WIRELESS_FREQUENCY}', |
496 |
|
wireless_mode='${WIRELESS_MODE}', |
497 |
|
wireless_nick='${WIRELESS_NICK}', |
498 |
|
wireless_auth_mode='${WIRELESS_AUTH_MODE}', |
499 |
|
wireless_key_length='${WIRELESS_KEY_LENGTH}', |
500 |
|
wireless_key='${WIRELESS_KEY}', |
501 |
|
wireless_key_ascii='${WIRELESS_KEY_ASCII}' |
502 |
|
where serial=${ALX_SERIAL};" |
503 |
|
|
504 |
|
# only insert the *FIRST* iface |
505 |
|
break |
506 |
|
done |
507 |
|
else |
508 |
|
mysqldo "update cfg_network set |
509 |
|
hostname='${ALX_DEFAULT_HOSTNAME}', |
510 |
|
module='${NETCARD_DRIVER}', |
511 |
|
domain='${ALX_DEFAULT_DOMAIN}', |
512 |
|
networking='dhcp' |
513 |
|
where serial=${ALX_SERIAL};" |
514 |
|
fi |
515 |
evaluate_retval |
evaluate_retval |
516 |
|
|
517 |
# xserver |
# xserver |
518 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
519 |
# xserver general |
# xserver general |
520 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "update cfg_graphic set |
|
"update cfg_graphic set |
|
521 |
module='${XMODULE}', |
module='${XMODULE}', |
522 |
resolution='1024x768', |
resolution='1024x768', |
523 |
depth='16', |
depth='16', |
524 |
monitorid='0' |
refresh_rate='60' |
525 |
where serial=${ALX_SERIAL};" |
where serial=${ALX_SERIAL};" |
526 |
evaluate_retval |
evaluate_retval |
527 |
|
|
528 |
# input |
# input |
529 |
echo -e " Input settings ..." |
echo -e " Input settings ..." |
530 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};" |
|
"update cfg_input set |
|
|
mouse='${XMOUSETYPE}' |
|
|
where serial=${ALX_SERIAL};" |
|
531 |
evaluate_retval |
evaluate_retval |
532 |
|
|
533 |
|
# version info |
534 |
|
local alx_os |
535 |
|
local alx_utils |
536 |
|
alx_os="$(< /etc/mageversion)" |
537 |
|
alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" |
538 |
|
alx_utils="${alx_utils/alxconfig-ng-alx-}" |
539 |
|
mysqldo "update client_version set os='${alx_os}', utils='${alx_utils}' where serial=${ALX_SERIAL};" |
540 |
} |
} |
541 |
|
|
542 |
# imports current settings to the local system resolved by the hardware detection |
# imports current settings to the local system resolved by the hardware detection |
543 |
# we only need the network settings |
# we only need the network settings |
544 |
import_settings_local(){ |
import_settings_local() |
545 |
|
{ |
546 |
# note: networking is always 'dhcp' if hw was autodetected |
# note: networking is always 'dhcp' if hw was autodetected |
547 |
# note: default_domain/hostname is set in config.rc |
# note: default_domain/hostname is set in config.rc |
548 |
|
|
561 |
echo |
echo |
562 |
echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} |
563 |
|
|
564 |
[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
if [[ ${ALX_CONFD_NETWORKING} = false ]] |
565 |
echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules |
then |
566 |
evaluate_retval |
#[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
567 |
|
#echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules |
568 |
|
|
569 |
|
# set an device alias for modprobe.conf |
570 |
|
[ ! -d /etc/modules.d ] && install -d /etc/modules.d |
571 |
|
echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0 |
572 |
|
|
573 |
|
# regenerate modprobe.conf |
574 |
|
[ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf" |
575 |
|
evaluate_retval |
576 |
|
fi |
577 |
|
|
578 |
# set system state to 'already configured' |
# set system state to 'already configured' |
579 |
touch /etc/alxconfig-ng/state/configured |
touch /etc/alxconfig-ng/state/configured |
580 |
|
|
581 |
|
# if only an recheck was forced than abort now |
582 |
|
[[ ${ALX_FORCED_RECHECK} = true ]] && return 0 |
583 |
|
|
584 |
# create a fresh fluxbox directory |
# create a fresh fluxbox directory |
585 |
[ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox |
[ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox |
586 |
install -d ${ALX_UNPRIV_HOME}/.fluxbox |
install -d ${ALX_UNPRIV_HOME}/.fluxbox |
591 |
cat ${ALX_SKELETONS}/fluxbox/init \ |
cat ${ALX_SKELETONS}/fluxbox/init \ |
592 |
> ${ALX_UNPRIV_HOME}/.fluxbox/init |
> ${ALX_UNPRIV_HOME}/.fluxbox/init |
593 |
|
|
594 |
|
# fluxbox autostart |
595 |
|
cat ${ALX_SKELETONS}/fluxbox/apps \ |
596 |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
597 |
|
|
598 |
# fluxbox menu header |
# fluxbox menu header |
599 |
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
600 |
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
601 |
|
|
602 |
|
# now fix it with proper messages :P |
603 |
|
local ver="$(< /etc/mageversion)" |
604 |
|
sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" \ |
605 |
|
${ALX_UNPRIV_HOME}/.fluxbox/menu |
606 |
|
|
607 |
# add a newline (maybe there is no crlf in the header) |
# add a newline (maybe there is no crlf in the header) |
608 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
609 |
|
|
614 |
# add a newline (maybe there is no crlf in the footer) |
# add a newline (maybe there is no crlf in the footer) |
615 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
616 |
|
|
617 |
|
|
618 |
|
# setup some standart icons (sysinfo.lnk) |
619 |
|
# basic config |
620 |
|
cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc |
621 |
|
|
622 |
|
# clean desktop icon location |
623 |
|
[ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop |
624 |
|
install -d ${ALX_UNPRIV_HOME}/.xtdesktop |
625 |
|
|
626 |
|
# last but not least gen a icon with some sys informations |
627 |
|
local sysinfo |
628 |
|
local osversion |
629 |
|
local xres |
630 |
|
local yres |
631 |
|
|
632 |
|
osversion="$(< /etc/mageversion)" |
633 |
|
sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
634 |
|
|
635 |
|
# at first boot we got always a resolution of 1024x768-16@60 |
636 |
|
# middle of the screen |
637 |
|
# (no txt - length required, xtdesk manage that itself) |
638 |
|
xres="$((1024 / 2))" |
639 |
|
# default y pos (full yres -22 !) |
640 |
|
yres="$((768 - 22 ))" |
641 |
|
|
642 |
|
generate_icon \ |
643 |
|
--name "${sysinfo}" \ |
644 |
|
--command "exit 0" \ |
645 |
|
--icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ |
646 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ |
647 |
|
--xres "${xres}" \ |
648 |
|
--yres "${yres}" \ |
649 |
|
--icon-width "1" \ |
650 |
|
--icon-height "1" |
651 |
|
|
652 |
|
# create a xinitrc |
653 |
|
echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc |
654 |
|
|
655 |
# set correct permissions |
# set correct permissions |
656 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
657 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
658 |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
659 |
|
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
660 |
# default passwords are bad |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
661 |
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") root |
chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc |
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER} |
|
|
#smbpasswd -a root foobar |
|
662 |
} |
} |
663 |
|
|
664 |
# start|stop |
# start|stop |
665 |
preliminary_network(){ |
preliminary_network() |
666 |
|
{ |
667 |
local module |
local module |
668 |
|
|
669 |
if [ -f /etc/alxconfig-ng/state/configured ] |
if [ -f /etc/alxconfig-ng/state/configured ] |
670 |
then |
then |
671 |
# get module name |
# compat for old clients |
672 |
module=$(cat ${SETTINGSPATH}/modules) |
if [ -f ${SETTINGSPATH}/modules ] |
673 |
modprobe ${module} |
then |
674 |
|
# get module name |
675 |
|
module=$(cat ${SETTINGSPATH}/modules) |
676 |
|
modprobe ${module} |
677 |
|
fi |
678 |
else |
else |
679 |
# vars used by hwdetect |
# vars used by hwdetect |
680 |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
698 |
else |
else |
699 |
rm -f /var/run/dhcpcd-eth?.pid |
rm -f /var/run/dhcpcd-eth?.pid |
700 |
fi |
fi |
701 |
|
[[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \ |
702 |
|
${rc_base}/init.d/network stop |
703 |
|
|
704 |
echo -e ${COLMAGENTA}"Starting preliminary network ... "${COLDEFAULT} |
echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} |
|
# -t 10 timeout of 10 secs |
|
|
dhcpcd -t 10 &> /dev/null |
|
|
|
|
|
# aka_fix ######################################## |
|
|
#ifconfig eth0 128.20.222.222 netmask 255.255.0.0 up |
|
|
#route del default gw 128.20.50.13 &> /dev/null |
|
|
#route add default gw 128.20.50.21 &> /dev/null |
|
|
#echo "nameserver 128.20.50.21" > /etc/resolv.conf |
|
|
################################################## |
|
705 |
|
|
706 |
evaluate_retval |
# start network configured from /etc/conf.d |
707 |
|
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
708 |
|
then |
709 |
|
${rc_base}/init.d/network start |
710 |
|
else |
711 |
|
echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT} |
712 |
|
# -t 10 timeout of 10 secs |
713 |
|
dhcpcd -t 10 &> /dev/null |
714 |
|
evaluate_retval |
715 |
|
fi |
716 |
;; |
;; |
717 |
|
|
718 |
stop) |
stop) |
719 |
echo -e ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT} |
echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT} |
720 |
ifconfig eth0 down |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
721 |
|
then |
722 |
|
${rc_base}/init.d/network stop |
723 |
|
else |
724 |
|
echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT} |
725 |
|
ifconfig eth0 down |
726 |
|
fi |
727 |
if ps -A|grep dhcpcd > /dev/null |
if ps -A|grep dhcpcd > /dev/null |
728 |
then |
then |
729 |
dhcpcd -z &> /dev/null |
dhcpcd -z &> /dev/null |
737 |
esac |
esac |
738 |
} |
} |
739 |
|
|
740 |
|
reset_system_settings() |
741 |
|
{ |
742 |
|
# force load of de kbdkeys |
743 |
|
loadkeys -q de |
744 |
|
echo |
745 |
|
echo -en ${COLRED} |
746 |
|
echo -n "*** Warning: you are about to reset *all* local settings on this system!" |
747 |
|
echo -e ${COLDEFAULT} |
748 |
|
echo "*** Do you really want to continue ?" |
749 |
|
echo -n "*** Enter 'yes' to continue, anything else to abort: " |
750 |
|
read kbinsert |
751 |
|
if [[ ${kbinsert} = yes ]] |
752 |
|
then |
753 |
|
echo -en ${COLRED} |
754 |
|
echo -n "*** OK, you really want it ... killing all settings: " |
755 |
|
for i in 3 2 1 now |
756 |
|
do |
757 |
|
echo -n " ${i}" |
758 |
|
sleep 1 |
759 |
|
done |
760 |
|
echo -e ${COLDEFAULT} |
761 |
|
|
762 |
|
## reset all settings: |
763 |
|
rm -rf ${SETTINGSPATH}/* |
764 |
|
rm -f /etc/alxconfig-ng/serial |
765 |
|
rm -rf /etc/alxconfig-ng/state |
766 |
|
|
767 |
|
# clear all printers & net-shares |
768 |
|
:> /etc/cups/printers.conf |
769 |
|
:> /etc/samba/smb.conf |
770 |
|
|
771 |
|
# remove inetd, cups & smb from init |
772 |
|
rc-config del inetd &> /dev/null |
773 |
|
rc-config del cups &> /dev/null |
774 |
|
rc-config del samba &> /dev/null |
775 |
|
|
776 |
|
# remove all user settings |
777 |
|
[ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} |
778 |
|
|
779 |
|
# remove all ica-sessions |
780 |
|
find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm |
781 |
|
|
782 |
|
# remove all old nics and modules configs |
783 |
|
find /etc/conf.d -type f -name 'net.*' | xargs rm |
784 |
|
find /etc/modules.d -type f -name 'net.*' | xargs rm |
785 |
|
|
786 |
|
# restore default networking |
787 |
|
cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 |
788 |
|
|
789 |
|
echo "I am done now, press [Enter] to reboot system ..." |
790 |
|
else |
791 |
|
echo "Aborted, press [Enter] to reboot system ..." |
792 |
|
fi |
793 |
|
read |
794 |
|
reboot |
795 |
|
} |
796 |
|
|
797 |
|
onboot_interface_list() |
798 |
|
{ |
799 |
|
local file |
800 |
|
local devices |
801 |
|
local iface |
802 |
|
|
803 |
|
# get list of all devices |
804 |
|
for file in $@ |
805 |
|
do |
806 |
|
if [[ $(read_value ONBOOT ${file}) = yes ]] |
807 |
|
then |
808 |
|
iface="$(basename ${file} | sed s/net.//)" |
809 |
|
# exclude backup files |
810 |
|
case "${iface}" in |
811 |
|
*~) ;; |
812 |
|
*) devices="${devices} $(basename ${file} | sed s/net.//)" ;; |
813 |
|
esac |
814 |
|
fi |
815 |
|
done |
816 |
|
|
817 |
|
echo "${devices}" |
818 |
|
} |
819 |
|
|
820 |
|
# read values from net.* files |
821 |
|
read_value() |
822 |
|
{ |
823 |
|
local var="$1" |
824 |
|
local file="$2" |
825 |
|
local value |
826 |
|
|
827 |
|
# local all possible vars |
828 |
|
# global |
829 |
|
local ONBOOT |
830 |
|
local NETWORKING |
831 |
|
|
832 |
|
# static |
833 |
|
local IP |
834 |
|
local NETMASK |
835 |
|
local BROADCAST |
836 |
|
local NETWORKING |
837 |
|
local FORCE_MAC_TO |
838 |
|
|
839 |
|
# dhcp |
840 |
|
local DHCP_PROG |
841 |
|
local DHCP_START |
842 |
|
local DHCP_STOP |
843 |
|
|
844 |
|
# default gw |
845 |
|
local GATEWAY |
846 |
|
local GATEWAY_IF |
847 |
|
|
848 |
|
# wireless extensions |
849 |
|
local WIRELESS_AP |
850 |
|
local WIRELESS_AUTH_MODE |
851 |
|
local WIRELESS_BITRATE |
852 |
|
local WIRELESS_CHANNEL |
853 |
|
local WIRELESS_DEFAULT_KEY |
854 |
|
local WIRELESS_ESSID |
855 |
|
local WIRELESS_FREQUENCY |
856 |
|
local WIRELESS_KEY |
857 |
|
local WIRELESS_KEY_ASCII |
858 |
|
local WIRELESS_KEY_0 |
859 |
|
local WIRELESS_KEY_1 |
860 |
|
local WIRELESS_KEY_2 |
861 |
|
local WIRELESS_KEY_3 |
862 |
|
local WIRELESS_KEY_LENGTH |
863 |
|
local WIRELESS_MODE |
864 |
|
local WIRELESS_NICK |
865 |
|
local WIRELESS_NWID |
866 |
|
local WIRELESS_POWER |
867 |
|
|
868 |
|
source ${file} |
869 |
|
eval value=\$$(echo ${var}) |
870 |
|
echo "${value}" |
871 |
|
} |
872 |
|
|
873 |
case $1 in |
case $1 in |
874 |
start) |
start) |
875 |
|
# check for global overrides |
876 |
|
[ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true |
877 |
|
[ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true |
878 |
|
read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true |
879 |
|
read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true |
880 |
|
|
881 |
|
# kill all settings if requested |
882 |
|
if [[ ${ALX_RESET_SETTINGS} = true ]] |
883 |
|
then |
884 |
|
reset_system_settings |
885 |
|
fi |
886 |
|
|
887 |
# retrieve or validate current serial |
# retrieve or validate current serial |
888 |
get_system_serial |
get_system_serial |
889 |
if [[ ${ALX_HW_DETECT} = true ]] |
if [[ ${ALX_HW_DETECT} = true ]] |
904 |
|
|
905 |
# now setup system configuration |
# now setup system configuration |
906 |
# alx_setup_or_whatever_it_will_be_called() |
# alx_setup_or_whatever_it_will_be_called() |
907 |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
[[ ${ALX_HW_DETECT} = false ]] && update_system_settings |
908 |
|
|
909 |
# stop at last the preliminary networking (dhcp) |
# stop at last the preliminary networking (dhcp) |
910 |
preliminary_network stop |
preliminary_network stop |