11 |
#%before: |
#%before: |
12 |
#%after: |
#%after: |
13 |
|
|
14 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.17 2005-08-18 08:10:46 niro Exp $ |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.23 2005-10-09 21:38:14 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 |
44 |
# other needed vars |
# other needed vars |
45 |
ALX_HW_DETECT=false |
ALX_HW_DETECT=false |
46 |
ALX_FORCED_RECHECK=false |
ALX_FORCED_RECHECK=false |
47 |
|
ALX_RESET_SETTINGS=false |
48 |
|
ALX_CONFD_NETWORKING=false |
49 |
|
|
50 |
# unset vars which may kill us |
# unset vars which may kill us |
51 |
unset ALX_SERIAL ALX_STATE |
unset ALX_SERIAL ALX_STATE |
55 |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
56 |
|
|
57 |
|
|
58 |
update_system_settings(){ |
# read_cmdline ${item} |
59 |
|
read_cmdline() |
60 |
|
{ |
61 |
|
local i |
62 |
|
|
63 |
|
for i in $(< /proc/cmdline) |
64 |
|
do |
65 |
|
[[ ${i} = $1 ]] && return 0 |
66 |
|
done |
67 |
|
|
68 |
|
return 1 |
69 |
|
} |
70 |
|
|
71 |
|
update_system_settings() |
72 |
|
{ |
73 |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
74 |
|
|
75 |
# get the modules settings |
# get the modules settings |
95 |
HOME=/root config_ssh_auth |
HOME=/root config_ssh_auth |
96 |
} |
} |
97 |
|
|
98 |
get_system_serial(){ |
get_system_serial() |
99 |
|
{ |
100 |
local CUR_IP CUR_MAC CUR_MTIME |
local CUR_IP CUR_MAC CUR_MTIME |
101 |
|
|
102 |
# check if serial file exists |
# check if serial file exists |
103 |
if [ -f /etc/alxconfig-ng/serial ] && [ ! -f /hardware-auto-detection ] |
if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]] |
104 |
then |
then |
105 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
106 |
|
|
115 |
exit 1 |
exit 1 |
116 |
fi |
fi |
117 |
|
|
118 |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') |
119 |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) |
120 |
CUR_MTIME=$(date +%s) |
CUR_MTIME=$(date +%s) |
121 |
|
|
122 |
echo -e ${COLOREDSTAR} "Trying to validate my serial ..." |
echo -e ${COLOREDSTAR} "Trying to validate my serial ..." |
130 |
then |
then |
131 |
ALX_STATE="ok" |
ALX_STATE="ok" |
132 |
else |
else |
133 |
|
# abort on non valid serial |
134 |
ALX_STATE="invalid serial" |
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 |
fi |
139 |
|
|
140 |
else |
else |
141 |
# run hardware detection |
# run hardware detection |
142 |
echo |
echo |
143 |
if [ -f /hardware-auto-detection ] |
if [[ ${ALX_FORCED_RECHECK} = true ]] |
144 |
then |
then |
145 |
echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} |
146 |
else |
else |
151 |
|
|
152 |
# set hostname to alx_default_hostname |
# set hostname to alx_default_hostname |
153 |
# use old hostname if this is a forced re-check |
# use old hostname if this is a forced re-check |
154 |
[ -f /hardware-auto-detection ] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)" |
[[ ${ALX_FORCED_RECHECK} = true ]] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)" |
155 |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
156 |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
157 |
|
|
174 |
CUR_MTIME=$(date +%s) |
CUR_MTIME=$(date +%s) |
175 |
|
|
176 |
# abort now if this is a forced re-check |
# abort now if this is a forced re-check |
177 |
if [ -f /hardware-auto-detection ] |
if [[ ${ALX_FORCED_RECHECK} = true ]] |
178 |
then |
then |
179 |
# but first check the serial |
# but first check the serial |
180 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
190 |
then |
then |
191 |
ALX_STATE="ok" |
ALX_STATE="ok" |
192 |
else |
else |
193 |
|
# abort on non valid serial |
194 |
ALX_STATE="invalid serial" |
ALX_STATE="invalid serial" |
195 |
|
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
196 |
|
show_invalid_serial_msg |
197 |
|
exit 1 |
198 |
fi |
fi |
199 |
|
|
200 |
# write current state to temp file |
# write current state to temp file |
201 |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
202 |
rm /hardware-auto-detection |
[ -f /hardware-auto-detection ] && rm /hardware-auto-detection |
203 |
|
|
204 |
# now export ALX_FORCED_RECHECK=true |
# now export ALX_FORCED_RECHECK=true |
205 |
# that the setting will be updated not inserted ! |
# that the setting will be updated not inserted ! |
209 |
|
|
210 |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
211 |
|
|
212 |
# request new serial |
# request a new serial; one command now (cause must be done in the same session) |
213 |
# ALX_REG_DATE="$(date +%F)" |
ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); |
214 |
|
select last_insert_id();") |
215 |
|
|
216 |
# 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 ] |
|
217 |
then |
then |
218 |
# nice serial output |
# nice serial output |
219 |
$CURS_UP |
$CURS_UP |
220 |
$SET_WCOL |
$SET_WCOL |
221 |
echo "[ SN: ${ALX_SERIAL} ]" |
echo "[ SN: ${ALX_SERIAL} ]" |
222 |
|
|
223 |
# set ALX_STATE to ok so everybody that everything was ok |
# set ALX_STATE to ok so everybody knows that everything was ok |
224 |
ALX_STATE=ok |
ALX_STATE=ok |
225 |
|
|
226 |
echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial |
echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial |
244 |
|
|
245 |
# write current state to temp file |
# write current state to temp file |
246 |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
247 |
|
echo "ALX_IFACE=${ALX_IFACE}" >> /etc/alxconfig-ng/state/state |
248 |
} |
} |
249 |
|
|
250 |
|
|
251 |
check_is_configured() { |
check_is_configured() |
252 |
|
{ |
253 |
if [ -f /etc/alxconfig-ng/state/configured ] |
if [ -f /etc/alxconfig-ng/state/configured ] |
254 |
then |
then |
255 |
export ALX_CONFIGURED=true |
export ALX_CONFIGURED=true |
260 |
|
|
261 |
|
|
262 |
# imports current settings to the database resolved by the hardware detection |
# imports current settings to the database resolved by the hardware detection |
263 |
import_settings_to_db() { |
import_settings_to_db() |
264 |
|
{ |
265 |
# note: networking is always 'dhcp' if hw was autodetected |
# note: networking is always 'dhcp' if hw was autodetected |
266 |
# note: default_domain/hostname is set in config.rc |
# note: default_domain/hostname is set in config.rc |
267 |
|
|
283 |
|
|
284 |
# network |
# network |
285 |
echo -e " Network settings ..." |
echo -e " Network settings ..." |
286 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
287 |
"insert into cfg_network( |
then |
288 |
hostname, |
# get settings |
289 |
serial, |
#source ${rc_base}/init.d/network &> /dev/null |
290 |
module, |
for iface in $(onboot_interface_list ${network_settings}/net.*) |
291 |
domain, |
do |
292 |
networking |
[[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue |
293 |
) |
echo "WARNING: only importing settings for interface [ ${iface} ] !" |
294 |
values( |
source ${network_settings}/net.${iface} || exit 1 |
295 |
'${ALX_DEFAULT_HOSTNAME}', |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
296 |
'${ALX_SERIAL}', |
|
297 |
'${NETCARD_DRIVER}', |
mysqldo "insert into cfg_network( |
298 |
'${ALX_DEFAULT_DOMAIN}', |
hostname, |
299 |
'dhcp' |
serial, |
300 |
);" |
module, |
301 |
|
domain, |
302 |
|
networking, |
303 |
|
netmask, |
304 |
|
dns, |
305 |
|
gateway, |
306 |
|
broadcast, |
307 |
|
ip, |
308 |
|
forcemacto, |
309 |
|
wireless_bitrate, |
310 |
|
wireless_channel, |
311 |
|
wireless_essid, |
312 |
|
wireless_frequency, |
313 |
|
wireless_mode, |
314 |
|
wireless_nick, |
315 |
|
wireless_auth_mode, |
316 |
|
wireless_key_length, |
317 |
|
wireless_key, |
318 |
|
wireless_key_ascii |
319 |
|
) |
320 |
|
values( |
321 |
|
'${ALX_DEFAULT_HOSTNAME}', |
322 |
|
'${ALX_SERIAL}', |
323 |
|
'${NETCARD_DRIVER}', |
324 |
|
'${ALX_DEFAULT_DOMAIN}', |
325 |
|
'${NETWORKING}', |
326 |
|
'${NETMASK}', |
327 |
|
'${NAMESERVER}', |
328 |
|
'${GATEWAY}', |
329 |
|
'${BROADCAST}', |
330 |
|
'${IP}', |
331 |
|
'${FORCE_MAC_TO}', |
332 |
|
'${WIRELESS_BITRATE}', |
333 |
|
'${WIRELESS_CHANNEL}', |
334 |
|
'${WIRELESS_ESSID}', |
335 |
|
'${WIRELESS_FREQUENCY}', |
336 |
|
'${WIRELESS_MODE}', |
337 |
|
'${WIRELESS_NICK}', |
338 |
|
'${WIRELESS_AUTH_MODE}', |
339 |
|
'${WIRELESS_KEY_LENGTH}', |
340 |
|
'${WIRELESS_KEY}', |
341 |
|
'${WIRELESS_KEY_ASCII}' |
342 |
|
);" |
343 |
|
|
344 |
|
# only insert the *FIRST* iface |
345 |
|
break |
346 |
|
done |
347 |
|
else |
348 |
|
mysqldo "insert into cfg_network( |
349 |
|
hostname, |
350 |
|
serial, |
351 |
|
module, |
352 |
|
domain, |
353 |
|
networking |
354 |
|
) |
355 |
|
values( |
356 |
|
'${ALX_DEFAULT_HOSTNAME}', |
357 |
|
'${ALX_SERIAL}', |
358 |
|
'${NETCARD_DRIVER}', |
359 |
|
'${ALX_DEFAULT_DOMAIN}', |
360 |
|
'dhcp' |
361 |
|
);" |
362 |
|
fi |
363 |
evaluate_retval |
evaluate_retval |
364 |
|
|
365 |
# xserver |
# xserver |
366 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
367 |
# xserver general |
# xserver general |
368 |
( mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
( mysqldo "insert into cfg_graphic( |
|
"insert into cfg_graphic( |
|
369 |
serial, |
serial, |
370 |
module, |
module, |
371 |
resolution, |
resolution, |
383 |
|
|
384 |
# input |
# input |
385 |
echo -e " Input settings ..." |
echo -e " Input settings ..." |
386 |
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}');" |
|
387 |
evaluate_retval |
evaluate_retval |
388 |
|
|
389 |
# auth |
# auth |
390 |
echo -e " Authentifcation settings ..." |
echo -e " Authentification settings ..." |
391 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into client_auth( |
|
"insert into client_auth( |
|
392 |
serial, |
serial, |
393 |
username, |
username, |
394 |
shell, |
shell, |
408 |
|
|
409 |
# exchange ssh rsa keys - the first boot needs this ! |
# exchange ssh rsa keys - the first boot needs this ! |
410 |
# or no reboot will work via the webadmin |
# or no reboot will work via the webadmin |
411 |
echo -e " SSH authentifcation settings ..." |
echo -e " SSH authentification settings ..." |
412 |
HOME=/root config_ssh_auth |
HOME=/root config_ssh_auth |
413 |
evaluate_retval |
evaluate_retval |
414 |
|
|
415 |
# input |
# autostart |
416 |
echo -e " Autostart settings ..." |
echo -e " Autostart settings ..." |
417 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
418 |
"insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
|
419 |
|
# screensaver |
420 |
|
echo -e " Screensaver settings ..." |
421 |
|
mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" |
422 |
|
|
423 |
evaluate_retval |
evaluate_retval |
424 |
} |
} |
425 |
|
|
426 |
# imports current settings to the database resolved by the hardware detection |
# imports current settings to the database resolved by the hardware detection |
427 |
update_settings_in_db() { |
update_settings_in_db() |
428 |
|
{ |
429 |
# note: networking is always 'dhcp' if hw was autodetected |
# note: networking is always 'dhcp' if hw was autodetected |
430 |
# note: default_domain/hostname is set in config.rc or exported |
# note: default_domain/hostname is set in config.rc or exported |
431 |
# note: we updating only hardware settings here ! |
# note: we updating only hardware settings here ! |
448 |
|
|
449 |
# network |
# network |
450 |
echo -e " Network settings ..." |
echo -e " Network settings ..." |
451 |
|
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
452 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
then |
453 |
"update cfg_network set |
# get settings |
454 |
hostname='${ALX_DEFAULT_HOSTNAME}', |
#source ${rc_base}/init.d/network &> /dev/null |
455 |
module='${NETCARD_DRIVER}', |
for iface in $(onboot_interface_list ${network_settings}/net.*) |
456 |
domain='${ALX_DEFAULT_DOMAIN}', |
do |
457 |
networking='dhcp' |
[[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue |
458 |
where serial=${ALX_SERIAL};" |
echo "WARNING: only importing settings for interface [ ${iface} ] !" |
459 |
|
source ${network_settings}/net.${iface} || exit 1 |
460 |
|
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
461 |
|
|
462 |
|
mysqldo "update cfg_network set |
463 |
|
hostname='${ALX_DEFAULT_HOSTNAME}', |
464 |
|
module='${NETCARD_DRIVER}', |
465 |
|
domain='${ALX_DEFAULT_DOMAIN}', |
466 |
|
networking='${NETWORKING}', |
467 |
|
netmask='${NETMASK}', |
468 |
|
dns='${NAMESERVER}', |
469 |
|
gateway='${GATEWAY}', |
470 |
|
broadcast='${BROADCAST}', |
471 |
|
ip='${IP}', |
472 |
|
forcemacto='${FORCE_MAC_TO}', |
473 |
|
wireless_bitrate='${WIRELESS_BITRATE}', |
474 |
|
wireless_channel='${WIRELESS_CHANNEL}', |
475 |
|
wireless_essid='${WIRELESS_ESSID}', |
476 |
|
wireless_frequency='${WIRELESS_FREQUENCY}', |
477 |
|
wireless_mode='${WIRELESS_MODE}', |
478 |
|
wireless_nick='${WIRELESS_NICK}', |
479 |
|
wireless_auth_mode='${WIRELESS_AUTH_MODE}', |
480 |
|
wireless_key_length='${WIRELESS_KEY_LENGTH}', |
481 |
|
wireless_key='${WIRELESS_KEY}', |
482 |
|
wireless_key_ascii='${WIRELESS_KEY_ASCII}' |
483 |
|
where serial=${ALX_SERIAL};" |
484 |
|
|
485 |
|
# only insert the *FIRST* iface |
486 |
|
break |
487 |
|
done |
488 |
|
else |
489 |
|
mysqldo "update cfg_network set |
490 |
|
hostname='${ALX_DEFAULT_HOSTNAME}', |
491 |
|
module='${NETCARD_DRIVER}', |
492 |
|
domain='${ALX_DEFAULT_DOMAIN}', |
493 |
|
networking='dhcp' |
494 |
|
where serial=${ALX_SERIAL};" |
495 |
|
fi |
496 |
evaluate_retval |
evaluate_retval |
497 |
|
|
498 |
# xserver |
# xserver |
499 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
500 |
# xserver general |
# xserver general |
501 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "update cfg_graphic set |
|
"update cfg_graphic set |
|
502 |
module='${XMODULE}', |
module='${XMODULE}', |
503 |
resolution='1024x768', |
resolution='1024x768', |
504 |
depth='16', |
depth='16', |
508 |
|
|
509 |
# input |
# input |
510 |
echo -e " Input settings ..." |
echo -e " Input settings ..." |
511 |
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};" |
|
512 |
evaluate_retval |
evaluate_retval |
513 |
} |
} |
514 |
|
|
515 |
# imports current settings to the local system resolved by the hardware detection |
# imports current settings to the local system resolved by the hardware detection |
516 |
# we only need the network settings |
# we only need the network settings |
517 |
import_settings_local(){ |
import_settings_local() |
518 |
|
{ |
519 |
# note: networking is always 'dhcp' if hw was autodetected |
# note: networking is always 'dhcp' if hw was autodetected |
520 |
# note: default_domain/hostname is set in config.rc |
# note: default_domain/hostname is set in config.rc |
521 |
|
|
534 |
echo |
echo |
535 |
echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} |
536 |
|
|
537 |
[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
if [[ ${ALX_CONFD_NETWORKING} = false ]] |
538 |
echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules |
then |
539 |
evaluate_retval |
#[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
540 |
|
#echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules |
541 |
|
|
542 |
|
# set an device alias for modprobe.conf |
543 |
|
[ ! -d /etc/modules.d ] && install -d /etc/modules.d |
544 |
|
echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0 |
545 |
|
|
546 |
|
# regenerate modprobe.conf |
547 |
|
[ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf" |
548 |
|
evaluate_retval |
549 |
|
fi |
550 |
|
|
551 |
# set system state to 'already configured' |
# set system state to 'already configured' |
552 |
touch /etc/alxconfig-ng/state/configured |
touch /etc/alxconfig-ng/state/configured |
553 |
|
|
554 |
|
# if only an recheck was forced than abort now |
555 |
|
[[ ${ALX_FORCED_RECHECK} = true ]] && return 0 |
556 |
|
|
557 |
# create a fresh fluxbox directory |
# create a fresh fluxbox directory |
558 |
[ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox |
[ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox |
559 |
install -d ${ALX_UNPRIV_HOME}/.fluxbox |
install -d ${ALX_UNPRIV_HOME}/.fluxbox |
564 |
cat ${ALX_SKELETONS}/fluxbox/init \ |
cat ${ALX_SKELETONS}/fluxbox/init \ |
565 |
> ${ALX_UNPRIV_HOME}/.fluxbox/init |
> ${ALX_UNPRIV_HOME}/.fluxbox/init |
566 |
|
|
567 |
|
# fluxbox autostart |
568 |
|
cat ${ALX_SKELETONS}/fluxbox/apps \ |
569 |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
570 |
|
|
571 |
# fluxbox menu header |
# fluxbox menu header |
572 |
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
573 |
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
587 |
# add a newline (maybe there is no crlf in the footer) |
# add a newline (maybe there is no crlf in the footer) |
588 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
589 |
|
|
590 |
|
|
591 |
|
# setup some standart icons (sysinfo.lnk) |
592 |
|
# basic config |
593 |
|
cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc |
594 |
|
|
595 |
|
# clean desktop icon location |
596 |
|
[ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop |
597 |
|
install -d ${ALX_UNPRIV_HOME}/.xtdesktop |
598 |
|
|
599 |
|
# last but not least gen a icon with some sys informations |
600 |
|
local sysinfo |
601 |
|
local osversion |
602 |
|
local xres |
603 |
|
local yres |
604 |
|
|
605 |
|
osversion="$(< /etc/mageversion)" |
606 |
|
sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
607 |
|
|
608 |
|
# at first boot we got always a resolution of 1024x768-16@60 |
609 |
|
# middle of the screen |
610 |
|
# (no txt - length required, xtdesk manage that itself) |
611 |
|
xres="$((1024 / 2))" |
612 |
|
# default y pos (full yres -22 !) |
613 |
|
yres="$((768 - 22 ))" |
614 |
|
|
615 |
|
generate_icon \ |
616 |
|
--name "${sysinfo}" \ |
617 |
|
--command "exit 0" \ |
618 |
|
--icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ |
619 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ |
620 |
|
--xres "${xres}" \ |
621 |
|
--yres "${yres}" \ |
622 |
|
--icon-width "1" \ |
623 |
|
--icon-height "1" |
624 |
|
|
625 |
# set correct permissions |
# set correct permissions |
626 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
627 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
628 |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
629 |
|
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
630 |
# default passwords are bad |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") root |
|
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER} |
|
|
#smbpasswd -a root foobar |
|
631 |
} |
} |
632 |
|
|
633 |
# start|stop |
# start|stop |
634 |
preliminary_network(){ |
preliminary_network() |
635 |
|
{ |
636 |
local module |
local module |
637 |
|
|
638 |
if [ -f /etc/alxconfig-ng/state/configured ] |
if [ -f /etc/alxconfig-ng/state/configured ] |
639 |
then |
then |
640 |
# get module name |
# compat for old clients |
641 |
module=$(cat ${SETTINGSPATH}/modules) |
if [ -f ${SETTINGSPATH}/modules ] |
642 |
modprobe ${module} |
then |
643 |
|
# get module name |
644 |
|
module=$(cat ${SETTINGSPATH}/modules) |
645 |
|
modprobe ${module} |
646 |
|
fi |
647 |
else |
else |
648 |
# vars used by hwdetect |
# vars used by hwdetect |
649 |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
667 |
else |
else |
668 |
rm -f /var/run/dhcpcd-eth?.pid |
rm -f /var/run/dhcpcd-eth?.pid |
669 |
fi |
fi |
670 |
|
[[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \ |
671 |
|
${rc_base}/init.d/network stop |
672 |
|
|
673 |
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 |
|
|
################################################## |
|
674 |
|
|
675 |
evaluate_retval |
# start network configured from /etc/conf.d |
676 |
|
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
677 |
|
then |
678 |
|
${rc_base}/init.d/network start |
679 |
|
else |
680 |
|
echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT} |
681 |
|
# -t 10 timeout of 10 secs |
682 |
|
dhcpcd -t 10 &> /dev/null |
683 |
|
evaluate_retval |
684 |
|
fi |
685 |
;; |
;; |
686 |
|
|
687 |
stop) |
stop) |
688 |
echo -e ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT} |
echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT} |
689 |
ifconfig eth0 down |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
690 |
|
then |
691 |
|
${rc_base}/init.d/network stop |
692 |
|
else |
693 |
|
echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT} |
694 |
|
ifconfig eth0 down |
695 |
|
fi |
696 |
if ps -A|grep dhcpcd > /dev/null |
if ps -A|grep dhcpcd > /dev/null |
697 |
then |
then |
698 |
dhcpcd -z &> /dev/null |
dhcpcd -z &> /dev/null |
706 |
esac |
esac |
707 |
} |
} |
708 |
|
|
709 |
|
reset_system_settings() |
710 |
|
{ |
711 |
|
# force load of de kbdkeys |
712 |
|
loadkeys -q de |
713 |
|
echo |
714 |
|
echo -en ${COLRED} |
715 |
|
echo -n "*** Warning: you are about to reset *all* local settings on this system!" |
716 |
|
echo -e ${COLDEFAULT} |
717 |
|
echo "*** Do you really want to continue ?" |
718 |
|
echo -n "*** Enter 'yes' to continue, anything else to abort: " |
719 |
|
read kbinsert |
720 |
|
if [[ ${kbinsert} = yes ]] |
721 |
|
then |
722 |
|
echo -en ${COLRED} |
723 |
|
echo -n "*** OK, you really want it ... killing all settings: " |
724 |
|
for i in 3 2 1 now |
725 |
|
do |
726 |
|
echo -n " ${i}" |
727 |
|
sleep 1 |
728 |
|
done |
729 |
|
echo -e ${COLDEFAULT} |
730 |
|
|
731 |
|
## reset all settings: |
732 |
|
rm -rf ${SETTINGSPATH}/* |
733 |
|
rm -f /etc/alxconfig-ng/serial |
734 |
|
rm -rf /etc/alxconfig-ng/state |
735 |
|
|
736 |
|
echo "I am done now, press [Enter] to reboot system ..." |
737 |
|
else |
738 |
|
echo "Aborted, press [Enter] to reboot system ..." |
739 |
|
fi |
740 |
|
read |
741 |
|
reboot |
742 |
|
} |
743 |
|
|
744 |
|
onboot_interface_list() |
745 |
|
{ |
746 |
|
local file |
747 |
|
local devices |
748 |
|
local iface |
749 |
|
|
750 |
|
# get list of all devices |
751 |
|
for file in $@ |
752 |
|
do |
753 |
|
if [[ $(read_value ONBOOT ${file}) = yes ]] |
754 |
|
then |
755 |
|
iface="$(basename ${file} | sed s/net.//)" |
756 |
|
# exclude backup files |
757 |
|
case "${iface}" in |
758 |
|
*~) ;; |
759 |
|
*) devices="${devices} $(basename ${file} | sed s/net.//)" ;; |
760 |
|
esac |
761 |
|
fi |
762 |
|
done |
763 |
|
|
764 |
|
echo "${devices}" |
765 |
|
} |
766 |
|
|
767 |
|
# read values from net.* files |
768 |
|
read_value() |
769 |
|
{ |
770 |
|
local var="$1" |
771 |
|
local file="$2" |
772 |
|
local value |
773 |
|
|
774 |
|
# local all possible vars |
775 |
|
# global |
776 |
|
local ONBOOT |
777 |
|
local NETWORKING |
778 |
|
|
779 |
|
# static |
780 |
|
local IP |
781 |
|
local NETMASK |
782 |
|
local BROADCAST |
783 |
|
local NETWORKING |
784 |
|
local FORCE_MAC_TO |
785 |
|
|
786 |
|
# dhcp |
787 |
|
local DHCP_PROG |
788 |
|
local DHCP_START |
789 |
|
local DHCP_STOP |
790 |
|
|
791 |
|
# default gw |
792 |
|
local GATEWAY |
793 |
|
local GATEWAY_IF |
794 |
|
|
795 |
|
# wireless extensions |
796 |
|
local WIRELESS_AP |
797 |
|
local WIRELESS_AUTH_MODE |
798 |
|
local WIRELESS_BITRATE |
799 |
|
local WIRELESS_CHANNEL |
800 |
|
local WIRELESS_DEFAULT_KEY |
801 |
|
local WIRELESS_ESSID |
802 |
|
local WIRELESS_FREQUENCY |
803 |
|
local WIRELESS_KEY |
804 |
|
local WIRELESS_KEY_ASCII |
805 |
|
local WIRELESS_KEY_0 |
806 |
|
local WIRELESS_KEY_1 |
807 |
|
local WIRELESS_KEY_2 |
808 |
|
local WIRELESS_KEY_3 |
809 |
|
local WIRELESS_KEY_LENGTH |
810 |
|
local WIRELESS_MODE |
811 |
|
local WIRELESS_NICK |
812 |
|
local WIRELESS_NWID |
813 |
|
local WIRELESS_POWER |
814 |
|
|
815 |
|
source ${file} |
816 |
|
eval value=\$$(echo ${var}) |
817 |
|
echo "${value}" |
818 |
|
} |
819 |
|
|
820 |
case $1 in |
case $1 in |
821 |
start) |
start) |
822 |
|
# check for global overrides |
823 |
|
[ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true |
824 |
|
[ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true |
825 |
|
read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true |
826 |
|
read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true |
827 |
|
|
828 |
|
# kill all settings if requested |
829 |
|
if [[ ${ALX_RESET_SETTINGS} = true ]] |
830 |
|
then |
831 |
|
reset_system_settings |
832 |
|
fi |
833 |
|
|
834 |
# retrieve or validate current serial |
# retrieve or validate current serial |
835 |
get_system_serial |
get_system_serial |
836 |
if [[ ${ALX_HW_DETECT} = true ]] |
if [[ ${ALX_HW_DETECT} = true ]] |
851 |
|
|
852 |
# now setup system configuration |
# now setup system configuration |
853 |
# alx_setup_or_whatever_it_will_be_called() |
# alx_setup_or_whatever_it_will_be_called() |
854 |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
[[ ${ALX_HW_DETECT} = false ]] && update_system_settings |
855 |
|
|
856 |
# stop at last the preliminary networking (dhcp) |
# stop at last the preliminary networking (dhcp) |
857 |
preliminary_network stop |
preliminary_network stop |