1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Id$ |
3 |
# <niro@magellan-linux.de> |
# <niro@magellan-linux.de> |
4 |
|
|
5 |
#%rlevels: 7:s 0:k 6:k |
#%rlevels: 7:s 0:k |
6 |
#%start: 41 |
#%start: 41 |
7 |
#%stop: 01 |
#%stop: 01 |
8 |
|
|
11 |
#%before: |
#%before: |
12 |
#%after: |
#%after: |
13 |
|
|
|
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.11 2005-04-18 22:34:56 niro Exp $ |
|
|
|
|
14 |
# 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 |
15 |
# if not it runs the autoconfiguration script |
# if not it runs the autoconfiguration script |
16 |
# these settings will be used for client setup |
# these settings will be used for client setup |
19 |
# if no changes are at server side they will be kept, if yes the get updated. |
# if no changes are at server side they will be kept, if yes the get updated. |
20 |
# the server settings has higher priority. |
# the server settings has higher priority. |
21 |
|
|
22 |
source /etc/sysconfig/rc |
source /etc/conf.d/rc |
23 |
source $rc_functions |
source $rc_functions |
24 |
|
|
25 |
#mysql settings |
# mysql settings |
26 |
source /etc/alxconfig-ng/config.rc |
source /etc/alxconfig-ng/config.rc |
27 |
|
|
28 |
|
# helper functions |
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 |
source /usr/lib/alxconfig-ng/functions/config_modules |
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 |
source /usr/lib/alxconfig-ng/functions/config_auth |
37 |
source /usr/lib/alxconfig-ng/functions/config_ssh_auth |
source /usr/lib/alxconfig-ng/functions/config_ssh_auth |
38 |
|
source /usr/lib/alxconfig-ng/functions/config_versions |
39 |
|
|
40 |
#check if mysql is available |
# other needed vars |
|
[ -x /usr/bin/mysql ] && MYSQL_ALX=true |
|
|
|
|
|
#other needed vars |
|
41 |
ALX_HW_DETECT=false |
ALX_HW_DETECT=false |
42 |
|
ALX_FORCED_RECHECK=false |
43 |
|
ALX_RESET_SETTINGS=false |
44 |
|
ALX_CONFD_NETWORKING=false |
45 |
|
|
46 |
#unset vars which may kill us |
# unset vars which may kill us |
47 |
unset ALX_SERIAL ALX_STATE |
unset ALX_SERIAL ALX_STATE |
48 |
|
|
49 |
|
|
50 |
#setup needed directories |
# setup needed directories |
51 |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
[ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
52 |
|
|
53 |
|
|
54 |
update_system_settings(){ |
# read_cmdline ${item} |
55 |
|
read_cmdline() |
56 |
|
{ |
57 |
|
local i |
58 |
|
|
59 |
|
for i in $(< /proc/cmdline) |
60 |
|
do |
61 |
|
[[ ${i} = $1 ]] && return 0 |
62 |
|
done |
63 |
|
|
64 |
|
return 1 |
65 |
|
} |
66 |
|
|
67 |
|
update_system_settings() |
68 |
|
{ |
69 |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} |
70 |
|
|
71 |
# get the modules settings |
# get the modules settings |
88 |
config_auth |
config_auth |
89 |
|
|
90 |
# exchange ssh rsa keys |
# exchange ssh rsa keys |
91 |
config_ssh_auth |
HOME=/root config_ssh_auth |
92 |
|
|
93 |
|
# import version info |
94 |
|
config_version |
95 |
} |
} |
96 |
|
|
97 |
get_system_serial(){ |
get_system_serial() |
98 |
|
{ |
99 |
|
local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE |
100 |
|
|
101 |
local CUR_IP CUR_MAC CUR_MTIME |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
102 |
|
then |
103 |
|
ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)" |
104 |
|
else |
105 |
|
ALX_IFACE="eth0" |
106 |
|
fi |
107 |
|
|
108 |
#check if serial file exists |
# check if serial file exists |
109 |
if [ -f /etc/alxconfig-ng/serial ] |
if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]] |
110 |
then |
then |
111 |
source /etc/alxconfig-ng/serial |
source /etc/alxconfig-ng/serial |
112 |
|
|
113 |
#start preliminary networking (dhcp) |
# start preliminary networking (dhcp) |
114 |
preliminary_network start |
preliminary_network start |
115 |
|
|
116 |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
# check if mysql server is reachable |
117 |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
# if not abort this script |
118 |
|
if ! reach_mysql_server |
119 |
|
then |
120 |
|
preliminary_network stop |
121 |
|
exit 1 |
122 |
|
fi |
123 |
|
|
124 |
|
CUR_IP=$(ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') |
125 |
|
CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) |
126 |
CUR_MTIME=$(date +%s) |
CUR_MTIME=$(date +%s) |
127 |
|
|
128 |
echo -e ${COLOREDSTAR} "Trying to validate my serial ..." |
echo -e ${COLOREDSTAR} "Trying to validate my serial ..." |
129 |
|
|
130 |
#nice serial output |
# nice serial output |
131 |
$CURS_UP |
$CURS_UP |
132 |
$SET_WCOL |
$SET_WCOL |
133 |
echo "[ SN: ${ALX_SERIAL} ]" |
echo "[ SN: ${ALX_SERIAL} ]" |
136 |
then |
then |
137 |
ALX_STATE="ok" |
ALX_STATE="ok" |
138 |
else |
else |
139 |
|
# abort on non valid serial |
140 |
ALX_STATE="invalid serial" |
ALX_STATE="invalid serial" |
141 |
|
echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state |
142 |
|
show_invalid_serial_msg |
143 |
|
exit 1 |
144 |
fi |
fi |
145 |
|
|
146 |
else |
else |
147 |
#run hardware detection |
# run hardware detection |
148 |
echo |
echo |
149 |
echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} |
if [[ ${ALX_FORCED_RECHECK} = true ]] |
150 |
|
then |
151 |
|
echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} |
152 |
|
# always disable CONFD_NETWORKING here |
153 |
|
export ALX_CONFD_NETWORKING="false" |
154 |
|
else |
155 |
|
echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} |
156 |
|
fi |
157 |
ALX_HW_DETECT=true |
ALX_HW_DETECT=true |
158 |
/etc/init.d/hwdetect start |
hwsetup |
159 |
|
|
160 |
#set hostname to alx_default_hostname |
# set hostname to alx_default_hostname |
161 |
|
# use old hostname if this is a forced re-check |
162 |
|
[[ ${ALX_FORCED_RECHECK} = true ]] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)" |
163 |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
164 |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
165 |
|
|
166 |
#update the hostname on the system for sure |
# update the hostname on the system for sure |
167 |
echo "${HOSTNAME}" > /etc/hostname |
echo "${HOSTNAME}" > /etc/hostname |
168 |
|
|
169 |
#start preliminary networking (dhcp) |
# start preliminary networking (dhcp) |
170 |
preliminary_network start |
preliminary_network start |
171 |
|
|
172 |
|
# check if mysql server is reachable |
173 |
|
# if not abort this script |
174 |
|
if ! reach_mysql_server |
175 |
|
then |
176 |
|
preliminary_network stop |
177 |
|
exit 1 |
178 |
|
fi |
179 |
|
|
180 |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') |
181 |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) |
182 |
CUR_MTIME=$(date +%s) |
CUR_MTIME=$(date +%s) |
183 |
|
|
184 |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
# abort now if this is a forced re-check |
185 |
|
if [[ ${ALX_FORCED_RECHECK} = true ]] |
186 |
|
then |
187 |
|
# but first check the serial |
188 |
|
source /etc/alxconfig-ng/serial |
189 |
|
|
190 |
#request new serial |
echo -e ${COLOREDSTAR} "Trying to validate my serial ..." |
|
#ALX_REG_DATE="$(date +%F)" |
|
191 |
|
|
192 |
#we're using the mtime now (better for vaildating the serial) |
# nice serial output |
193 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
$CURS_UP |
194 |
"insert into client_serials( |
$SET_WCOL |
195 |
mtime, |
echo "[ SN: ${ALX_SERIAL} ]" |
|
mac |
|
|
) |
|
|
values( |
|
|
'${CUR_MTIME}', |
|
|
'${CUR_MAC}' |
|
|
);" |
|
196 |
|
|
197 |
#then validate and retrieve serial |
if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}" |
198 |
|
then |
199 |
|
ALX_STATE="ok" |
200 |
|
else |
201 |
|
# abort on non valid serial |
202 |
|
ALX_STATE="invalid serial" |
203 |
|
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
204 |
|
show_invalid_serial_msg |
205 |
|
exit 1 |
206 |
|
fi |
207 |
|
|
208 |
### warning must be changed that only the LAST ID will be fetched, ### |
# write current state to temp file |
209 |
### or you get error if the computer name and date are the same ### |
echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state |
210 |
### you have more than one serial number then ### |
[ -f /hardware-auto-detection ] && rm /hardware-auto-detection |
211 |
|
|
212 |
|
# now export ALX_FORCED_RECHECK=true |
213 |
|
# that the setting will be updated not inserted ! |
214 |
|
export ALX_FORCED_RECHECK=true |
215 |
|
return 0 |
216 |
|
fi |
217 |
|
|
218 |
#select highest id only (added max) |
echo -e ${COLOREDSTAR} "Trying to get new serial ..." |
219 |
ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
220 |
"select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'") |
# request a new serial; one command now (cause must be done in the same session) |
221 |
|
ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); |
222 |
|
select last_insert_id();") |
223 |
|
|
224 |
if [ "${ALX_SERIAL}" != NULL ] |
if [[ ${ALX_SERIAL} != NULL ]] |
225 |
then |
then |
226 |
#nice serial output |
# nice serial output |
227 |
$CURS_UP |
$CURS_UP |
228 |
$SET_WCOL |
$SET_WCOL |
229 |
echo "[ SN: ${ALX_SERIAL} ]" |
echo "[ SN: ${ALX_SERIAL} ]" |
230 |
|
|
231 |
#set ALX_STATE to ok so everybody that everything was ok |
# set ALX_STATE to ok so everybody knows that everything was ok |
232 |
ALX_STATE=ok |
ALX_STATE=ok |
233 |
|
|
234 |
echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial |
echo "ALX_SERIAL=\"${ALX_SERIAL}\"" > /etc/alxconfig-ng/serial |
235 |
echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial |
echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial |
236 |
|
|
237 |
evaluate_retval |
evaluate_retval |
238 |
else |
else |
239 |
#print false (works only if this is the first statement here) |
# print false (works only if this is the first statement here) |
240 |
evaluate_retval |
evaluate_retval |
241 |
|
|
242 |
#set ALX_STATE to error so everybody sees there was an error |
# set ALX_STATE to error so everybody sees there was an error |
243 |
ALX_STATE=error |
ALX_STATE=error |
244 |
|
|
245 |
#show an error that no new serial was found |
# show an error that no new serial was found |
246 |
#nice serial output |
# nice serial output |
247 |
$CURS_UP |
$CURS_UP |
248 |
$SET_WCOL |
$SET_WCOL |
249 |
echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]" |
echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]" |
250 |
fi |
fi |
251 |
fi |
fi |
252 |
|
|
253 |
#write current state to temp file |
# write current state to temp file |
254 |
echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state |
echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state |
255 |
|
echo "ALX_IFACE=\"${ALX_IFACE}\"" >> /etc/alxconfig-ng/state/state |
256 |
} |
} |
257 |
|
|
258 |
|
|
259 |
check_is_configured() { |
check_is_configured() |
260 |
|
{ |
261 |
if [ -f /etc/alxconfig-ng/state/configured ] |
if [ -f /etc/alxconfig-ng/state/configured ] |
262 |
then |
then |
263 |
export ALX_CONFIGURED=true |
export ALX_CONFIGURED=true |
268 |
|
|
269 |
|
|
270 |
# imports current settings to the database resolved by the hardware detection |
# imports current settings to the database resolved by the hardware detection |
271 |
import_settings_to_db() { |
import_settings_to_db() |
272 |
#note: networking is always 'dhcp' if hw was autodetected |
{ |
273 |
#note: default_domain/hostname is set in config.rc |
# note: networking is always 'dhcp' if hw was autodetected |
274 |
|
# note: default_domain/hostname is set in config.rc |
275 |
|
|
276 |
#to be safe, we do some sanity checks |
# to be safe, we do some sanity checks |
277 |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
278 |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
279 |
|
|
280 |
#vars used by hwdetect |
# vars used by hwsetup |
281 |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
282 |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
283 |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
284 |
|
|
285 |
#get setting from hwdetect |
# get setting from hwsetup |
286 |
source /etc/sysconfig/hwsetup/knoppix |
source /etc/conf.d/hwsetup/knoppix |
287 |
source /etc/sysconfig/hwsetup/mouse |
source /etc/conf.d/hwsetup/mouse |
288 |
|
|
289 |
echo |
echo |
290 |
echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} |
291 |
|
|
292 |
#network |
# network |
293 |
echo -e " Network settings ..." |
echo -e " Network settings ..." |
294 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
295 |
"insert into cfg_network( |
then |
296 |
hostname, |
# get settings |
297 |
serial, |
#source ${rc_base}/init.d/network &> /dev/null |
298 |
module, |
for iface in $(onboot_interface_list ${network_settings}/net.*) |
299 |
domain, |
do |
300 |
networking |
[[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue |
301 |
) |
echo "WARNING: only importing settings for interface [ ${iface} ] !" |
302 |
values( |
source ${network_settings}/net.${iface} || exit 1 |
303 |
'${ALX_DEFAULT_HOSTNAME}', |
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
304 |
'${ALX_SERIAL}', |
|
305 |
'${NETCARD_DRIVER}', |
mysqldo "insert into cfg_network( |
306 |
'${ALX_DEFAULT_DOMAIN}', |
hostname, |
307 |
'dhcp' |
serial, |
308 |
);" |
module, |
309 |
|
domain, |
310 |
|
networking, |
311 |
|
netmask, |
312 |
|
dns, |
313 |
|
gateway, |
314 |
|
broadcast, |
315 |
|
ip, |
316 |
|
forcemacto, |
317 |
|
wireless_bitrate, |
318 |
|
wireless_channel, |
319 |
|
wireless_essid, |
320 |
|
wireless_frequency, |
321 |
|
wireless_mode, |
322 |
|
wireless_nick, |
323 |
|
wireless_auth_mode, |
324 |
|
wireless_key_length, |
325 |
|
wireless_key, |
326 |
|
wireless_key_ascii |
327 |
|
) |
328 |
|
values( |
329 |
|
'${ALX_DEFAULT_HOSTNAME}', |
330 |
|
'${ALX_SERIAL}', |
331 |
|
'${NETCARD_DRIVER}', |
332 |
|
'${ALX_DEFAULT_DOMAIN}', |
333 |
|
'${NETWORKING}', |
334 |
|
'${NETMASK}', |
335 |
|
'${NAMESERVER}', |
336 |
|
'${GATEWAY}', |
337 |
|
'${BROADCAST}', |
338 |
|
'${IP}', |
339 |
|
'${FORCE_MAC_TO}', |
340 |
|
'${WIRELESS_BITRATE}', |
341 |
|
'${WIRELESS_CHANNEL}', |
342 |
|
'${WIRELESS_ESSID}', |
343 |
|
'${WIRELESS_FREQUENCY}', |
344 |
|
'${WIRELESS_MODE}', |
345 |
|
'${WIRELESS_NICK}', |
346 |
|
'${WIRELESS_AUTH_MODE}', |
347 |
|
'${WIRELESS_KEY_LENGTH}', |
348 |
|
'${WIRELESS_KEY}', |
349 |
|
'${WIRELESS_KEY_ASCII}' |
350 |
|
);" |
351 |
|
|
352 |
|
# only insert the *FIRST* iface |
353 |
|
break |
354 |
|
done |
355 |
|
else |
356 |
|
mysqldo "insert into cfg_network( |
357 |
|
hostname, |
358 |
|
serial, |
359 |
|
module, |
360 |
|
domain, |
361 |
|
networking |
362 |
|
) |
363 |
|
values( |
364 |
|
'${ALX_DEFAULT_HOSTNAME}', |
365 |
|
'${ALX_SERIAL}', |
366 |
|
'${NETCARD_DRIVER}', |
367 |
|
'${ALX_DEFAULT_DOMAIN}', |
368 |
|
'dhcp' |
369 |
|
);" |
370 |
|
fi |
371 |
evaluate_retval |
evaluate_retval |
372 |
|
|
373 |
#xserver |
# xserver |
374 |
echo -e " Graphic settings ..." |
echo -e " Graphic settings ..." |
375 |
#xserver general |
# xserver general |
376 |
( mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
( mysqldo "insert into cfg_graphic( |
|
"insert into cfg_graphic( |
|
377 |
serial, |
serial, |
378 |
module, |
module, |
379 |
resolution, |
resolution, |
380 |
depth, |
depth, |
381 |
monitorid |
refresh_rate |
382 |
) |
) |
383 |
values( |
values( |
384 |
'${ALX_SERIAL}', |
'${ALX_SERIAL}', |
385 |
'${XMODULE}', |
'${XMODULE}', |
386 |
'1024x768', |
'1024x768', |
387 |
'16', |
'16', |
388 |
'0' |
'60' |
389 |
);"; ) |
);"; ) |
390 |
evaluate_retval |
evaluate_retval |
391 |
|
|
392 |
# input |
# input |
393 |
echo -e " Input settings ..." |
echo -e " Input settings ..." |
394 |
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}');" |
|
395 |
evaluate_retval |
evaluate_retval |
396 |
|
|
397 |
# auth |
# auth |
398 |
echo -e " Authentifcation settings ..." |
echo -e " Authentification settings ..." |
399 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into client_auth( |
|
"insert into client_auth( |
|
400 |
serial, |
serial, |
401 |
username, |
username, |
402 |
shell, |
shell, |
416 |
|
|
417 |
# exchange ssh rsa keys - the first boot needs this ! |
# exchange ssh rsa keys - the first boot needs this ! |
418 |
# or no reboot will work via the webadmin |
# or no reboot will work via the webadmin |
419 |
echo -e " SSH authentifcation settings ..." |
echo -e " SSH authentification settings ..." |
420 |
config_ssh_auth |
HOME=/root config_ssh_auth |
421 |
evaluate_retval |
evaluate_retval |
422 |
|
|
423 |
# input |
# autostart |
424 |
echo -e " Autostart settings ..." |
echo -e " Autostart settings ..." |
425 |
mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
426 |
"insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
|
427 |
|
# screensaver |
428 |
|
echo -e " Screensaver settings ..." |
429 |
|
mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" |
430 |
|
|
431 |
|
# version info |
432 |
|
local alx_os |
433 |
|
local alx_utils |
434 |
|
alx_os="$(< /etc/mageversion)" |
435 |
|
alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" |
436 |
|
alx_utils="${alx_utils/alxconfig-ng-alx-}" |
437 |
|
mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')" |
438 |
|
|
439 |
evaluate_retval |
evaluate_retval |
440 |
} |
} |
441 |
|
|
442 |
|
# imports current settings to the database resolved by the hardware detection |
443 |
|
update_settings_in_db() |
444 |
|
{ |
445 |
|
# note: networking is always 'dhcp' if hw was autodetected |
446 |
|
# note: default_domain/hostname is set in config.rc or exported |
447 |
|
# note: we updating only hardware settings here ! |
448 |
|
|
449 |
|
# to be safe, we do some sanity checks |
450 |
|
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
451 |
|
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
452 |
|
|
453 |
|
# vars used by hwsetup |
454 |
|
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
455 |
|
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
456 |
|
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
457 |
|
|
458 |
|
# get setting from hwsetup |
459 |
|
source /etc/conf.d/hwsetup/knoppix |
460 |
|
source /etc/conf.d/hwsetup/mouse |
461 |
|
|
462 |
|
echo |
463 |
|
echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT} |
464 |
|
|
465 |
|
# network |
466 |
|
echo -e " Network settings ..." |
467 |
|
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
468 |
|
then |
469 |
|
# get settings |
470 |
|
#source ${rc_base}/init.d/network &> /dev/null |
471 |
|
for iface in $(onboot_interface_list ${network_settings}/net.*) |
472 |
|
do |
473 |
|
[[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue |
474 |
|
echo "WARNING: only importing settings for interface [ ${iface} ] !" |
475 |
|
source ${network_settings}/net.${iface} || exit 1 |
476 |
|
NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" |
477 |
|
|
478 |
|
mysqldo "update cfg_network set |
479 |
|
hostname='${ALX_DEFAULT_HOSTNAME}', |
480 |
|
module='${NETCARD_DRIVER}', |
481 |
|
domain='${ALX_DEFAULT_DOMAIN}', |
482 |
|
networking='${NETWORKING}', |
483 |
|
netmask='${NETMASK}', |
484 |
|
dns='${NAMESERVER}', |
485 |
|
gateway='${GATEWAY}', |
486 |
|
broadcast='${BROADCAST}', |
487 |
|
ip='${IP}', |
488 |
|
forcemacto='${FORCE_MAC_TO}', |
489 |
|
wireless_bitrate='${WIRELESS_BITRATE}', |
490 |
|
wireless_channel='${WIRELESS_CHANNEL}', |
491 |
|
wireless_essid='${WIRELESS_ESSID}', |
492 |
|
wireless_frequency='${WIRELESS_FREQUENCY}', |
493 |
|
wireless_mode='${WIRELESS_MODE}', |
494 |
|
wireless_nick='${WIRELESS_NICK}', |
495 |
|
wireless_auth_mode='${WIRELESS_AUTH_MODE}', |
496 |
|
wireless_key_length='${WIRELESS_KEY_LENGTH}', |
497 |
|
wireless_key='${WIRELESS_KEY}', |
498 |
|
wireless_key_ascii='${WIRELESS_KEY_ASCII}' |
499 |
|
where serial=${ALX_SERIAL};" |
500 |
|
|
501 |
|
# only insert the *FIRST* iface |
502 |
|
break |
503 |
|
done |
504 |
|
else |
505 |
|
mysqldo "update cfg_network set |
506 |
|
hostname='${ALX_DEFAULT_HOSTNAME}', |
507 |
|
module='${NETCARD_DRIVER}', |
508 |
|
domain='${ALX_DEFAULT_DOMAIN}', |
509 |
|
networking='dhcp' |
510 |
|
where serial=${ALX_SERIAL};" |
511 |
|
fi |
512 |
|
evaluate_retval |
513 |
|
|
514 |
|
# xserver |
515 |
|
echo -e " Graphic settings ..." |
516 |
|
# xserver general |
517 |
|
mysqldo "update cfg_graphic set |
518 |
|
module='${XMODULE}', |
519 |
|
resolution='1024x768', |
520 |
|
depth='16', |
521 |
|
refresh_rate='60' |
522 |
|
where serial=${ALX_SERIAL};" |
523 |
|
evaluate_retval |
524 |
|
|
525 |
|
# input |
526 |
|
echo -e " Input settings ..." |
527 |
|
mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};" |
528 |
|
evaluate_retval |
529 |
|
|
530 |
|
# version info |
531 |
|
local alx_os |
532 |
|
local alx_utils |
533 |
|
alx_os="$(< /etc/mageversion)" |
534 |
|
alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" |
535 |
|
alx_utils="${alx_utils/alxconfig-ng-alx-}" |
536 |
|
mysqldo "update client_version set os='${alx_os}', utils='${alx_utils}' where serial=${ALX_SERIAL};" |
537 |
|
} |
538 |
|
|
539 |
# imports current settings to the local system resolved by the hardware detection |
# imports current settings to the local system resolved by the hardware detection |
540 |
# we only need the network settings |
# we only need the network settings |
541 |
import_settings_local(){ |
import_settings_local() |
542 |
#note: networking is always 'dhcp' if hw was autodetected |
{ |
543 |
#note: default_domain/hostname is set in config.rc |
# note: networking is always 'dhcp' if hw was autodetected |
544 |
|
# note: default_domain/hostname is set in config.rc |
545 |
|
|
546 |
#to be safe, we do some sanity checks |
# to be safe, we do some sanity checks |
547 |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
[ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
548 |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
[ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
549 |
|
|
550 |
#vars used by hwdetect |
# vars used by hwsetup |
551 |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
552 |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
553 |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
554 |
|
|
555 |
#get setting from hwdetect |
# get setting from hwsetup |
556 |
source /etc/sysconfig/hwsetup/knoppix |
source /etc/conf.d/hwsetup/knoppix |
557 |
|
|
558 |
echo |
echo |
559 |
echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} |
560 |
|
|
561 |
[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
if [[ ${ALX_CONFD_NETWORKING} = false ]] |
562 |
echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules |
then |
563 |
evaluate_retval |
#[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
564 |
|
#echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules |
565 |
|
|
566 |
#set system state to 'already configured' |
# set an device alias for modprobe.conf and modules.conf |
567 |
|
[ ! -d /etc/modules.d ] && install -d /etc/modules.d |
568 |
|
[ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d |
569 |
|
echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0 |
570 |
|
echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0 |
571 |
|
|
572 |
|
# regenerate modprobe.conf |
573 |
|
[ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf" |
574 |
|
evaluate_retval |
575 |
|
fi |
576 |
|
|
577 |
|
# set system state to 'already configured' |
578 |
touch /etc/alxconfig-ng/state/configured |
touch /etc/alxconfig-ng/state/configured |
579 |
|
|
580 |
# default passwords are bad |
# install slim desktopmanager configuration |
581 |
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") root |
config_display_manager |
582 |
#usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER} |
|
583 |
#smbpasswd -a root foobar |
# if only an recheck was forced than abort now |
584 |
|
[[ ${ALX_FORCED_RECHECK} = true ]] && return 0 |
585 |
|
|
586 |
|
# create a fresh fluxbox directory |
587 |
|
[ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox |
588 |
|
install -d ${ALX_UNPRIV_HOME}/.fluxbox |
589 |
|
|
590 |
|
# now generate fluxbox config files |
591 |
|
|
592 |
|
# fluxbox main config |
593 |
|
cat ${ALX_SKELETONS}/fluxbox/init \ |
594 |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/init |
595 |
|
|
596 |
|
# fluxbox autostart |
597 |
|
cat ${ALX_SKELETONS}/fluxbox/apps \ |
598 |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
599 |
|
|
600 |
|
# fluxbox menu header |
601 |
|
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
602 |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
603 |
|
|
604 |
|
# now fix it with proper messages :P |
605 |
|
local ver="$(< /etc/mageversion)" |
606 |
|
sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" \ |
607 |
|
${ALX_UNPRIV_HOME}/.fluxbox/menu |
608 |
|
|
609 |
|
# add a newline (maybe there is no crlf in the header) |
610 |
|
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
611 |
|
|
612 |
|
# fluxbox menu footer |
613 |
|
cat ${ALX_SKELETONS}/fluxbox/menu.footer \ |
614 |
|
>> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
615 |
|
|
616 |
|
# add a newline (maybe there is no crlf in the footer) |
617 |
|
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
618 |
|
|
619 |
|
|
620 |
|
# setup some standart icons (sysinfo.lnk) |
621 |
|
# basic config |
622 |
|
cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc |
623 |
|
|
624 |
|
# clean desktop icon location |
625 |
|
[ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop |
626 |
|
install -d ${ALX_UNPRIV_HOME}/.xtdesktop |
627 |
|
|
628 |
|
# last but not least gen a icon with some sys informations |
629 |
|
local sysinfo |
630 |
|
local osversion |
631 |
|
local xres |
632 |
|
local yres |
633 |
|
|
634 |
|
osversion="$(< /etc/mageversion)" |
635 |
|
sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
636 |
|
|
637 |
|
# at first boot we got always a resolution of 1024x768-16@60 |
638 |
|
# middle of the screen |
639 |
|
# (no txt - length required, xtdesk manage that itself) |
640 |
|
xres="$((1024 / 2))" |
641 |
|
# default y pos (full yres -22 !) |
642 |
|
yres="$((768 - 22 ))" |
643 |
|
|
644 |
|
generate_icon \ |
645 |
|
--name "${sysinfo}" \ |
646 |
|
--command "exit 0" \ |
647 |
|
--icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ |
648 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ |
649 |
|
--xres "${xres}" \ |
650 |
|
--yres "${yres}" \ |
651 |
|
--icon-width "1" \ |
652 |
|
--icon-height "1" |
653 |
|
|
654 |
|
# create a xinitrc |
655 |
|
echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc |
656 |
|
|
657 |
|
# set correct permissions |
658 |
|
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
659 |
|
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
660 |
|
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
661 |
|
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
662 |
|
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
663 |
|
chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc |
664 |
} |
} |
665 |
|
|
666 |
#start|stop |
# start|stop |
667 |
preliminary_network(){ |
preliminary_network() |
668 |
|
{ |
669 |
local module |
local module |
670 |
|
local modulesconf |
671 |
|
|
672 |
if [ -f /etc/alxconfig-ng/state/configured ] |
if [ -f /etc/alxconfig-ng/state/configured ] |
673 |
then |
then |
674 |
#get module name |
# compat for old clients |
675 |
module=$(cat ${SETTINGSPATH}/modules) |
if [ -f ${SETTINGSPATH}/modules ] |
676 |
modprobe ${module} |
then |
677 |
|
# get module name |
678 |
|
module=$(cat ${SETTINGSPATH}/modules) |
679 |
|
modprobe ${module} |
680 |
|
fi |
681 |
|
|
682 |
|
# check modprobe.conf |
683 |
|
if [[ $(kernel_major_version) = 2.4 ]] |
684 |
|
then |
685 |
|
modulesconf="/etc/modules.conf" |
686 |
|
else |
687 |
|
modulesconf="/etc/modprobe.conf" |
688 |
|
fi |
689 |
|
if [[ -z $(grep eth0 ${modulesconf}) ]] |
690 |
|
then |
691 |
|
modules-update force |
692 |
|
fi |
693 |
else |
else |
694 |
#vars used by hwdetect |
# vars used by hwsetup |
695 |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
696 |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
697 |
|
|
698 |
#get setting from hwdetect |
# get setting from hwsetup |
699 |
source /etc/sysconfig/hwsetup/knoppix |
source /etc/conf.d/hwsetup/knoppix |
700 |
modprobe ${NETCARD_DRIVER} |
modprobe ${NETCARD_DRIVER} |
701 |
fi |
fi |
702 |
|
|
705 |
# keeping like always safe: |
# keeping like always safe: |
706 |
# no network should be startet here, |
# no network should be startet here, |
707 |
# so we can delete all pid files if one exists |
# so we can delete all pid files if one exists |
708 |
if ps -A|grep dhcpcd > /dev/null |
if ps -A|grep udhcpc > /dev/null |
709 |
then |
then |
710 |
echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT} |
echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT} |
711 |
dhcpcd -k |
killall udhcpc &> /dev/null |
712 |
sleep 1 |
sleep 1 |
|
else |
|
|
rm -f /var/run/dhcpcd-eth?.pid |
|
713 |
fi |
fi |
714 |
|
[[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \ |
715 |
|
${rc_base}/init.d/network stop |
716 |
|
|
717 |
echo -e ${COLMAGENTA}"Starting preliminary network ... "${COLDEFAULT} |
echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} |
|
dhcpcd &> /dev/null |
|
718 |
|
|
719 |
# aka_fix ######################################## |
# start network configured from /etc/conf.d |
720 |
#ifconfig eth0 128.20.222.222 netmask 255.255.0.0 up |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
721 |
#route del default gw 128.20.50.13 &> /dev/null |
then |
722 |
#route add default gw 128.20.50.21 &> /dev/null |
${rc_base}/init.d/network start |
723 |
#echo "nameserver 128.20.50.21" > /etc/resolv.conf |
else |
724 |
################################################## |
echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT} |
725 |
|
# -t 10 timeout of 10 secs |
726 |
evaluate_retval |
udhcpc -t 10 &> /dev/null |
727 |
|
evaluate_retval |
728 |
|
fi |
729 |
;; |
;; |
730 |
|
|
731 |
stop) |
stop) |
732 |
echo -e ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT} |
echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT} |
733 |
ifconfig eth0 down |
if [[ ${ALX_CONFD_NETWORKING} = true ]] |
734 |
|
then |
735 |
|
${rc_base}/init.d/network stop |
736 |
|
else |
737 |
|
echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT} |
738 |
|
ifconfig eth0 down |
739 |
|
fi |
740 |
if ps -A|grep dhcpcd > /dev/null |
if ps -A|grep dhcpcd > /dev/null |
741 |
then |
then |
742 |
dhcpcd -z &> /dev/null |
dhcpcd -z &> /dev/null |
743 |
|
sleep 1 |
744 |
fi |
fi |
745 |
evaluate_retval |
evaluate_retval |
746 |
;; |
;; |
751 |
esac |
esac |
752 |
} |
} |
753 |
|
|
754 |
|
reset_system_settings() |
755 |
|
{ |
756 |
|
# force load of de kbdkeys |
757 |
|
loadkeys -q de |
758 |
|
echo |
759 |
|
echo -en ${COLRED} |
760 |
|
echo -n "*** Warning: you are about to reset *all* local settings on this system!" |
761 |
|
echo -e ${COLDEFAULT} |
762 |
|
echo "*** Do you really want to continue ?" |
763 |
|
echo -n "*** Enter 'yes' to continue, anything else to abort: " |
764 |
|
read kbinsert |
765 |
|
if [[ ${kbinsert} = yes ]] |
766 |
|
then |
767 |
|
echo -en ${COLRED} |
768 |
|
echo -n "*** OK, you really want it ... killing all settings: " |
769 |
|
for i in 3 2 1 now |
770 |
|
do |
771 |
|
echo -n " ${i}" |
772 |
|
sleep 1 |
773 |
|
done |
774 |
|
echo -e ${COLDEFAULT} |
775 |
|
|
776 |
|
## reset all settings: |
777 |
|
rm -rf ${SETTINGSPATH}/* |
778 |
|
rm -f /etc/alxconfig-ng/serial |
779 |
|
rm -rf /etc/alxconfig-ng/state |
780 |
|
|
781 |
|
# clear all printers & net-shares |
782 |
|
:> /etc/cups/printers.conf |
783 |
|
:> /etc/samba/smb.conf |
784 |
|
|
785 |
|
# remove inetd, cups & smb from init |
786 |
|
rc-config del inetd &> /dev/null |
787 |
|
rc-config del cups &> /dev/null |
788 |
|
rc-config del samba &> /dev/null |
789 |
|
|
790 |
|
# remove all user settings |
791 |
|
[ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} |
792 |
|
|
793 |
|
# remove all ica-sessions |
794 |
|
find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm |
795 |
|
|
796 |
|
# remove all old nics and modules configs |
797 |
|
find /etc/conf.d -type f -name 'net.*' | xargs rm |
798 |
|
find /etc/modules.d -type f -name 'net.*' | xargs rm |
799 |
|
|
800 |
|
# restore default networking |
801 |
|
cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 |
802 |
|
|
803 |
|
echo "I am done now, press [Enter] to reboot system ..." |
804 |
|
else |
805 |
|
echo "Aborted, press [Enter] to reboot system ..." |
806 |
|
fi |
807 |
|
read |
808 |
|
reboot |
809 |
|
} |
810 |
|
|
811 |
|
onboot_interface_list() |
812 |
|
{ |
813 |
|
local file |
814 |
|
local devices |
815 |
|
local iface |
816 |
|
|
817 |
|
# get list of all devices |
818 |
|
for file in $@ |
819 |
|
do |
820 |
|
if [[ $(read_value ONBOOT ${file}) = yes ]] |
821 |
|
then |
822 |
|
iface="$(basename ${file} | sed s/net.//)" |
823 |
|
# exclude backup files |
824 |
|
case "${iface}" in |
825 |
|
*~) ;; |
826 |
|
*) devices="${devices} $(basename ${file} | sed s/net.//)" ;; |
827 |
|
esac |
828 |
|
fi |
829 |
|
done |
830 |
|
|
831 |
|
echo "${devices}" |
832 |
|
} |
833 |
|
|
834 |
|
# read values from net.* files |
835 |
|
read_value() |
836 |
|
{ |
837 |
|
local var="$1" |
838 |
|
local file="$2" |
839 |
|
local value |
840 |
|
|
841 |
|
# local all possible vars |
842 |
|
# global |
843 |
|
local ONBOOT |
844 |
|
local NETWORKING |
845 |
|
|
846 |
|
# static |
847 |
|
local IP |
848 |
|
local NETMASK |
849 |
|
local BROADCAST |
850 |
|
local NETWORKING |
851 |
|
local FORCE_MAC_TO |
852 |
|
|
853 |
|
# dhcp |
854 |
|
local DHCP_PROG |
855 |
|
local DHCP_START |
856 |
|
local DHCP_STOP |
857 |
|
|
858 |
|
# default gw |
859 |
|
local GATEWAY |
860 |
|
local GATEWAY_IF |
861 |
|
|
862 |
|
# wireless extensions |
863 |
|
local WIRELESS_AP |
864 |
|
local WIRELESS_AUTH_MODE |
865 |
|
local WIRELESS_BITRATE |
866 |
|
local WIRELESS_CHANNEL |
867 |
|
local WIRELESS_DEFAULT_KEY |
868 |
|
local WIRELESS_ESSID |
869 |
|
local WIRELESS_FREQUENCY |
870 |
|
local WIRELESS_KEY |
871 |
|
local WIRELESS_KEY_ASCII |
872 |
|
local WIRELESS_KEY_0 |
873 |
|
local WIRELESS_KEY_1 |
874 |
|
local WIRELESS_KEY_2 |
875 |
|
local WIRELESS_KEY_3 |
876 |
|
local WIRELESS_KEY_LENGTH |
877 |
|
local WIRELESS_MODE |
878 |
|
local WIRELESS_NICK |
879 |
|
local WIRELESS_NWID |
880 |
|
local WIRELESS_POWER |
881 |
|
|
882 |
|
source ${file} |
883 |
|
eval value=\$$(echo ${var}) |
884 |
|
echo "${value}" |
885 |
|
} |
886 |
|
|
887 |
case $1 in |
case $1 in |
888 |
start) |
start) |
889 |
#retrieve or validate current serial |
# check for global overrides |
890 |
|
[ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true |
891 |
|
[ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true |
892 |
|
read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true |
893 |
|
read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true |
894 |
|
|
895 |
|
# kill all settings if requested |
896 |
|
if [[ ${ALX_RESET_SETTINGS} = true ]] |
897 |
|
then |
898 |
|
reset_system_settings |
899 |
|
fi |
900 |
|
|
901 |
|
# retrieve or validate current serial |
902 |
get_system_serial |
get_system_serial |
903 |
if [ "${ALX_HW_DETECT}" == "true" ] |
if [[ ${ALX_HW_DETECT} = true ]] |
904 |
then |
then |
905 |
import_settings_to_db |
if [[ ${ALX_FORCED_RECHECK} = true ]] |
906 |
|
then |
907 |
|
update_settings_in_db |
908 |
|
else |
909 |
|
import_settings_to_db |
910 |
|
fi |
911 |
import_settings_local |
import_settings_local |
912 |
|
|
913 |
# here we should also exchange the ssh keys |
# here we should also exchange the ssh keys |
916 |
config_ssh_auth |
config_ssh_auth |
917 |
fi |
fi |
918 |
|
|
919 |
#now setup system configuration |
# now setup system configuration |
920 |
#alx_setup_or_whatever_it_will_be_called() |
# alx_setup_or_whatever_it_will_be_called() |
921 |
[ "${ALX_HW_DETECT}" == "false" ] && update_system_settings |
[[ ${ALX_HW_DETECT} = false ]] && update_system_settings |
922 |
|
|
923 |
#stop at last the preliminary networking (dhcp) |
# stop at last the preliminary networking (dhcp) |
924 |
preliminary_network stop |
preliminary_network stop |
925 |
;; |
;; |
926 |
|
|
927 |
stop) |
stop) |
928 |
#unset_alx_connected #--> now in alxsetstate-rc6 |
# unset_alx_connected #--> now in alxsetstate-rc6 |
929 |
# ! important !: del systemstate |
# ! important !: del systemstate |
930 |
[ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state |
[ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state |
931 |
sleep 0.1 |
sleep 0.1 |