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.8 2005-04-13 16:15: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 |
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 |
|
|
37 |
#check if mysql is available |
#check if mysql is available |
38 |
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
48 |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
49 |
|
|
50 |
|
|
|
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 |
|
|
} |
|
|
|
|
|
|
|
51 |
update_system_settings(){ |
update_system_settings(){ |
52 |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
53 |
|
|
57 |
# imports x11 settings from db |
# imports x11 settings from db |
58 |
config_x11 |
config_x11 |
59 |
|
|
60 |
#echo |
# imports session settings from db |
61 |
#echo "sessions" |
config_sessions |
|
#validate_sessions |
|
|
#echo |
|
62 |
|
|
63 |
# imports printer settings from db |
# imports printer settings from db |
64 |
config_printing |
config_printing |
65 |
|
|
66 |
|
# imports auth settings from db |
67 |
|
config_auth |
68 |
} |
} |
69 |
|
|
70 |
get_system_serial(){ |
get_system_serial(){ |
76 |
then |
then |
77 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
78 |
|
|
|
# if system is already configured, it *has* a hostname. |
|
|
# so we take the hostname of this system here |
|
|
source /etc/hostname |
|
|
|
|
79 |
#start preliminary networking (dhcp) |
#start preliminary networking (dhcp) |
80 |
preliminary_network start |
preliminary_network start |
81 |
|
|
109 |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
110 |
|
|
111 |
#update the hostname on the system for sure |
#update the hostname on the system for sure |
112 |
echo "HOSTNAME=${HOSTNAME}" > /etc/hostname |
echo "${HOSTNAME}" > /etc/hostname |
113 |
|
|
114 |
#start preliminary networking (dhcp) |
#start preliminary networking (dhcp) |
115 |
preliminary_network start |
preliminary_network start |
192 |
import_settings_to_db() { |
import_settings_to_db() { |
193 |
#note: networking is always 'dhcp' if hw was autodetected |
#note: networking is always 'dhcp' if hw was autodetected |
194 |
#note: default_domain/hostname is set in config.rc |
#note: default_domain/hostname is set in config.rc |
195 |
|
|
196 |
#to be safe, we do some sanity checks |
#to be safe, we do some sanity checks |
197 |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
198 |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
199 |
|
|
200 |
#vars used by hwdetect |
#vars used by hwdetect |
201 |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
202 |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
203 |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
204 |
|
|
205 |
#get setting from hwdetect |
#get setting from hwdetect |
206 |
source /etc/sysconfig/hwsetup/knoppix |
source /etc/sysconfig/hwsetup/knoppix |
207 |
source /etc/sysconfig/hwsetup/mouse |
source /etc/sysconfig/hwsetup/mouse |
208 |
|
|
209 |
echo |
echo |
210 |
echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} |
211 |
|
|
212 |
#network |
#network |
213 |
echo -e " Network settings ..." |
echo -e " Network settings ..." |
214 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
227 |
'dhcp' |
'dhcp' |
228 |
);" |
);" |
229 |
evaluate_retval |
evaluate_retval |
230 |
|
|
231 |
#xserver |
#xserver |
232 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
233 |
#xserver general |
#xserver general |
236 |
serial, |
serial, |
237 |
module, |
module, |
238 |
resolution, |
resolution, |
239 |
depth |
depth, |
240 |
|
monitorid |
241 |
) |
) |
242 |
values( |
values( |
243 |
'${ALX_SERIAL}', |
'${ALX_SERIAL}', |
244 |
'${XMODULE}', |
'${XMODULE}', |
245 |
'1024x768', |
'1024x768', |
246 |
'16' |
'16', |
247 |
);"; |
'0' |
|
#xserver monitor |
|
|
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"insert into cfg_monitor( |
|
|
serial, |
|
|
vendor, |
|
|
model, |
|
|
hsync, |
|
|
vrefresh |
|
|
) |
|
|
values( |
|
|
'${ALX_SERIAL}', |
|
|
'Aamazing', |
|
|
'CM-1528-FS', |
|
|
'28-64', |
|
|
'47-104' |
|
248 |
);"; |
);"; |
249 |
|
|
250 |
# input |
# input |
251 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
252 |
"insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');";) |
"insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');";) |