11 |
#%before: |
#%before: |
12 |
#%after: |
#%after: |
13 |
|
|
14 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.3 2005-03-09 00:04:23 niro Exp $ |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.9 2005-04-14 19:12:21 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 |
30 |
source /usr/lib/alxconfig-ng/functions/serial_functions |
source /usr/lib/alxconfig-ng/functions/serial_functions |
31 |
source /usr/lib/alxconfig-ng/functions/config_network |
source /usr/lib/alxconfig-ng/functions/config_network |
32 |
source /usr/lib/alxconfig-ng/functions/config_printers |
source /usr/lib/alxconfig-ng/functions/config_printers |
33 |
|
source /usr/lib/alxconfig-ng/functions/config_sessions |
34 |
source /usr/lib/alxconfig-ng/functions/config_x11 |
source /usr/lib/alxconfig-ng/functions/config_x11 |
35 |
|
source /usr/lib/alxconfig-ng/functions/config_auth |
36 |
|
source /usr/lib/alxconfig-ng/functions/config_ssh_auth |
37 |
|
|
38 |
#check if mysql is available |
#check if mysql is available |
39 |
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
49 |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
50 |
|
|
51 |
|
|
|
validate_sessions(){ |
|
|
|
|
|
local x i all LOCAL_SESSIONS DB_SESSIONS SETTINGSPATH count |
|
|
|
|
|
#all arrays: |
|
|
# -> session1 session2 ... sessionN |
|
|
|
|
|
|
|
|
#no LOCAL_SESSIONS here, needs bubblesort |
|
|
|
|
|
#get settings from database |
|
|
all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select session from cfg_sessions where serial='${ALX_SERIAL}'") |
|
|
|
|
|
#split'em up and put in an array (only if $all not zero) |
|
|
declare -i i=0 |
|
|
if [ -n "${all}" ] |
|
|
then |
|
|
for x in ${all} |
|
|
do |
|
|
DB_SESSIONS[${i}]=${x} |
|
|
((i++)) |
|
|
done |
|
|
count=${i} |
|
|
else |
|
|
count=0 |
|
|
fi |
|
|
|
|
|
## no compare here, can only done with bubblesort or s.th like that |
|
|
# shows only the new sessions |
|
|
declare -i i=0 |
|
|
#count=${#DB_SESSIONS[*]} #---> not working gets always 1, why ? |
|
|
|
|
|
echo "Number of new sessions: ${count}" |
|
|
for ((i=0; i < count; i++)) |
|
|
do |
|
|
echo "${i} - ${DB_SESSIONS[${i}]}" |
|
|
done |
|
|
|
|
|
#update local configs |
|
|
SETTINGSPATH=${SETTINGS_TEMPLATE}/menu |
|
|
declare -i i=0 |
|
|
|
|
|
#count=${#DB_SESSIONS[*]} |
|
|
|
|
|
if [ ${count} -gt 0 ] |
|
|
then |
|
|
#create directory if not exist |
|
|
[ ! -d ${SETTINGSPATH}/sessions ] && install -d ${SETTINGSPATH}/sessions |
|
|
|
|
|
#delete old sessions |
|
|
echo -n > ${SETTINGSPATH}/sessions/sessions |
|
|
|
|
|
for ((i=0; i < count; i++)) |
|
|
do |
|
|
echo "${DB_SESSIONS[${i}]}" >> ${SETTINGSPATH}/sessions/sessions |
|
|
done |
|
|
|
|
|
#set update flag |
|
|
ALX_SESSION_SETUP=true |
|
|
fi |
|
|
} |
|
|
|
|
|
|
|
52 |
update_system_settings(){ |
update_system_settings(){ |
53 |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
54 |
|
|
58 |
# imports x11 settings from db |
# imports x11 settings from db |
59 |
config_x11 |
config_x11 |
60 |
|
|
61 |
#echo |
# imports session settings from db |
62 |
#echo "sessions" |
config_sessions |
|
#validate_sessions |
|
|
#echo |
|
63 |
|
|
64 |
# imports printer settings from db |
# imports printer settings from db |
65 |
config_printing |
config_printing |
66 |
|
|
67 |
|
# imports auth settings from db |
68 |
|
config_auth |
69 |
|
|
70 |
|
# exchange ssh rsa keys |
71 |
|
config_ssh_auth |
72 |
} |
} |
73 |
|
|
74 |
get_system_serial(){ |
get_system_serial(){ |
80 |
then |
then |
81 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
82 |
|
|
|
# if system is already configured, it *has* a hostname. |
|
|
# so we take the hostname of this system here |
|
|
source /etc/hostname |
|
|
|
|
83 |
#start preliminary networking (dhcp) |
#start preliminary networking (dhcp) |
84 |
preliminary_network start |
preliminary_network start |
85 |
|
|
113 |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
114 |
|
|
115 |
#update the hostname on the system for sure |
#update the hostname on the system for sure |
116 |
echo "HOSTNAME=${HOSTNAME}" > /etc/hostname |
echo "${HOSTNAME}" > /etc/hostname |
117 |
|
|
118 |
#start preliminary networking (dhcp) |
#start preliminary networking (dhcp) |
119 |
preliminary_network start |
preliminary_network start |
196 |
import_settings_to_db() { |
import_settings_to_db() { |
197 |
#note: networking is always 'dhcp' if hw was autodetected |
#note: networking is always 'dhcp' if hw was autodetected |
198 |
#note: default_domain/hostname is set in config.rc |
#note: default_domain/hostname is set in config.rc |
199 |
|
|
200 |
#to be safe, we do some sanity checks |
#to be safe, we do some sanity checks |
201 |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
202 |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
203 |
|
|
204 |
#vars used by hwdetect |
#vars used by hwdetect |
205 |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
206 |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
207 |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
208 |
|
|
209 |
#get setting from hwdetect |
#get setting from hwdetect |
210 |
source /etc/sysconfig/hwsetup/knoppix |
source /etc/sysconfig/hwsetup/knoppix |
211 |
source /etc/sysconfig/hwsetup/mouse |
source /etc/sysconfig/hwsetup/mouse |
212 |
|
|
213 |
echo |
echo |
214 |
echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} |
215 |
|
|
216 |
#network |
#network |
217 |
echo -e " Network settings ..." |
echo -e " Network settings ..." |
218 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
231 |
'dhcp' |
'dhcp' |
232 |
);" |
);" |
233 |
evaluate_retval |
evaluate_retval |
234 |
|
|
235 |
#xserver |
#xserver |
236 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
237 |
#xserver general |
#xserver general |
240 |
serial, |
serial, |
241 |
module, |
module, |
242 |
resolution, |
resolution, |
243 |
depth |
depth, |
244 |
|
monitorid |
245 |
) |
) |
246 |
values( |
values( |
247 |
'${ALX_SERIAL}', |
'${ALX_SERIAL}', |
248 |
'${XMODULE}', |
'${XMODULE}', |
249 |
'1024x768', |
'1024x768', |
250 |
'16' |
'16', |
251 |
);"; |
'0' |
252 |
#xserver monitor |
);"; ) |
253 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
evaluate_retval |
254 |
"insert into cfg_monitor( |
|
255 |
|
# input |
256 |
|
echo -e " Input settings ..." |
257 |
|
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
258 |
|
"insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');" |
259 |
|
evaluate_retval |
260 |
|
|
261 |
|
# auth |
262 |
|
echo -e " Authentifcation settings ..." |
263 |
|
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
264 |
|
"insert into client_auth( |
265 |
serial, |
serial, |
266 |
vendor, |
username, |
267 |
model, |
shell, |
268 |
hsync, |
vnc, |
269 |
vrefresh |
samba, |
270 |
|
station |
271 |
) |
) |
272 |
values( |
values( |
273 |
'${ALX_SERIAL}', |
'${ALX_SERIAL}', |
274 |
'Aamazing', |
'${ALX_UNPRIV_USER}', |
275 |
'CM-1528-FS', |
'', |
276 |
'28-64', |
'', |
277 |
'47-104' |
'', |
278 |
);"; |
'' |
279 |
|
);" |
280 |
|
evaluate_retval |
281 |
|
|
282 |
# input |
# input |
283 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
echo -e " Autostart settings ..." |
284 |
"insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');";) |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
285 |
|
"insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
286 |
evaluate_retval |
evaluate_retval |
287 |
} |
} |
288 |
|
|
313 |
|
|
314 |
#set system state to 'already configured' |
#set system state to 'already configured' |
315 |
touch /etc/alxconfig-ng/state/configured |
touch /etc/alxconfig-ng/state/configured |
316 |
|
|
317 |
|
# default passwords are bad |
318 |
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") root |
319 |
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER} |
320 |
|
#smbpasswd -a root foobar |
321 |
} |
} |
322 |
|
|
323 |
#start|stop |
#start|stop |
390 |
then |
then |
391 |
import_settings_to_db |
import_settings_to_db |
392 |
import_settings_local |
import_settings_local |
393 |
|
|
394 |
|
# here we should also exchange the ssh keys |
395 |
|
# or the system cannot be rebooted after |
396 |
|
# the first start via the alx-webadmin |
397 |
|
config_ssh_auth |
398 |
fi |
fi |
399 |
|
|
400 |
#now setup system configuration |
#now setup system configuration |
401 |
#alx_setup_or_whatever_it_will_be_called() |
#alx_setup_or_whatever_it_will_be_called() |
402 |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
415 |
echo "Usage: $0 {start|stop} ..." |
echo "Usage: $0 {start|stop} ..." |
416 |
;; |
;; |
417 |
esac |
esac |
418 |
|
|