11 |
#%before: |
#%before: |
12 |
#%after: |
#%after: |
13 |
|
|
14 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.15 2005-08-17 21:19:52 niro Exp $ |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.21 2005-09-01 18:30:28 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 |
88 |
then |
then |
89 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
90 |
|
|
|
# doing this now before this function gets called |
|
91 |
# start preliminary networking (dhcp) |
# start preliminary networking (dhcp) |
92 |
# preliminary_network start |
preliminary_network start |
93 |
|
|
94 |
|
# check if mysql server is reachable |
95 |
|
# if not abort this script |
96 |
|
if ! reach_mysql_server |
97 |
|
then |
98 |
|
preliminary_network stop |
99 |
|
exit 1 |
100 |
|
fi |
101 |
|
|
102 |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
103 |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
114 |
then |
then |
115 |
ALX_STATE="ok" |
ALX_STATE="ok" |
116 |
else |
else |
117 |
|
# abort on non valid serial |
118 |
ALX_STATE="invalid serial" |
ALX_STATE="invalid serial" |
119 |
|
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
120 |
|
show_invalid_serial_msg |
121 |
|
exit 1 |
122 |
fi |
fi |
123 |
|
|
124 |
else |
else |
126 |
echo |
echo |
127 |
if [ -f /hardware-auto-detection ] |
if [ -f /hardware-auto-detection ] |
128 |
then |
then |
129 |
echo -e ${COLMAGENTA}"Hardware-Auto-Detection forced by system-administrator"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} |
130 |
else |
else |
131 |
echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} |
132 |
fi |
fi |
145 |
# start preliminary networking (dhcp) |
# start preliminary networking (dhcp) |
146 |
preliminary_network start |
preliminary_network start |
147 |
|
|
148 |
|
# check if mysql server is reachable |
149 |
|
# if not abort this script |
150 |
|
if ! reach_mysql_server |
151 |
|
then |
152 |
|
preliminary_network stop |
153 |
|
exit 1 |
154 |
|
fi |
155 |
|
|
156 |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
157 |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
158 |
CUR_MTIME=$(date +%s) |
CUR_MTIME=$(date +%s) |
174 |
then |
then |
175 |
ALX_STATE="ok" |
ALX_STATE="ok" |
176 |
else |
else |
177 |
|
# abort on non valid serial |
178 |
ALX_STATE="invalid serial" |
ALX_STATE="invalid serial" |
179 |
|
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
180 |
|
show_invalid_serial_msg |
181 |
|
exit 1 |
182 |
fi |
fi |
183 |
|
|
184 |
# write current state to temp file |
# write current state to temp file |
196 |
# request new serial |
# request new serial |
197 |
# ALX_REG_DATE="$(date +%F)" |
# ALX_REG_DATE="$(date +%F)" |
198 |
|
|
199 |
# we're using the mtime now (better for vaildating the serial) |
# we're using the mtime now (better for validating the serial) |
200 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
# mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
201 |
"insert into client_serials( |
# "insert into client_serials( |
202 |
mtime, |
# mtime, |
203 |
mac |
# mac |
204 |
) |
# ) |
205 |
values( |
# values( |
206 |
'${CUR_MTIME}', |
# '${CUR_MTIME}', |
207 |
'${CUR_MAC}' |
# '${CUR_MAC}' |
208 |
);" |
# );" |
209 |
|
# |
210 |
# then validate and retrieve serial |
# # then validate and retrieve serial |
211 |
|
# |
212 |
### warning must be changed that only the LAST ID will be fetched, ### |
# ### warning must be changed that only the LAST ID will be fetched, ### |
213 |
### or you get error if the computer name and date are the same ### |
# ### or you get error if the computer name and date are the same ### |
214 |
### you have more than one serial number then ### |
# ### you have more than one serial number then ### |
215 |
|
# |
216 |
|
# # select highest id only (added max) |
217 |
|
# ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
218 |
|
# "select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'") |
219 |
|
|
220 |
# select highest id only (added max) |
# request a new serial; one command now (cause must be done in the same session) |
221 |
ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
222 |
"select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'") |
"insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); |
223 |
|
select last_insert_id();") |
224 |
|
|
225 |
if [ "${ALX_SERIAL}" != NULL ] |
if [ "${ALX_SERIAL}" != NULL ] |
226 |
then |
then |
449 |
# set system state to 'already configured' |
# set system state to 'already configured' |
450 |
touch /etc/alxconfig-ng/state/configured |
touch /etc/alxconfig-ng/state/configured |
451 |
|
|
452 |
|
# if only an recheck was forced than abort now |
453 |
|
[[ ${ALX_FORCED_RECHECK} = true ]] && return 0 |
454 |
|
|
455 |
# create a fresh fluxbox directory |
# create a fresh fluxbox directory |
456 |
[ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox |
[ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox |
457 |
install -d ${ALX_UNPRIV_HOME}/.fluxbox |
install -d ${ALX_UNPRIV_HOME}/.fluxbox |
462 |
cat ${ALX_SKELETONS}/fluxbox/init \ |
cat ${ALX_SKELETONS}/fluxbox/init \ |
463 |
> ${ALX_UNPRIV_HOME}/.fluxbox/init |
> ${ALX_UNPRIV_HOME}/.fluxbox/init |
464 |
|
|
465 |
|
# fluxbox autostart |
466 |
|
cat ${ALX_SKELETONS}/fluxbox/apps \ |
467 |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
468 |
|
|
469 |
# fluxbox menu header |
# fluxbox menu header |
470 |
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
471 |
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
472 |
|
|
473 |
|
# now fix it with proper messages :P |
474 |
|
local ver="$(< /etc/mageversion)" |
475 |
|
sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" \ |
476 |
|
${ALX_UNPRIV_HOME}/.fluxbox/menu |
477 |
|
|
478 |
# add a newline (maybe there is no crlf in the header) |
# add a newline (maybe there is no crlf in the header) |
479 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
480 |
|
|
485 |
# add a newline (maybe there is no crlf in the footer) |
# add a newline (maybe there is no crlf in the footer) |
486 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
487 |
|
|
488 |
|
|
489 |
|
# setup some standart icons (sysinfo.lnk) |
490 |
|
# basic config |
491 |
|
cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc |
492 |
|
|
493 |
|
# clean desktop icon location |
494 |
|
[ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop |
495 |
|
install -d ${ALX_UNPRIV_HOME}/.xtdesktop |
496 |
|
|
497 |
|
# last but not least gen a icon with some sys informations |
498 |
|
local sysinfo |
499 |
|
local osversion |
500 |
|
local xres |
501 |
|
local yres |
502 |
|
|
503 |
|
osversion="$(< /etc/mageversion)" |
504 |
|
sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
505 |
|
|
506 |
|
# at first boot we got always a resolution of 1024x768-16@60 |
507 |
|
# middle of the screen |
508 |
|
# (no txt - length required, xtdesk manage that itself) |
509 |
|
xres="$((1024 / 2))" |
510 |
|
# default y pos (full yres -22 !) |
511 |
|
yres="$((768 - 22 ))" |
512 |
|
|
513 |
|
generate_icon \ |
514 |
|
--name "${sysinfo}" \ |
515 |
|
--command "exit 0" \ |
516 |
|
--icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ |
517 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ |
518 |
|
--xres "${xres}" \ |
519 |
|
--yres "${yres}" \ |
520 |
|
--icon-width "1" \ |
521 |
|
--icon-height "1" |
522 |
|
|
523 |
# set correct permissions |
# set correct permissions |
524 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
525 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
526 |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
527 |
chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop |
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
528 |
chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
529 |
|
|
530 |
# default passwords are bad |
# default passwords are bad |
531 |
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") root |
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") root |
598 |
|
|
599 |
case $1 in |
case $1 in |
600 |
start) |
start) |
|
# start preliminary networking (dhcp) |
|
|
preliminary_network start |
|
|
|
|
|
# check if mysql server is reachable |
|
|
# if not abort this script |
|
|
if ! reach_mysql_server |
|
|
then |
|
|
preliminary_network stop |
|
|
exit 1 |
|
|
fi |
|
|
|
|
601 |
# retrieve or validate current serial |
# retrieve or validate current serial |
602 |
get_system_serial |
get_system_serial |
603 |
if [[ ${ALX_HW_DETECT} = true ]] |
if [[ ${ALX_HW_DETECT} = true ]] |