Magellan Linux

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

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

revision 2008 by niro, Mon May 9 15:35:49 2011 UTC revision 3476 by niro, Fri Apr 13 18:11:28 2012 UTC
# Line 26  source $rc_functions Line 26  source $rc_functions
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/mysqlfunctions  source ${ALX_FUNCTIONS}/common
30  source /usr/lib/alxconfig-ng/functions/serial_functions  source ${ALX_FUNCTIONS}/mysqlfunctions
31  source /usr/lib/alxconfig-ng/functions/config_modules  source ${ALX_FUNCTIONS}/serial_functions
32  source /usr/lib/alxconfig-ng/functions/config_network  source ${ALX_FUNCTIONS}/config_modules
33  source /usr/lib/alxconfig-ng/functions/config_printers  source ${ALX_FUNCTIONS}/config_plugins
34  source /usr/lib/alxconfig-ng/functions/config_sessions  source ${ALX_FUNCTIONS}/config_network
35  source /usr/lib/alxconfig-ng/functions/config_x11  source ${ALX_FUNCTIONS}/config_printers
36  source /usr/lib/alxconfig-ng/functions/config_auth  source ${ALX_FUNCTIONS}/config_sessions
37  source /usr/lib/alxconfig-ng/functions/config_ssh_auth  source ${ALX_FUNCTIONS}/config_x11
38  source /usr/lib/alxconfig-ng/functions/config_versions  source ${ALX_FUNCTIONS}/config_auth
39    source ${ALX_FUNCTIONS}/config_ssh_auth
40    source ${ALX_FUNCTIONS}/config_versions
41    
42  # other needed vars  # other needed vars
43  ALX_HW_DETECT=false  ALX_HW_DETECT=false
# Line 50  unset ALX_SERIAL ALX_STATE Line 52  unset ALX_SERIAL ALX_STATE
52  # setup needed directories  # setup needed directories
53  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state
54    
   
 # read_cmdline ${item}  
 read_cmdline()  
 {  
  local i  
   
  for i in $(< /proc/cmdline)  
  do  
  [[ ${i} = $1 ]] && return 0  
  done  
   
  return 1  
 }  
   
55  update_system_settings()  update_system_settings()
56  {  {
57   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}   rc_mecho Checking system setup ...
58    
59   # get the modules settings   # get the modules settings
60   # ! is the first thing that must be configured !   # ! is the first thing that must be configured !
61   config_modules   config_modules
62    
63     # install or uninstall plugins
64     config_plugins
65    
66   # imports network settings from db   # imports network settings from db
67   config_networking   config_networking
68    
# Line 96  update_system_settings() Line 87  update_system_settings()
87    
88  get_system_serial()  get_system_serial()
89  {  {
90   local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE   # never declare ALX_IFACE as a local variable! ->fixme!
91     local CUR_IP CUR_MAC CUR_MTIME CONFIG
92    
93   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
94   then   then
# Line 125  get_system_serial() Line 117  get_system_serial()
117   CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
118   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
119    
120   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."   rc_print "Trying to validate my serial ..."
121    
122   # nice serial output   # nice serial output
123   $CURS_UP   $CURS_UP
124   $SET_WCOL   $SET_WCOL
125   echo "[ SN: ${ALX_SERIAL} ]"   rc_echo "[ SN: ${ALX_SERIAL} ]"
126    
127   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"
128   then   then
# Line 138  get_system_serial() Line 130  get_system_serial()
130   else   else
131   # abort on non valid serial   # abort on non valid serial
132   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
133   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state   CONFIG="/etc/alxconfig-ng/state/state"
134     clearconfig
135     addconfig "ALX_STATE=\"${ALX_STATE}\""
136   show_invalid_serial_msg   show_invalid_serial_msg
137   exit 1   exit 1
138   fi   fi
139    
140   else   else
141   # run hardware detection   # run hardware detection
142   echo   rc_echo
143   if [[ ${ALX_FORCED_RECHECK} = true ]]   if [[ ${ALX_FORCED_RECHECK} = true ]]
144   then   then
145   echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT}   rc_mecho "Hardware autodetection forced by system-administrator"
146   # always disable CONFD_NETWORKING here   # always disable CONFD_NETWORKING here
147   export ALX_CONFD_NETWORKING="false"   export ALX_CONFD_NETWORKING="false"
148   else   else
149   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}   rc_mecho "Preparing system for first boot"
150   fi   fi
151   ALX_HW_DETECT=true   ALX_HW_DETECT=true
152   /etc/init.d/hwdetect start   hwsetup
153    
154   # set hostname to alx_default_hostname   # set hostname to alx_default_hostname
155   # use old hostname if this is a forced re-check   # use old hostname if this is a forced re-check
# Line 164  get_system_serial() Line 158  get_system_serial()
158   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"
159    
160   # update the hostname on the system for sure   # update the hostname on the system for sure
161   echo "${HOSTNAME}" > /etc/hostname   CONFIG="/etc/hostname"
162     clearconfig
163     addconfig "${HOSTNAME}"
164    
165   # start preliminary networking (dhcp)   # start preliminary networking (dhcp)
166   preliminary_network start   preliminary_network start
# Line 177  get_system_serial() Line 173  get_system_serial()
173   exit 1   exit 1
174   fi   fi
175    
176   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
177   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
178   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
179    
180   # abort now if this is a forced re-check   # abort now if this is a forced re-check
# Line 187  get_system_serial() Line 183  get_system_serial()
183   # but first check the serial   # but first check the serial
184   source /etc/alxconfig-ng/serial   source /etc/alxconfig-ng/serial
185    
186   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."   rc_print "Trying to validate my serial ..."
187    
188   # nice serial output   # nice serial output
189   $CURS_UP   $CURS_UP
190   $SET_WCOL   $SET_WCOL
191   echo "[ SN: ${ALX_SERIAL} ]"   rc_echo "[ SN: ${ALX_SERIAL} ]"
192    
193   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"
194   then   then
# Line 200  get_system_serial() Line 196  get_system_serial()
196   else   else
197   # abort on non valid serial   # abort on non valid serial
198   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
199   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   CONFIG="/etc/alxconfig-ng/state/state"
200     clearconfig
201     addconfig "ALX_STATE=\"${ALX_STATE}\""
202   show_invalid_serial_msg   show_invalid_serial_msg
203   exit 1   exit 1
204   fi   fi
205    
206   # write current state to temp file   # write current state to temp file
207   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state   CONFIG="/etc/alxconfig-ng/state/state"
208     clearconfig
209     addconfig "ALX_STATE=\"${ALX_STATE}\""
210   [ -f /hardware-auto-detection ] && rm /hardware-auto-detection   [ -f /hardware-auto-detection ] && rm /hardware-auto-detection
211    
212   # now export ALX_FORCED_RECHECK=true   # now export ALX_FORCED_RECHECK=true
# Line 215  get_system_serial() Line 215  get_system_serial()
215   return 0   return 0
216   fi   fi
217    
218   echo -e ${COLOREDSTAR} "Trying to get new serial ..."   rc_print "Trying to get new serial ..."
219    
220   # 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)
221   ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');   ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');
# Line 226  get_system_serial() Line 226  get_system_serial()
226   # nice serial output   # nice serial output
227   $CURS_UP   $CURS_UP
228   $SET_WCOL   $SET_WCOL
229   echo "[ SN: ${ALX_SERIAL} ]"   rc_echo "[ SN: ${ALX_SERIAL} ]"
230    
231   # set ALX_STATE to ok so everybody knows 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   CONFIG="/etc/alxconfig-ng/serial"
235   echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial   clearconfig
236     addconfig "ALX_SERIAL=\"${ALX_SERIAL}\""
237     addconfig "ALX_REG_DATE=\"${CUR_MTIME}\""
238    
239   evaluate_retval   evaluate_retval
240   else   else
# Line 246  get_system_serial() Line 248  get_system_serial()
248   # nice serial output   # nice serial output
249   $CURS_UP   $CURS_UP
250   $SET_WCOL   $SET_WCOL
251   echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]"   rc_echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]"
252   fi   fi
253   fi   fi
254    
255   # write current state to temp file   # write current state to temp file
256   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state   CONFIG="/etc/alxconfig-ng/state/state"
257   echo "ALX_IFACE=\"${ALX_IFACE}\"" >> /etc/alxconfig-ng/state/state   clearconfig
258     addconfig "ALX_STATE=\"${ALX_STATE}\""
259     addconfig "ALX_IFACE=\"${ALX_IFACE}\""
260  }  }
261    
262    
# Line 277  import_settings_to_db() Line 281  import_settings_to_db()
281   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
282   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
283    
284   # vars used by hwdetect   # vars used by hwsetup
285   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
286   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
287   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
288    
289   # get setting from hwdetect   # get setting from hwsetup
290   source /etc/conf.d/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
291   source /etc/conf.d/hwsetup/mouse   source /etc/conf.d/hwsetup/mouse
292    
293   echo   rc_echo
294   echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT}   rc_mecho "Importing detected settings to database"
295    
296   # network   # network
297   echo -e "      Network settings ..."   rc_mecho "      Network settings ..."
298   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
299   then   then
300   # get settings   # get settings
  #source ${rc_base}/init.d/network &> /dev/null  
301   for iface in $(onboot_interface_list ${network_settings}/net.*)   for iface in $(onboot_interface_list ${network_settings}/net.*)
302   do   do
303   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
304   echo "WARNING: only importing settings for interface [ ${iface} ] !"   rc_echo "WARNING: only importing settings for interface [ ${iface} ] !"
305   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || echo "Error: could not read '${network_settings}/net.${iface}'"
306   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"
307    
308   mysqldo "insert into cfg_network(   mysqldo "insert into cfg_network(
309   hostname,   hostname,
# Line 371  import_settings_to_db() Line 374  import_settings_to_db()
374   evaluate_retval   evaluate_retval
375    
376   # xserver   # xserver
377   echo -e "      Graphic settings ..."   rc_mecho "      Graphic settings ..."
378   # xserver general   # xserver general
379   ( mysqldo "insert into cfg_graphic(   ( mysqldo "insert into cfg_graphic(
380   serial,   serial,
# Line 390  import_settings_to_db() Line 393  import_settings_to_db()
393   evaluate_retval   evaluate_retval
394    
395   # input   # input
396   echo -e "      Input settings ..."   rc_mecho "      Input settings ..."
397   mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"   mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"
398   evaluate_retval   evaluate_retval
399    
400   # auth   # auth
401   echo -e "      Authentification settings ..."   rc_mecho "      Authentification settings ..."
402   mysqldo "insert into client_auth(   mysqldo "insert into client_auth(
403   serial,   serial,
404   username,   username,
# Line 416  import_settings_to_db() Line 419  import_settings_to_db()
419    
420   # exchange ssh rsa keys - the first boot needs this !   # exchange ssh rsa keys - the first boot needs this !
421   # or no reboot will work via the webadmin   # or no reboot will work via the webadmin
422   echo -e "      SSH authentification settings ..."   rc_mecho "      SSH authentification settings ..."
423   HOME=/root config_ssh_auth   HOME=/root config_ssh_auth
424   evaluate_retval   evaluate_retval
425    
426   # autostart   # autostart
427   echo -e "      Autostart settings ..."   rc_mecho "      Autostart settings ..."
428   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
429    
430   # screensaver   # screensaver
431   echo -e "      Screensaver settings ..."   rc_mecho "      Screensaver settings ..."
432   mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"   mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"
433    
434   # version info   # version info
435     rc_mecho "      OS version info ..."
436   local alx_os   local alx_os
437   local alx_utils   local alx_utils
438   alx_os="$(< /etc/mageversion)"   alx_os="$(< /etc/mageversion)"
439   alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')"   alx_utils="$(magequery -n alxconfig-ng | sed 's:.*\[\ \(.*\)\ \].*:\1:')"
440   alx_utils="${alx_utils/alxconfig-ng-alx-}"   alx_utils="${alx_utils/alxconfig-ng-}"
441   mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')"   mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')"
442    
443   evaluate_retval   evaluate_retval
# Line 450  update_settings_in_db() Line 454  update_settings_in_db()
454   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
455   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
456    
457   # vars used by hwdetect   # vars used by hwsetup
458   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
459   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
460   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
461    
462   # get setting from hwdetect   # get setting from hwsetup
463   source /etc/conf.d/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
464   source /etc/conf.d/hwsetup/mouse   source /etc/conf.d/hwsetup/mouse
465    
466   echo   rc_echo
467   echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT}   rc_mecho "Updating detected settings in database"
468    
469   # network   # network
470   echo -e "      Network settings ..."   rc_mecho "      Network settings ..."
471   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
472   then   then
473   # get settings   # get settings
# Line 471  update_settings_in_db() Line 475  update_settings_in_db()
475   for iface in $(onboot_interface_list ${network_settings}/net.*)   for iface in $(onboot_interface_list ${network_settings}/net.*)
476   do   do
477   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
478   echo "WARNING: only importing settings for interface [ ${iface} ] !"   rc_echo "WARNING: only importing settings for interface [ ${iface} ] !"
479   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || exit 1
480   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"
481    
482   mysqldo "update cfg_network set   mysqldo "update cfg_network set
483   hostname='${ALX_DEFAULT_HOSTNAME}',   hostname='${ALX_DEFAULT_HOSTNAME}',
# Line 512  update_settings_in_db() Line 516  update_settings_in_db()
516   evaluate_retval   evaluate_retval
517    
518   # xserver   # xserver
519   echo -e "      Graphic settings ..."   rc_mecho "      Graphic settings ..."
520   # xserver general   # xserver general
521   mysqldo "update cfg_graphic set   mysqldo "update cfg_graphic set
522   module='${XMODULE}',   module='${XMODULE}',
# Line 523  update_settings_in_db() Line 527  update_settings_in_db()
527   evaluate_retval   evaluate_retval
528    
529   # input   # input
530   echo -e "      Input settings ..."   rc_mecho "      Input settings ..."
531   mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};"   mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};"
532   evaluate_retval   evaluate_retval
533    
534   # version info   # version info
535     rc_mecho "      OS version info ..."
536   local alx_os   local alx_os
537   local alx_utils   local alx_utils
538   alx_os="$(< /etc/mageversion)"   alx_os="$(< /etc/mageversion)"
# Line 547  import_settings_local() Line 552  import_settings_local()
552   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
553   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
554    
555   # vars used by hwdetect   # vars used by hwsetup
556   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
557   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
558   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
559    
560   # get setting from hwdetect   # get setting from hwsetup
561   source /etc/conf.d/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
562    
563   echo   rc_echo
564   echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT}   rc_mecho "Importing detected settings to local system"
565    
566   if [[ ${ALX_CONFD_NETWORKING} = false ]]   if [[ ${ALX_CONFD_NETWORKING} = false ]]
567   then   then
568   #[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}   # set an device alias for modprobe.conf
  #echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules  
   
  # set an device alias for modprobe.conf and modules.conf  
  [ ! -d /etc/modules.d ] && install -d /etc/modules.d  
569   [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d   [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d
570   echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0   # update only if not the same (to speed up bootprocess - no depmod)
571   echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0   CONFIG="/etc/modprobe.d/net.${ALX_IFACE}.conf"
572     clearconfig
573     addconfig "alias ${ALX_IFACE} ${cfg_network_module}"
574    
575     # update confd-networking default iface
576     [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}
577     CONFIG="${SETTINGSPATH}/confd-networking"
578     clearconfig
579     addconfig "${ALX_IFACE}"
580    
581   # regenerate modprobe.conf   # regenerate modprobe.conf
582   [ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf"   [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!"
583   evaluate_retval   evaluate_retval
584   fi   fi
585    
# Line 590  import_settings_local() Line 599  import_settings_local()
599   # now generate fluxbox config files   # now generate fluxbox config files
600    
601   # fluxbox main config   # fluxbox main config
602   cat ${ALX_SKELETONS}/fluxbox/init \   local fbinit
603   > ${ALX_UNPRIV_HOME}/.fluxbox/init   if [ -f ${ALX_SKELETONS}/fluxbox/init ]
604     then
605     fbinit="${ALX_SKELETONS}/fluxbox/init"
606     else
607     fbinit="/usr/share/fluxbox/init"
608     fi
609     cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init
610    
611   # fluxbox autostart   # fluxbox autostart
612   cat ${ALX_SKELETONS}/fluxbox/apps \   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
613   > ${ALX_UNPRIV_HOME}/.fluxbox/apps   # do not show decorations on messages generated with xmessage
614     if [ -x /usr/bin/xmessage ]
615     then
616     addconfig '[app] (xmessage)'
617     addconfig ' [Deco] {NONE}'
618     addconfig '[end]'
619     fi
620     # add icon utility
621     [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
622     # add numlock utility
623     [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}'
624    
625     # fluxbox hotkeys
626     local fbkeys
627     if [ -f ${ALX_SKELETONS}/fluxbox/keys ]
628     then
629     fbkeys="${ALX_SKELETONS}/fluxbox/keys"
630     else
631     fbkeys="/usr/share/fluxbox/keys"
632     fi
633     cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys
634    
635   # fluxbox menu header   # fluxbox menu header
636   cat ${ALX_SKELETONS}/fluxbox/menu.header \   cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu
  > ${ALX_UNPRIV_HOME}/.fluxbox/menu  
637    
638   # now fix it with proper messages :P   # now fix it with proper messages :P
639   local ver="$(< /etc/mageversion)"   local ver="$(< /etc/mageversion)"
640   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  
641    
642   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
643   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
644    
645   # fluxbox menu footer   # fluxbox menu footer
646   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
  >> ${ALX_UNPRIV_HOME}/.fluxbox/menu  
647    
648   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
649   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
650    
   
651   # setup some standart icons (sysinfo.lnk)   # setup some standart icons (sysinfo.lnk)
  # basic config  
  cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc  
   
652   # clean desktop icon location   # clean desktop icon location
653   [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop   [ -d ${ALX_UNPRIV_HOME}/.idesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.idesktop
654   install -d ${ALX_UNPRIV_HOME}/.xtdesktop   install -d ${ALX_UNPRIV_HOME}/.idesktop
655    
656     # add shutdown, reboot icons
657     local name
658     # default settings
659     declare -i x=30
660     declare -i y=30
661     for i in shutdown reboot
662     do
663     case ${i} in
664     shutdown) name="Herunterfahren" ;;
665     reboot) name="Neustarten" ;;
666     esac
667    
668     generate_icon \
669     --name "${name}" \
670     --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \
671     --icon "${ALX_SESSIONS_ICONS}/${i}.png" \
672     --dest "${dest}/${i}.lnk" \
673     --xres "${x}" \
674     --yres "${y}"
675    
676     y=$((${y} + 80))
677     done
678    
679   # last but not least gen a icon with some sys informations   # last but not least gen a icon with some sys informations
680   local sysinfo   local sysinfo
# Line 645  import_settings_local() Line 696  import_settings_local()
696   --name "${sysinfo}" \   --name "${sysinfo}" \
697   --command "exit 0" \   --command "exit 0" \
698   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
699   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \   --dest "${ALX_UNPRIV_HOME}/.idesktop/sysinfo.lnk" \
700   --xres "${xres}" \   --xres "${xres}" \
701   --yres "${yres}" \   --yres "${yres}" \
702   --icon-width "1" \   --icon-width "1" \
703   --icon-height "1"   --icon-height "1"
704    
  # create a xinitrc  
  echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc  
   
705   # set correct permissions   # set correct permissions
706   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
707   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
708   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
709   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop
710   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc   if [ -f ${ALX_UNPRIV_HOME}/.ideskrc ]
711   chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc   then
712     chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc
713     fi
714  }  }
715    
716  # start|stop  # start|stop
717  preliminary_network()  preliminary_network()
718  {  {
719   local module   local module
  local modulesconf  
720    
721   if [ -f /etc/alxconfig-ng/state/configured ]   if [ -f /etc/alxconfig-ng/state/configured ]
722   then   then
# Line 679  preliminary_network() Line 728  preliminary_network()
728   modprobe ${module}   modprobe ${module}
729   fi   fi
730    
  # check modprobe.conf  
  if [[ $(kernel_major_version) = 2.4 ]]  
  then  
  modulesconf="/etc/modules.conf"  
  else  
  modulesconf="/etc/modprobe.conf"  
  fi  
  if [[ -z $(grep eth0 ${modulesconf}) ]]  
  then  
  modules-update force  
  fi  
731   else   else
732   # vars used by hwdetect   # vars used by hwsetup
733   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
734   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
735    
736   # get setting from hwdetect   # get setting from hwsetup
737   source /etc/conf.d/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
738   modprobe ${NETCARD_DRIVER}   modprobe ${NETCARD_DRIVER}
739   fi   fi
# Line 705  preliminary_network() Line 743  preliminary_network()
743   # keeping like always safe:   # keeping like always safe:
744   # no network should be startet here,   # no network should be startet here,
745   # so we can delete all pid files if one exists   # so we can delete all pid files if one exists
746   if ps -A|grep dhcpcd > /dev/null   if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]]
747   then   then
748   echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT}   rc_mecho "Forcing network down"
749   dhcpcd -k   killall $(basename ${ALX_DHCP_PROG}) &> /dev/null
750   sleep 1   sleep 1
  else  
  rm -f /var/run/dhcpcd-eth?.pid  
751   fi   fi
752   [[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \   [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop
  ${rc_base}/init.d/network stop  
753    
754   echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT}   rc_mecho "Starting preliminary networking ... "
755    
756   # start network configured from /etc/conf.d   # start network configured from /etc/conf.d
757   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
758   then   then
759   ${rc_base}/init.d/network start   ${rc_base}/init.d/network start
760   else   else
761   echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT}   rc_print "Starting default dhcp based networking ... "
762   # -t 10 timeout of 10 secs   ${ALX_DHCP_PROG} ${ALX_DHCP_START} ${ALX_IFACE} &> /dev/null
  dhcpcd -t 10 &> /dev/null  
763   evaluate_retval   evaluate_retval
764   fi   fi
765   ;;   ;;
766    
767   stop)   stop)
768   echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT}   rc_mecho "Stopping preliminary networking ... "
769   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
770   then   then
771   ${rc_base}/init.d/network stop   ${rc_base}/init.d/network stop
772   else   else
773   echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT}   rc_print "Stopping default dhcp based networking ... "
774   ifconfig eth0 down   ifconfig ${ALX_IFACE} down
775   fi   fi
776   if ps -A|grep dhcpcd > /dev/null   if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]]
777   then   then
778   dhcpcd -z  &> /dev/null   killall $(basename ${ALX_DHCP_PROG}) &> /dev/null
779   sleep 1   sleep 1
780   fi   fi
781   evaluate_retval   evaluate_retval
782   ;;   ;;
783    
784   *)   *)
785   echo "Usage: preliminary_network {start|stop}"   rc_echo "Usage: preliminary_network {start|stop}"
786   ;;   ;;
787   esac   esac
788  }  }
# Line 756  preliminary_network() Line 790  preliminary_network()
790  reset_system_settings()  reset_system_settings()
791  {  {
792   # force load of de kbdkeys   # force load of de kbdkeys
793   loadkeys -q de   [ -x /usr/bin/loadkeys ] && loadkeys -q de
794   echo   [ -x /sbin/loadkmap ] && loadkmap < /usr/share/busybox/keymaps/de.kmap
795   echo -en ${COLRED}   rc_echo
796   echo -n "*** Warning: you are about to reset *all* local settings on this system!"   rc_echo -en "${COLRED}"
797   echo -e ${COLDEFAULT}   rc_echo -n '--- Warning: you are about to reset *all* local settings on this system!'
798   echo "*** Do you really want to continue ?"   rc_echo -e "${COLDEFAULT}"
799   echo -n "*** Enter 'yes' to continue, anything else to abort: "   rc_echo '--- Do you really want to continue ?'
800     rc_echo -n '--- Enter 'yes' to continue, anything else to abort: '
801   read kbinsert   read kbinsert
802   if [[ ${kbinsert} = yes ]]   if [[ ${kbinsert} = yes ]]
803   then   then
804   echo -en ${COLRED}   rc_echo -en "${COLRED}"
805   echo -n "*** OK, you really want it ... killing all settings: "   rc_echo -n '--- OK, you really want it ... killing all settings: '
806   for i in 3 2 1 now   for i in 3 2 1 now
807   do   do
808   echo -n " ${i}"   rc_echo -n " ${i}"
809   sleep 1   sleep 1
810   done   done
811   echo -e ${COLDEFAULT}   rc_echo -e "${COLDEFAULT}"
812    
813   ## reset all settings:   ## reset all settings:
814   rm -rf ${SETTINGSPATH}/*   rm -rf ${SETTINGSPATH}
815   rm -f /etc/alxconfig-ng/serial   rm -f /etc/alxconfig-ng/serial
816   rm -rf /etc/alxconfig-ng/state   rm -rf /etc/alxconfig-ng/state
817     local i
818     for i in xserver netcard knoppix mouse
819     do
820     [[ -f /etc/conf.d/hwsetup/${i} ]] && rm /etc/conf.d/hwsetup/${i}
821     done
822    
823   # clear all printers & net-shares   # clear all printers & net-shares
824   :> /etc/cups/printers.conf   :> /etc/printcap
  :> /etc/samba/smb.conf  
825    
826   # remove inetd, cups & smb from init   # remove lprng
827   rc-config del inetd &> /dev/null   rc-config del lprng &> /dev/null
828   rc-config del cups &> /dev/null   rc-config del nmbd &> /dev/null
  rc-config del samba &> /dev/null  
829    
830   # remove all user settings   # remove all user settings
831   [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}   [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}
832     install -o ${ALX_UNPRIV_USER} -g ${ALX_UNPRIV_GROUP} -d ${ALX_UNPRIV_HOME}
833    
834   # remove all ica-sessions   # remove all ica-sessions
835   find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm   find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs --no-run-if-empty rm
836    
837   # remove all old nics and modules configs   # remove all old nics and modules configs
838   find /etc/conf.d -type f -name 'net.*' | xargs rm   find /etc/conf.d -type f -name 'net.*' | xargs --no-run-if-empty rm
839   find /etc/modules.d -type f -name 'net.*' | xargs rm   find /etc/modprobe.d -type f -name 'net.*' | xargs --no-run-if-empty rm
840    
841   # restore default networking   # restore default networking
842   cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0   cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0
843     local CONFIG="/etc/hostname"
844     clearconfig
845     addconfig "${ALX_DEFAULT_HOSTNAME}"
846    
847   echo "I am done now, press [Enter] to reboot system ..."   rc_echo -n "I am done now, press [Enter] to reboot system ..."
848   else   else
849   echo "Aborted, press [Enter] to reboot system ..."   rc_echo -n "Aborted, press [Enter] to reboot system ..."
850   fi   fi
851   read   read
852   reboot   sync
853     mount -oremount,ro /
854     reboot -f
855  }  }
856    
857  onboot_interface_list()  onboot_interface_list()
# Line 932  case $1 in Line 976  case $1 in
976   [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state   [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state
977   sleep 0.1   sleep 0.1
978   ;;   ;;
979    
980   *)   *)
981   echo "Usage: $0 {start|stop} ..."   rc_echo "Usage: $0 {start|stop} ..."
982   ;;   ;;
983  esac  esac
   

Legend:
Removed from v.2008  
changed lines
  Added in v.3476