11 |
#%before: |
#%before: |
12 |
#%after: |
#%after: |
13 |
|
|
14 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.22 2005-09-22 22:14:38 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 |
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 ] && [[ ${ALX_FORCED_RECHECK} = false ]] |
if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]] |
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 ..." |
143 |
else |
else |
144 |
# abort on non valid serial |
# 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 |
echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state |
147 |
show_invalid_serial_msg |
show_invalid_serial_msg |
148 |
exit 1 |
exit 1 |
149 |
fi |
fi |
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 |
[ -f /hardware-auto-detection ] && 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 |
221 |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
222 |
|
|
223 |
# request a new serial; one command now (cause must be done in the same session) |
# request a new serial; one command now (cause must be done in the same session) |
224 |
ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); |
|
"insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); |
|
225 |
select last_insert_id();") |
select last_insert_id();") |
226 |
|
|
227 |
if [[ ${ALX_SERIAL} != NULL ]] |
if [[ ${ALX_SERIAL} != NULL ]] |
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 |
238 |
echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial |
echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial |
239 |
|
|
240 |
evaluate_retval |
evaluate_retval |
241 |
else |
else |
254 |
fi |
fi |
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 |
|
|
305 |
source ${network_settings}/net.${iface} || exit 1 |
source ${network_settings}/net.${iface} || exit 1 |
306 |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
307 |
|
|
308 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_network( |
|
"insert into cfg_network( |
|
309 |
hostname, |
hostname, |
310 |
serial, |
serial, |
311 |
module, |
module, |
356 |
break |
break |
357 |
done |
done |
358 |
else |
else |
359 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_network( |
|
"insert into cfg_network( |
|
360 |
hostname, |
hostname, |
361 |
serial, |
serial, |
362 |
module, |
module, |
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 |
|
|
478 |
source ${network_settings}/net.${iface} || exit 1 |
source ${network_settings}/net.${iface} || exit 1 |
479 |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
480 |
|
|
481 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "update cfg_network set |
|
"update cfg_network set |
|
482 |
hostname='${ALX_DEFAULT_HOSTNAME}', |
hostname='${ALX_DEFAULT_HOSTNAME}', |
483 |
module='${NETCARD_DRIVER}', |
module='${NETCARD_DRIVER}', |
484 |
domain='${ALX_DEFAULT_DOMAIN}', |
domain='${ALX_DEFAULT_DOMAIN}', |
505 |
break |
break |
506 |
done |
done |
507 |
else |
else |
508 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "update cfg_network set |
|
"update cfg_network set |
|
509 |
hostname='${ALX_DEFAULT_HOSTNAME}', |
hostname='${ALX_DEFAULT_HOSTNAME}', |
510 |
module='${NETCARD_DRIVER}', |
module='${NETCARD_DRIVER}', |
511 |
domain='${ALX_DEFAULT_DOMAIN}', |
domain='${ALX_DEFAULT_DOMAIN}', |
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 |
649 |
--icon-width "1" \ |
--icon-width "1" \ |
650 |
--icon-height "1" |
--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 |
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
660 |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
661 |
|
chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc |
|
# default passwords are bad |
|
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") root |
|
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER} |
|
|
#smbpasswd -a root foobar |
|
662 |
} |
} |
663 |
|
|
664 |
# start|stop |
# start|stop |
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 ]] && ${rc_base}/init.d/network stop |
[[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \ |
702 |
|
${rc_base}/init.d/network stop |
703 |
|
|
704 |
echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} |
echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} |
705 |
|
|
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 |
730 |
|
sleep 1 |
731 |
fi |
fi |
732 |
evaluate_retval |
evaluate_retval |
733 |
;; |
;; |
765 |
rm -f /etc/alxconfig-ng/serial |
rm -f /etc/alxconfig-ng/serial |
766 |
rm -rf /etc/alxconfig-ng/state |
rm -rf /etc/alxconfig-ng/state |
767 |
|
|
768 |
|
# clear all printers & net-shares |
769 |
|
:> /etc/cups/printers.conf |
770 |
|
:> /etc/samba/smb.conf |
771 |
|
|
772 |
|
# remove inetd, cups & smb from init |
773 |
|
rc-config del inetd &> /dev/null |
774 |
|
rc-config del cups &> /dev/null |
775 |
|
rc-config del samba &> /dev/null |
776 |
|
|
777 |
|
# remove all user settings |
778 |
|
[ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} |
779 |
|
|
780 |
|
# remove all ica-sessions |
781 |
|
find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm |
782 |
|
|
783 |
|
# remove all old nics and modules configs |
784 |
|
find /etc/conf.d -type f -name 'net.*' | xargs rm |
785 |
|
find /etc/modules.d -type f -name 'net.*' | xargs rm |
786 |
|
|
787 |
|
# restore default networking |
788 |
|
cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 |
789 |
|
|
790 |
echo "I am done now, press [Enter] to reboot system ..." |
echo "I am done now, press [Enter] to reboot system ..." |
791 |
read |
else |
792 |
reboot |
echo "Aborted, press [Enter] to reboot system ..." |
793 |
fi |
fi |
794 |
|
read |
795 |
|
reboot |
796 |
} |
} |
797 |
|
|
798 |
onboot_interface_list() |
onboot_interface_list() |
818 |
echo "${devices}" |
echo "${devices}" |
819 |
} |
} |
820 |
|
|
821 |
# read values from files |
# read values from net.* files |
822 |
read_value() |
read_value() |
823 |
{ |
{ |
824 |
local var="$1" |
local var="$1" |
905 |
|
|
906 |
# now setup system configuration |
# now setup system configuration |
907 |
# alx_setup_or_whatever_it_will_be_called() |
# alx_setup_or_whatever_it_will_be_called() |
908 |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
[[ ${ALX_HW_DETECT} = false ]] && update_system_settings |
909 |
|
|
910 |
# stop at last the preliminary networking (dhcp) |
# stop at last the preliminary networking (dhcp) |
911 |
preliminary_network stop |
preliminary_network stop |