Magellan Linux

Diff of /alx-src/branches/alxconf-060/init.d/alxsettings

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

alx-src/trunk/alxconfig-ng/init.d/alxsettings revision 337 by niro, Thu Sep 22 22:14:38 2005 UTC alx-src/branches/alxconf-060/init.d/alxsettings revision 2568 by niro, Mon Jul 4 21:16:51 2011 UTC
# Line 1  Line 1 
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    
# Line 11  Line 11 
11  #%before:  #%before:
12  #%after:  #%after:
13    
 # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.22 2005-09-22 22:14:38 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
# Line 21  Line 19 
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  # helper functions
29    source /usr/lib/alxconfig-ng/functions/common
30  source /usr/lib/alxconfig-ng/functions/mysqlfunctions  source /usr/lib/alxconfig-ng/functions/mysqlfunctions
31  source /usr/lib/alxconfig-ng/functions/serial_functions  source /usr/lib/alxconfig-ng/functions/serial_functions
32  source /usr/lib/alxconfig-ng/functions/config_modules  source /usr/lib/alxconfig-ng/functions/config_modules
# Line 37  source /usr/lib/alxconfig-ng/functions/c Line 36  source /usr/lib/alxconfig-ng/functions/c
36  source /usr/lib/alxconfig-ng/functions/config_x11  source /usr/lib/alxconfig-ng/functions/config_x11
37  source /usr/lib/alxconfig-ng/functions/config_auth  source /usr/lib/alxconfig-ng/functions/config_auth
38  source /usr/lib/alxconfig-ng/functions/config_ssh_auth  source /usr/lib/alxconfig-ng/functions/config_ssh_auth
39    source /usr/lib/alxconfig-ng/functions/config_versions
 # check if mysql is available  
 [ -x /usr/bin/mysql ] && MYSQL_ALX=true  
40    
41  # other needed vars  # other needed vars
42  ALX_HW_DETECT=false  ALX_HW_DETECT=false
# Line 54  unset ALX_SERIAL ALX_STATE Line 51  unset ALX_SERIAL ALX_STATE
51  # setup needed directories  # setup needed directories
52  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state
53    
   
 # read_cmdline ${item}  
 read_cmdline()  
 {  
  local i  
   
  for i in $(< /proc/cmdline)  
  do  
  [[ ${i} = $1 ]] && return 0  
  done  
   
  return 1  
 }  
   
54  update_system_settings()  update_system_settings()
55  {  {
56   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}   rc_mecho Checking system setup ...
57    
58   # get the modules settings   # get the modules settings
59   # ! is the first thing that must be configured !   # ! is the first thing that must be configured !
# Line 93  update_system_settings() Line 76  update_system_settings()
76    
77   # exchange ssh rsa keys   # exchange ssh rsa keys
78   HOME=/root config_ssh_auth   HOME=/root config_ssh_auth
79    
80     # import version info
81     config_version
82  }  }
83    
84  get_system_serial()  get_system_serial()
85  {  {
86     local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE
87    
88   local CUR_IP CUR_MAC CUR_MTIME   if [[ ${ALX_CONFD_NETWORKING} = true ]]
89     then
90     ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)"
91     else
92     ALX_IFACE="eth0"
93     fi
94    
95   # check if serial file exists   # check if serial file exists
96   if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]]   if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]]
# Line 116  get_system_serial() Line 108  get_system_serial()
108   exit 1   exit 1
109   fi   fi
110    
111   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
112   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
113   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
114    
115   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."   rc_print "Trying to validate my serial ..."
116    
117   # nice serial output   # nice serial output
118   $CURS_UP   $CURS_UP
# Line 133  get_system_serial() Line 125  get_system_serial()
125   else   else
126   # abort on non valid serial   # abort on non valid serial
127   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
128   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
129   show_invalid_serial_msg   show_invalid_serial_msg
130   exit 1   exit 1
131   fi   fi
# Line 143  get_system_serial() Line 135  get_system_serial()
135   echo   echo
136   if [[ ${ALX_FORCED_RECHECK} = true ]]   if [[ ${ALX_FORCED_RECHECK} = true ]]
137   then   then
138   echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT}   rc_mecho "Hardware autodetection forced by system-administrator"
139     # always disable CONFD_NETWORKING here
140     export ALX_CONFD_NETWORKING="false"
141   else   else
142   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}   rc_mecho "Preparing system for first boot"
143   fi   fi
144   ALX_HW_DETECT=true   ALX_HW_DETECT=true
145   /etc/init.d/hwdetect start   hwsetup
146    
147   # set hostname to alx_default_hostname   # set hostname to alx_default_hostname
148   # use old hostname if this is a forced re-check   # use old hostname if this is a forced re-check
# Line 170  get_system_serial() Line 164  get_system_serial()
164   exit 1   exit 1
165   fi   fi
166    
167   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')  
168   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
169     CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
170   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
171    
172   # abort now if this is a forced re-check   # abort now if this is a forced re-check
# Line 180  get_system_serial() Line 175  get_system_serial()
175   # but first check the serial   # but first check the serial
176   source /etc/alxconfig-ng/serial   source /etc/alxconfig-ng/serial
177    
178   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."   rc_print "Trying to validate my serial ..."
179    
180   # nice serial output   # nice serial output
181   $CURS_UP   $CURS_UP
# Line 199  get_system_serial() Line 194  get_system_serial()
194   fi   fi
195    
196   # write current state to temp file   # write current state to temp file
197   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
198   [ -f /hardware-auto-detection ] && rm /hardware-auto-detection   [ -f /hardware-auto-detection ] && rm /hardware-auto-detection
199    
200   # now export ALX_FORCED_RECHECK=true   # now export ALX_FORCED_RECHECK=true
# Line 208  get_system_serial() Line 203  get_system_serial()
203   return 0   return 0
204   fi   fi
205    
206   echo -e ${COLOREDSTAR} "Trying to get new serial ..."   rc_print "Trying to get new serial ..."
207    
208   # request a new serial; one command now (cause must be done in the same session)   # request a new serial; one command now (cause must be done in the same session)
209   ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');
  "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');  
210   select last_insert_id();")   select last_insert_id();")
211    
212   if [[ ${ALX_SERIAL} != NULL ]]   if [[ ${ALX_SERIAL} != NULL ]]
# Line 222  get_system_serial() Line 216  get_system_serial()
216   $SET_WCOL   $SET_WCOL
217   echo "[ SN: ${ALX_SERIAL} ]"   echo "[ SN: ${ALX_SERIAL} ]"
218    
219   # set ALX_STATE to ok so everybody that everything was ok   # set ALX_STATE to ok so everybody knows that everything was ok
220   ALX_STATE=ok   ALX_STATE=ok
221    
222   echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial   echo "ALX_SERIAL=\"${ALX_SERIAL}\"" > /etc/alxconfig-ng/serial
223   echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial   echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial
224    
225   evaluate_retval   evaluate_retval
226   else   else
# Line 245  get_system_serial() Line 239  get_system_serial()
239   fi   fi
240    
241   # write current state to temp file   # write current state to temp file
242   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
243     echo "ALX_IFACE=\"${ALX_IFACE}\"" >> /etc/alxconfig-ng/state/state
244  }  }
245    
246    
# Line 270  import_settings_to_db() Line 265  import_settings_to_db()
265   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
266   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
267    
268   # vars used by hwdetect   # vars used by hwsetup
269   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
270   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
271   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
272    
273   # get setting from hwdetect   # get setting from hwsetup
274   source /etc/sysconfig/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
275   source /etc/sysconfig/hwsetup/mouse   source /etc/conf.d/hwsetup/mouse
276    
277   echo   echo
278   echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT}   rc_mecho "Importing detected settings to database"
279    
280   # network   # network
281   echo -e "      Network settings ..."   rc_mecho "      Network settings ..."
282   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
283   then   then
284   # get settings   # get settings
  #source ${rc_base}/init.d/network &> /dev/null  
285   for iface in $(onboot_interface_list ${network_settings}/net.*)   for iface in $(onboot_interface_list ${network_settings}/net.*)
286   do   do
287   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
288   echo "WARNING: only importing settings for interface [ ${iface} ] !"   rc_echo "WARNING: only importing settings for interface [ ${iface} ] !"
289   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || echo "Error: could not read '${network_settings}/net.${iface}'"
290   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"
291    
292   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_network(
  "insert into cfg_network(  
293   hostname,   hostname,
294   serial,   serial,
295   module,   module,
# Line 347  import_settings_to_db() Line 340  import_settings_to_db()
340   break   break
341   done   done
342   else   else
343   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_network(
  "insert into cfg_network(  
344   hostname,   hostname,
345   serial,   serial,
346   module,   module,
# Line 366  import_settings_to_db() Line 358  import_settings_to_db()
358   evaluate_retval   evaluate_retval
359    
360   # xserver   # xserver
361   echo -e "      Graphic settings ..."   rc_mecho "      Graphic settings ..."
362   # xserver general   # xserver general
363   ( mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ( mysqldo "insert into cfg_graphic(
  "insert into cfg_graphic(  
364   serial,   serial,
365   module,   module,
366   resolution,   resolution,
367   depth,   depth,
368   monitorid   refresh_rate
369   )   )
370   values(   values(
371   '${ALX_SERIAL}',   '${ALX_SERIAL}',
372   '${XMODULE}',   '${XMODULE}',
373   '1024x768',   '1024x768',
374   '16',   '16',
375   '0'   '60'
376   );"; )   );"; )
377   evaluate_retval   evaluate_retval
378    
379   # input   # input
380   echo -e "      Input settings ..."   rc_mecho "      Input settings ..."
381   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}');"  
382   evaluate_retval   evaluate_retval
383    
384   # auth   # auth
385   echo -e "      Authentifcation settings ..."   rc_mecho "      Authentification settings ..."
386   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into client_auth(
  "insert into client_auth(  
387   serial,   serial,
388   username,   username,
389   shell,   shell,
# Line 414  import_settings_to_db() Line 403  import_settings_to_db()
403    
404   # exchange ssh rsa keys - the first boot needs this !   # exchange ssh rsa keys - the first boot needs this !
405   # or no reboot will work via the webadmin   # or no reboot will work via the webadmin
406   echo -e "      SSH authentifcation settings ..."   rc_mecho "      SSH authentification settings ..."
407   HOME=/root config_ssh_auth   HOME=/root config_ssh_auth
408   evaluate_retval   evaluate_retval
409    
410   # input   # autostart
411   echo -e "      Autostart settings ..."   rc_mecho "      Autostart settings ..."
412   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
413   "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"  
414     # screensaver
415     rc_mecho "      Screensaver settings ..."
416     mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"
417    
418     # version info
419     rc_mecho "      OS version info ..."
420     local alx_os
421     local alx_utils
422     alx_os="$(< /etc/mageversion)"
423     alx_utils="$(magequery -n alxconfig-ng | sed 's:.*\[\ \(.*\)\ \].*:\1:')"
424     alx_utils="${alx_utils/alxconfig-ng-}"
425     mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')"
426    
427   evaluate_retval   evaluate_retval
428  }  }
429    
# Line 436  update_settings_in_db() Line 438  update_settings_in_db()
438   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
439   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
440    
441   # vars used by hwdetect   # vars used by hwsetup
442   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
443   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
444   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
445    
446   # get setting from hwdetect   # get setting from hwsetup
447   source /etc/sysconfig/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
448   source /etc/sysconfig/hwsetup/mouse   source /etc/conf.d/hwsetup/mouse
449    
450   echo   echo
451   echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT}   rc_mecho "Updating detected settings in database"
452    
453   # network   # network
454   echo -e "      Network settings ..."   rc_mecho "      Network settings ..."
455   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
456   then   then
457   # get settings   # get settings
# Line 457  update_settings_in_db() Line 459  update_settings_in_db()
459   for iface in $(onboot_interface_list ${network_settings}/net.*)   for iface in $(onboot_interface_list ${network_settings}/net.*)
460   do   do
461   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
462   echo "WARNING: only importing settings for interface [ ${iface} ] !"   rc_echo "WARNING: only importing settings for interface [ ${iface} ] !"
463   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || exit 1
464   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"
465    
466   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_network set
  "update cfg_network set  
467   hostname='${ALX_DEFAULT_HOSTNAME}',   hostname='${ALX_DEFAULT_HOSTNAME}',
468   module='${NETCARD_DRIVER}',   module='${NETCARD_DRIVER}',
469   domain='${ALX_DEFAULT_DOMAIN}',   domain='${ALX_DEFAULT_DOMAIN}',
# Line 489  update_settings_in_db() Line 490  update_settings_in_db()
490   break   break
491   done   done
492   else   else
493   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_network set
  "update cfg_network set  
494   hostname='${ALX_DEFAULT_HOSTNAME}',   hostname='${ALX_DEFAULT_HOSTNAME}',
495   module='${NETCARD_DRIVER}',   module='${NETCARD_DRIVER}',
496   domain='${ALX_DEFAULT_DOMAIN}',   domain='${ALX_DEFAULT_DOMAIN}',
# Line 500  update_settings_in_db() Line 500  update_settings_in_db()
500   evaluate_retval   evaluate_retval
501    
502   # xserver   # xserver
503   echo -e "      Graphic settings ..."   rc_mecho "      Graphic settings ..."
504   # xserver general   # xserver general
505   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_graphic set
  "update cfg_graphic set  
506   module='${XMODULE}',   module='${XMODULE}',
507   resolution='1024x768',   resolution='1024x768',
508   depth='16',   depth='16',
509   monitorid='0'   refresh_rate='60'
510   where serial=${ALX_SERIAL};"   where serial=${ALX_SERIAL};"
511   evaluate_retval   evaluate_retval
512    
513   # input   # input
514   echo -e "      Input settings ..."   rc_mecho "      Input settings ..."
515   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};"
  "update cfg_input set  
  mouse='${XMOUSETYPE}'  
  where serial=${ALX_SERIAL};"  
516   evaluate_retval   evaluate_retval
517    
518     # version info
519     rc_mecho "      OS version info ..."
520     local alx_os
521     local alx_utils
522     alx_os="$(< /etc/mageversion)"
523     alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')"
524     alx_utils="${alx_utils/alxconfig-ng-alx-}"
525     mysqldo "update client_version set os='${alx_os}', utils='${alx_utils}' where serial=${ALX_SERIAL};"
526  }  }
527    
528  # imports current settings to the local system resolved by the hardware detection  # imports current settings to the local system resolved by the hardware detection
# Line 531  import_settings_local() Line 536  import_settings_local()
536   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
537   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
538    
539   # vars used by hwdetect   # vars used by hwsetup
540   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
541   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
542   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
543    
544   # get setting from hwdetect   # get setting from hwsetup
545   source /etc/sysconfig/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
546    
547   echo   echo
548   echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT}   rc_mecho "Importing detected settings to local system"
549    
550   if [[ ${ALX_CONFD_NETWORKING} = false ]]   if [[ ${ALX_CONFD_NETWORKING} = false ]]
551   then   then
  #[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}  
  #echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules  
   
552   # set an device alias for modprobe.conf   # set an device alias for modprobe.conf
553   [ ! -d /etc/modules.d ] && install -d /etc/modules.d   [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d
554   echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0   # update only if not the same (to speed up bootprocess - no depmod)
555     CONFIG="/etc/modprobe.d/net.${ALX_IFACE}.conf"
556     clearconfig
557     addconfig "alias ${ALX_IFACE} ${cfg_network_module}"
558    
559     # update confd-networking default iface
560     [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}
561     CONFIG="${SETTINGSPATH}/confd-networking"
562     clearconfig
563     addconfig "${ALX_IFACE}"
564    
565   # regenerate modprobe.conf   # regenerate modprobe.conf
566   [ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf"   [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!"
567   evaluate_retval   evaluate_retval
568   fi   fi
569    
570   # set system state to 'already configured'   # set system state to 'already configured'
571   touch /etc/alxconfig-ng/state/configured   touch /etc/alxconfig-ng/state/configured
572    
573     # install slim desktopmanager configuration
574     config_display_manager
575    
576   # if only an recheck was forced than abort now   # if only an recheck was forced than abort now
577   [[ ${ALX_FORCED_RECHECK} = true ]] && return 0   [[ ${ALX_FORCED_RECHECK} = true ]] && return 0
578    
# Line 569  import_settings_local() Line 583  import_settings_local()
583   # now generate fluxbox config files   # now generate fluxbox config files
584    
585   # fluxbox main config   # fluxbox main config
586   cat ${ALX_SKELETONS}/fluxbox/init \   local fbinit
587   > ${ALX_UNPRIV_HOME}/.fluxbox/init   if [ -f ${ALX_SKELETONS}/fluxbox/init ]
588     then
589     fbinit="${ALX_SKELETONS}/fluxbox/init"
590     else
591     fbinit="/usr/share/fluxbox/init"
592     fi
593     cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init
594    
595   # fluxbox autostart   # fluxbox autostart
596   cat ${ALX_SKELETONS}/fluxbox/apps \   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
597   > ${ALX_UNPRIV_HOME}/.fluxbox/apps   # do not show decorations on messages generated with xmessage
598     if [ -x /usr/bin/xmessage ]
599     then
600     addconfig '[app] (xmessage)'
601     addconfig ' [Deco] {NONE}'
602     addconfig '[end]'
603     fi
604     # add icon utility
605     [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
606     # add numlock utility
607     [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}'
608    
609     # fluxbox hotkeys
610     local fbkeys
611     if [ -f ${ALX_SKELETONS}/fluxbox/keys ]
612     then
613     fbkeys="${ALX_SKELETONS}/fluxbox/keys"
614     else
615     fbkeys="/usr/share/fluxbox/keys"
616     fi
617     cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys
618    
619   # fluxbox menu header   # fluxbox menu header
620   cat ${ALX_SKELETONS}/fluxbox/menu.header \   cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu
  > ${ALX_UNPRIV_HOME}/.fluxbox/menu  
621    
622   # now fix it with proper messages :P   # now fix it with proper messages :P
623   local ver="$(< /etc/mageversion)"   local ver="$(< /etc/mageversion)"
624   sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" \   sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu
  ${ALX_UNPRIV_HOME}/.fluxbox/menu  
625    
626   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
627   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
628    
629   # fluxbox menu footer   # fluxbox menu footer
630   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
  >> ${ALX_UNPRIV_HOME}/.fluxbox/menu  
631    
632   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
633   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
634    
   
635   # setup some standart icons (sysinfo.lnk)   # setup some standart icons (sysinfo.lnk)
  # basic config  
  cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc  
   
636   # clean desktop icon location   # clean desktop icon location
637   [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop   [ -d ${ALX_UNPRIV_HOME}/.idesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.idesktop
638   install -d ${ALX_UNPRIV_HOME}/.xtdesktop   install -d ${ALX_UNPRIV_HOME}/.idesktop
639    
640     # add shutdown, reboot icons
641     local name
642     # default settings
643     declare -i x=30
644     declare -i y=30
645     for i in shutdown reboot
646     do
647     case ${i} in
648     shutdown) name="Herunterfahren" ;;
649     reboot) name="Neustarten" ;;
650     esac
651    
652     generate_icon \
653     --name "${name}" \
654     --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \
655     --icon "${ALX_SESSIONS_ICONS}/${i}.png" \
656     --dest "${dest}/${i}.lnk" \
657     --xres "${x}" \
658     --yres "${y}"
659    
660     y=$((${y} + 80))
661     done
662    
663   # last but not least gen a icon with some sys informations   # last but not least gen a icon with some sys informations
664   local sysinfo   local sysinfo
# Line 624  import_settings_local() Line 680  import_settings_local()
680   --name "${sysinfo}" \   --name "${sysinfo}" \
681   --command "exit 0" \   --command "exit 0" \
682   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
683   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \   --dest "${ALX_UNPRIV_HOME}/.idesktop/sysinfo.lnk" \
684   --xres "${xres}" \   --xres "${xres}" \
685   --yres "${yres}" \   --yres "${yres}" \
686   --icon-width "1" \   --icon-width "1" \
# Line 634  import_settings_local() Line 690  import_settings_local()
690   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
691   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
692   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
693   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop
694   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc   if [ -f ${ALX_UNPRIV_HOME}/.ideskrc ]
695     then
696   # default passwords are bad   chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc
697   #usermod -p $(perl -e "printf(crypt('foobar','AD'))") root   fi
  #usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER}  
  #smbpasswd -a root foobar  
698  }  }
699    
700  # start|stop  # start|stop
# Line 657  preliminary_network() Line 711  preliminary_network()
711   module=$(cat ${SETTINGSPATH}/modules)   module=$(cat ${SETTINGSPATH}/modules)
712   modprobe ${module}   modprobe ${module}
713   fi   fi
714    
715   else   else
716   # vars used by hwdetect   # vars used by hwsetup
717   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
718   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
719    
720   # get setting from hwdetect   # get setting from hwsetup
721   source /etc/sysconfig/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
722   modprobe ${NETCARD_DRIVER}   modprobe ${NETCARD_DRIVER}
723   fi   fi
724    
# Line 672  preliminary_network() Line 727  preliminary_network()
727   # keeping like always safe:   # keeping like always safe:
728   # no network should be startet here,   # no network should be startet here,
729   # so we can delete all pid files if one exists   # so we can delete all pid files if one exists
730   if ps -A|grep dhcpcd > /dev/null   if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]]
731   then   then
732   echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT}   rc_mecho "Forcing network down"
733   dhcpcd -k   killall $(basename ${ALX_DHCP_PROG}) &> /dev/null
734   sleep 1   sleep 1
  else  
  rm -f /var/run/dhcpcd-eth?.pid  
735   fi   fi
736   [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop   [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop
737    
738     rc_mecho "Starting preliminary networking ... "
  echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT}  
739    
740   # start network configured from /etc/conf.d   # start network configured from /etc/conf.d
741   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
742   then   then
743   ${rc_base}/init.d/network start   ${rc_base}/init.d/network start
744   else   else
745   echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT}   rc_print "Starting default dhcp based networking ... "
746   # -t 10 timeout of 10 secs   ${ALX_DHCP_PROG} ${ALX_DHCP_START} ${ALX_IFACE} &> /dev/null
  dhcpcd -t 10 &> /dev/null  
747   evaluate_retval   evaluate_retval
748   fi   fi
749   ;;   ;;
750    
751   stop)   stop)
752   echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT}   rc_mecho "Stopping preliminary networking ... "
753   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
754   then   then
755   ${rc_base}/init.d/network stop   ${rc_base}/init.d/network stop
756   else   else
757   echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT}   rc_print "Stopping default dhcp based networking ... "
758   ifconfig eth0 down   ifconfig ${ALX_IFACE} down
759   fi   fi
760   if ps -A|grep dhcpcd > /dev/null   if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]]
761   then   then
762   dhcpcd -z  &> /dev/null   killall $(basename ${ALX_DHCP_PROG}) &> /dev/null
763     sleep 1
764   fi   fi
765   evaluate_retval   evaluate_retval
766   ;;   ;;
# Line 723  reset_system_settings() Line 775  reset_system_settings()
775  {  {
776   # force load of de kbdkeys   # force load of de kbdkeys
777   loadkeys -q de   loadkeys -q de
778   echo   rc_echo
779   echo -en ${COLRED}   rc_echo -en ${COLRED}
780   echo -n "*** Warning: you are about to reset *all* local settings on this system!"   rc_echo -n "*** Warning: you are about to reset *all* local settings on this system!"
781   echo -e ${COLDEFAULT}   rc_echo -e ${COLDEFAULT}
782   echo "*** Do you really want to continue ?"   rc_echo "*** Do you really want to continue ?"
783   echo -n "*** Enter 'yes' to continue, anything else to abort: "   rc_echo -n "*** Enter 'yes' to continue, anything else to abort: "
784   read kbinsert   read kbinsert
785   if [[ ${kbinsert} = yes ]]   if [[ ${kbinsert} = yes ]]
786   then   then
787   echo -en ${COLRED}   rc_echo -en ${COLRED}
788   echo -n "*** OK, you really want it ... killing all settings: "   rc_echo -n "*** OK, you really want it ... killing all settings: "
789   for i in 3 2 1 now   for i in 3 2 1 now
790   do   do
791   echo -n " ${i}"   rc_echo -n " ${i}"
792   sleep 1   sleep 1
793   done   done
794   echo -e ${COLDEFAULT}   rc_echo -e ${COLDEFAULT}
795    
796   ## reset all settings:   ## reset all settings:
797   rm -rf ${SETTINGSPATH}/*   rm -rf ${SETTINGSPATH}/*
798   rm -f /etc/alxconfig-ng/serial   rm -f /etc/alxconfig-ng/serial
799   rm -rf /etc/alxconfig-ng/state   rm -rf /etc/alxconfig-ng/state
800    
801   echo "I am done now, press [Enter] to reboot system ..."   # clear all printers & net-shares
802   read   :> /etc/printcap
803   reboot  
804     # remove lprng
805     rc-config del lprng &> /dev/null
806    
807     # remove all user settings
808     [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}
809    
810     # remove all ica-sessions
811     find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm
812    
813     # remove all old nics and modules configs
814     find /etc/conf.d -type f -name 'net.*' | xargs rm
815     find /etc/modprobe.d -type f -name 'net.*' | xargs rm
816    
817     # restore default networking
818     cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0
819    
820     rc_echo "I am done now, press [Enter] to reboot system ..."
821     else
822     rc_echo "Aborted, press [Enter] to reboot system ..."
823   fi   fi
824     read
825     reboot
826  }  }
827    
828  onboot_interface_list()  onboot_interface_list()
# Line 775  onboot_interface_list() Line 848  onboot_interface_list()
848   echo "${devices}"   echo "${devices}"
849  }  }
850    
851  # read values from files  # read values from net.* files
852  read_value()  read_value()
853  {  {
854   local var="$1"   local var="$1"
# Line 862  case $1 in Line 935  case $1 in
935    
936   # now setup system configuration   # now setup system configuration
937   # alx_setup_or_whatever_it_will_be_called()   # alx_setup_or_whatever_it_will_be_called()
938   [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings   [[ ${ALX_HW_DETECT} = false ]] && update_system_settings
939    
940   # stop at last the preliminary networking (dhcp)   # stop at last the preliminary networking (dhcp)
941   preliminary_network stop   preliminary_network stop
# Line 874  case $1 in Line 947  case $1 in
947   [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state   [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state
948   sleep 0.1   sleep 0.1
949   ;;   ;;
950    
951   *)   *)
952   echo "Usage: $0 {start|stop} ..."   echo "Usage: $0 {start|stop} ..."
953   ;;   ;;
954  esac  esac
   

Legend:
Removed from v.337  
changed lines
  Added in v.2568