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.12 2005-04-18 22:59:49 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 |
28 |
source /etc/alxconfig-ng/config.rc |
source /etc/alxconfig-ng/config.rc |
29 |
source /usr/lib/alxconfig-ng/functions/mysqlfunctions |
source /usr/lib/alxconfig-ng/functions/mysqlfunctions |
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_modules |
32 |
source /usr/lib/alxconfig-ng/functions/config_network |
source /usr/lib/alxconfig-ng/functions/config_network |
33 |
source /usr/lib/alxconfig-ng/functions/config_printers |
source /usr/lib/alxconfig-ng/functions/config_printers |
34 |
|
source /usr/lib/alxconfig-ng/functions/config_sessions |
35 |
source /usr/lib/alxconfig-ng/functions/config_x11 |
source /usr/lib/alxconfig-ng/functions/config_x11 |
36 |
|
source /usr/lib/alxconfig-ng/functions/config_auth |
37 |
|
source /usr/lib/alxconfig-ng/functions/config_ssh_auth |
38 |
|
|
39 |
#check if mysql is available |
#check if mysql is available |
40 |
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
50 |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
51 |
|
|
52 |
|
|
|
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 |
|
|
} |
|
|
|
|
|
|
|
53 |
update_system_settings(){ |
update_system_settings(){ |
54 |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
55 |
|
|
56 |
|
# get the modules settings |
57 |
|
# ! is the first thing that must be configured ! |
58 |
|
config_modules |
59 |
|
|
60 |
# imports network settings from db |
# imports network settings from db |
61 |
config_networking |
config_networking |
62 |
|
|
63 |
# imports x11 settings from db |
# imports x11 settings from db |
64 |
config_x11 |
config_x11 |
65 |
|
|
66 |
#echo |
# imports session settings from db |
67 |
#echo "sessions" |
config_sessions |
|
#validate_sessions |
|
|
#echo |
|
68 |
|
|
69 |
# imports printer settings from db |
# imports printer settings from db |
70 |
config_printing |
config_printing |
71 |
|
|
72 |
|
# imports auth settings from db |
73 |
|
config_auth |
74 |
|
|
75 |
|
# exchange ssh rsa keys |
76 |
|
config_ssh_auth |
77 |
} |
} |
78 |
|
|
79 |
get_system_serial(){ |
get_system_serial(){ |
85 |
then |
then |
86 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
87 |
|
|
|
# if system is already configured, it *has* a hostname. |
|
|
# so we take the hostname of this system here |
|
|
source /etc/hostname |
|
|
|
|
88 |
#start preliminary networking (dhcp) |
#start preliminary networking (dhcp) |
89 |
preliminary_network start |
preliminary_network start |
90 |
|
|
118 |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
119 |
|
|
120 |
#update the hostname on the system for sure |
#update the hostname on the system for sure |
121 |
echo "HOSTNAME=${HOSTNAME}" > /etc/hostname |
echo "${HOSTNAME}" > /etc/hostname |
122 |
|
|
123 |
#start preliminary networking (dhcp) |
#start preliminary networking (dhcp) |
124 |
preliminary_network start |
preliminary_network start |
201 |
import_settings_to_db() { |
import_settings_to_db() { |
202 |
#note: networking is always 'dhcp' if hw was autodetected |
#note: networking is always 'dhcp' if hw was autodetected |
203 |
#note: default_domain/hostname is set in config.rc |
#note: default_domain/hostname is set in config.rc |
204 |
|
|
205 |
#to be safe, we do some sanity checks |
#to be safe, we do some sanity checks |
206 |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
207 |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
208 |
|
|
209 |
#vars used by hwdetect |
#vars used by hwdetect |
210 |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
211 |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
212 |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
213 |
|
|
214 |
#get setting from hwdetect |
#get setting from hwdetect |
215 |
source /etc/sysconfig/hwsetup/knoppix |
source /etc/sysconfig/hwsetup/knoppix |
216 |
source /etc/sysconfig/hwsetup/mouse |
source /etc/sysconfig/hwsetup/mouse |
217 |
|
|
218 |
echo |
echo |
219 |
echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} |
220 |
|
|
221 |
#network |
#network |
222 |
echo -e " Network settings ..." |
echo -e " Network settings ..." |
223 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
236 |
'dhcp' |
'dhcp' |
237 |
);" |
);" |
238 |
evaluate_retval |
evaluate_retval |
239 |
|
|
240 |
#xserver |
#xserver |
241 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
242 |
#xserver general |
#xserver general |
245 |
serial, |
serial, |
246 |
module, |
module, |
247 |
resolution, |
resolution, |
248 |
depth |
depth, |
249 |
|
monitorid |
250 |
) |
) |
251 |
values( |
values( |
252 |
'${ALX_SERIAL}', |
'${ALX_SERIAL}', |
253 |
'${XMODULE}', |
'${XMODULE}', |
254 |
'1024x768', |
'1024x768', |
255 |
'16' |
'16', |
256 |
);"; |
'0' |
257 |
#xserver monitor |
);"; ) |
258 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
evaluate_retval |
259 |
"insert into cfg_monitor( |
|
260 |
|
# input |
261 |
|
echo -e " Input settings ..." |
262 |
|
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
263 |
|
"insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');" |
264 |
|
evaluate_retval |
265 |
|
|
266 |
|
# auth |
267 |
|
echo -e " Authentifcation settings ..." |
268 |
|
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
269 |
|
"insert into client_auth( |
270 |
serial, |
serial, |
271 |
vendor, |
username, |
272 |
model, |
shell, |
273 |
hsync, |
vnc, |
274 |
vrefresh |
samba, |
275 |
|
station |
276 |
) |
) |
277 |
values( |
values( |
278 |
'${ALX_SERIAL}', |
'${ALX_SERIAL}', |
279 |
'Aamazing', |
'${ALX_UNPRIV_USER}', |
280 |
'CM-1528-FS', |
'', |
281 |
'28-64', |
'', |
282 |
'47-104' |
'', |
283 |
);"; |
'' |
284 |
|
);" |
285 |
|
evaluate_retval |
286 |
|
|
287 |
|
# exchange ssh rsa keys - the first boot needs this ! |
288 |
|
# or no reboot will work via the webadmin |
289 |
|
echo -e " SSH authentifcation settings ..." |
290 |
|
HOME=/root config_ssh_auth |
291 |
|
evaluate_retval |
292 |
|
|
293 |
# input |
# input |
294 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
echo -e " Autostart settings ..." |
295 |
"insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');";) |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
296 |
|
"insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
297 |
evaluate_retval |
evaluate_retval |
298 |
} |
} |
299 |
|
|
324 |
|
|
325 |
#set system state to 'already configured' |
#set system state to 'already configured' |
326 |
touch /etc/alxconfig-ng/state/configured |
touch /etc/alxconfig-ng/state/configured |
327 |
|
|
328 |
|
# default passwords are bad |
329 |
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") root |
330 |
|
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER} |
331 |
|
#smbpasswd -a root foobar |
332 |
} |
} |
333 |
|
|
334 |
#start|stop |
#start|stop |
401 |
then |
then |
402 |
import_settings_to_db |
import_settings_to_db |
403 |
import_settings_local |
import_settings_local |
404 |
|
|
405 |
|
# here we should also exchange the ssh keys |
406 |
|
# or the system cannot be rebooted after |
407 |
|
# the first start via the alx-webadmin |
408 |
|
config_ssh_auth |
409 |
fi |
fi |
410 |
|
|
411 |
#now setup system configuration |
#now setup system configuration |
412 |
#alx_setup_or_whatever_it_will_be_called() |
#alx_setup_or_whatever_it_will_be_called() |
413 |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
426 |
echo "Usage: $0 {start|stop} ..." |
echo "Usage: $0 {start|stop} ..." |
427 |
;; |
;; |
428 |
esac |
esac |
429 |
|
|