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 |
154 |
if [[ ${ALX_FORCED_RECHECK} = true ]] |
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 |
|
# always disable CONFD_NETWORKING here |
158 |
|
export ALX_CONFD_NETWORKING="false" |
159 |
else |
else |
160 |
echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} |
161 |
fi |
fi |
211 |
fi |
fi |
212 |
|
|
213 |
# write current state to temp file |
# write current state to temp file |
214 |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state |
215 |
[ -f /hardware-auto-detection ] && rm /hardware-auto-detection |
[ -f /hardware-auto-detection ] && rm /hardware-auto-detection |
216 |
|
|
217 |
# now export ALX_FORCED_RECHECK=true |
# now export ALX_FORCED_RECHECK=true |
223 |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
224 |
|
|
225 |
# 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) |
226 |
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}'); |
|
227 |
select last_insert_id();") |
select last_insert_id();") |
228 |
|
|
229 |
if [[ ${ALX_SERIAL} != NULL ]] |
if [[ ${ALX_SERIAL} != NULL ]] |
233 |
$SET_WCOL |
$SET_WCOL |
234 |
echo "[ SN: ${ALX_SERIAL} ]" |
echo "[ SN: ${ALX_SERIAL} ]" |
235 |
|
|
236 |
# set ALX_STATE to ok so everybody that everything was ok |
# set ALX_STATE to ok so everybody knows that everything was ok |
237 |
ALX_STATE=ok |
ALX_STATE=ok |
238 |
|
|
239 |
echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial |
echo "ALX_SERIAL=\"${ALX_SERIAL}\"" > /etc/alxconfig-ng/serial |
240 |
echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial |
echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial |
241 |
|
|
242 |
evaluate_retval |
evaluate_retval |
243 |
else |
else |
256 |
fi |
fi |
257 |
|
|
258 |
# write current state to temp file |
# write current state to temp file |
259 |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state |
260 |
|
echo "ALX_IFACE=\"${ALX_IFACE}\"" >> /etc/alxconfig-ng/state/state |
261 |
} |
} |
262 |
|
|
263 |
|
|
307 |
source ${network_settings}/net.${iface} || exit 1 |
source ${network_settings}/net.${iface} || exit 1 |
308 |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
309 |
|
|
310 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_network( |
|
"insert into cfg_network( |
|
311 |
hostname, |
hostname, |
312 |
serial, |
serial, |
313 |
module, |
module, |
358 |
break |
break |
359 |
done |
done |
360 |
else |
else |
361 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_network( |
|
"insert into cfg_network( |
|
362 |
hostname, |
hostname, |
363 |
serial, |
serial, |
364 |
module, |
module, |
378 |
# xserver |
# xserver |
379 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
380 |
# xserver general |
# xserver general |
381 |
( mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
( mysqldo "insert into cfg_graphic( |
|
"insert into cfg_graphic( |
|
382 |
serial, |
serial, |
383 |
module, |
module, |
384 |
resolution, |
resolution, |
385 |
depth, |
depth, |
386 |
monitorid |
refresh_rate |
387 |
) |
) |
388 |
values( |
values( |
389 |
'${ALX_SERIAL}', |
'${ALX_SERIAL}', |
390 |
'${XMODULE}', |
'${XMODULE}', |
391 |
'1024x768', |
'1024x768', |
392 |
'16', |
'16', |
393 |
'0' |
'60' |
394 |
);"; ) |
);"; ) |
395 |
evaluate_retval |
evaluate_retval |
396 |
|
|
397 |
# input |
# input |
398 |
echo -e " Input settings ..." |
echo -e " Input settings ..." |
399 |
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}');" |
|
400 |
evaluate_retval |
evaluate_retval |
401 |
|
|
402 |
# auth |
# auth |
403 |
echo -e " Authentifcation settings ..." |
echo -e " Authentification settings ..." |
404 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into client_auth( |
|
"insert into client_auth( |
|
405 |
serial, |
serial, |
406 |
username, |
username, |
407 |
shell, |
shell, |
421 |
|
|
422 |
# exchange ssh rsa keys - the first boot needs this ! |
# exchange ssh rsa keys - the first boot needs this ! |
423 |
# or no reboot will work via the webadmin |
# or no reboot will work via the webadmin |
424 |
echo -e " SSH authentifcation settings ..." |
echo -e " SSH authentification settings ..." |
425 |
HOME=/root config_ssh_auth |
HOME=/root config_ssh_auth |
426 |
evaluate_retval |
evaluate_retval |
427 |
|
|
428 |
# input |
# autostart |
429 |
echo -e " Autostart settings ..." |
echo -e " Autostart settings ..." |
430 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
431 |
"insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
|
432 |
|
# screensaver |
433 |
|
echo -e " Screensaver settings ..." |
434 |
|
mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" |
435 |
|
|
436 |
|
# version info |
437 |
|
local alx_os |
438 |
|
local alx_utils |
439 |
|
alx_os="$(< /etc/mageversion)" |
440 |
|
alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" |
441 |
|
alx_utils="${alx_utils/alxconfig-ng-alx-}" |
442 |
|
mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')" |
443 |
|
|
444 |
evaluate_retval |
evaluate_retval |
445 |
} |
} |
446 |
|
|
480 |
source ${network_settings}/net.${iface} || exit 1 |
source ${network_settings}/net.${iface} || exit 1 |
481 |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
482 |
|
|
483 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "update cfg_network set |
|
"update cfg_network set |
|
484 |
hostname='${ALX_DEFAULT_HOSTNAME}', |
hostname='${ALX_DEFAULT_HOSTNAME}', |
485 |
module='${NETCARD_DRIVER}', |
module='${NETCARD_DRIVER}', |
486 |
domain='${ALX_DEFAULT_DOMAIN}', |
domain='${ALX_DEFAULT_DOMAIN}', |
507 |
break |
break |
508 |
done |
done |
509 |
else |
else |
510 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "update cfg_network set |
|
"update cfg_network set |
|
511 |
hostname='${ALX_DEFAULT_HOSTNAME}', |
hostname='${ALX_DEFAULT_HOSTNAME}', |
512 |
module='${NETCARD_DRIVER}', |
module='${NETCARD_DRIVER}', |
513 |
domain='${ALX_DEFAULT_DOMAIN}', |
domain='${ALX_DEFAULT_DOMAIN}', |
519 |
# xserver |
# xserver |
520 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
521 |
# xserver general |
# xserver general |
522 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "update cfg_graphic set |
|
"update cfg_graphic set |
|
523 |
module='${XMODULE}', |
module='${XMODULE}', |
524 |
resolution='1024x768', |
resolution='1024x768', |
525 |
depth='16', |
depth='16', |
526 |
monitorid='0' |
refresh_rate='60' |
527 |
where serial=${ALX_SERIAL};" |
where serial=${ALX_SERIAL};" |
528 |
evaluate_retval |
evaluate_retval |
529 |
|
|
530 |
# input |
# input |
531 |
echo -e " Input settings ..." |
echo -e " Input settings ..." |
532 |
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};" |
|
533 |
evaluate_retval |
evaluate_retval |
534 |
|
|
535 |
|
# version info |
536 |
|
local alx_os |
537 |
|
local alx_utils |
538 |
|
alx_os="$(< /etc/mageversion)" |
539 |
|
alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" |
540 |
|
alx_utils="${alx_utils/alxconfig-ng-alx-}" |
541 |
|
mysqldo "update client_version set os='${alx_os}', utils='${alx_utils}' where serial=${ALX_SERIAL};" |
542 |
} |
} |
543 |
|
|
544 |
# imports current settings to the local system resolved by the hardware detection |
# imports current settings to the local system resolved by the hardware detection |
568 |
#[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
#[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
569 |
#echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules |
#echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules |
570 |
|
|
571 |
# set an device alias for modprobe.conf |
# set an device alias for modprobe.conf and modules.conf |
572 |
[ ! -d /etc/modules.d ] && install -d /etc/modules.d |
[ ! -d /etc/modules.d ] && install -d /etc/modules.d |
573 |
|
[ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d |
574 |
echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0 |
echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0 |
575 |
|
echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0 |
576 |
|
|
577 |
# regenerate modprobe.conf |
# regenerate modprobe.conf |
578 |
[ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf" |
[ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf" |
653 |
--icon-width "1" \ |
--icon-width "1" \ |
654 |
--icon-height "1" |
--icon-height "1" |
655 |
|
|
656 |
|
# create a xinitrc |
657 |
|
echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc |
658 |
|
|
659 |
# set correct permissions |
# set correct permissions |
660 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
661 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
662 |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
663 |
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
664 |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
665 |
|
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 |
|
666 |
} |
} |
667 |
|
|
668 |
# start|stop |
# start|stop |
702 |
else |
else |
703 |
rm -f /var/run/dhcpcd-eth?.pid |
rm -f /var/run/dhcpcd-eth?.pid |
704 |
fi |
fi |
705 |
[[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop |
[[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \ |
706 |
|
${rc_base}/init.d/network stop |
707 |
|
|
708 |
echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} |
echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} |
709 |
|
|
731 |
if ps -A|grep dhcpcd > /dev/null |
if ps -A|grep dhcpcd > /dev/null |
732 |
then |
then |
733 |
dhcpcd -z &> /dev/null |
dhcpcd -z &> /dev/null |
734 |
|
sleep 1 |
735 |
fi |
fi |
736 |
evaluate_retval |
evaluate_retval |
737 |
;; |
;; |
769 |
rm -f /etc/alxconfig-ng/serial |
rm -f /etc/alxconfig-ng/serial |
770 |
rm -rf /etc/alxconfig-ng/state |
rm -rf /etc/alxconfig-ng/state |
771 |
|
|
772 |
|
# clear all printers & net-shares |
773 |
|
:> /etc/cups/printers.conf |
774 |
|
:> /etc/samba/smb.conf |
775 |
|
|
776 |
|
# remove inetd, cups & smb from init |
777 |
|
rc-config del inetd &> /dev/null |
778 |
|
rc-config del cups &> /dev/null |
779 |
|
rc-config del samba &> /dev/null |
780 |
|
|
781 |
|
# remove all user settings |
782 |
|
[ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} |
783 |
|
|
784 |
|
# remove all ica-sessions |
785 |
|
find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm |
786 |
|
|
787 |
|
# remove all old nics and modules configs |
788 |
|
find /etc/conf.d -type f -name 'net.*' | xargs rm |
789 |
|
find /etc/modules.d -type f -name 'net.*' | xargs rm |
790 |
|
|
791 |
|
# restore default networking |
792 |
|
cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 |
793 |
|
|
794 |
echo "I am done now, press [Enter] to reboot system ..." |
echo "I am done now, press [Enter] to reboot system ..." |
795 |
read |
else |
796 |
reboot |
echo "Aborted, press [Enter] to reboot system ..." |
797 |
fi |
fi |
798 |
|
read |
799 |
|
reboot |
800 |
} |
} |
801 |
|
|
802 |
onboot_interface_list() |
onboot_interface_list() |
822 |
echo "${devices}" |
echo "${devices}" |
823 |
} |
} |
824 |
|
|
825 |
# read values from files |
# read values from net.* files |
826 |
read_value() |
read_value() |
827 |
{ |
{ |
828 |
local var="$1" |
local var="$1" |
909 |
|
|
910 |
# now setup system configuration |
# now setup system configuration |
911 |
# alx_setup_or_whatever_it_will_be_called() |
# alx_setup_or_whatever_it_will_be_called() |
912 |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
[[ ${ALX_HW_DETECT} = false ]] && update_system_settings |
913 |
|
|
914 |
# stop at last the preliminary networking (dhcp) |
# stop at last the preliminary networking (dhcp) |
915 |
preliminary_network stop |
preliminary_network stop |