Magellan Linux

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

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

revision 2509 by niro, Thu Jun 30 14:44:36 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/common  source ${ALX_FUNCTIONS}/common
30  source /usr/lib/alxconfig-ng/functions/mysqlfunctions  source ${ALX_FUNCTIONS}/mysqlfunctions
31  source /usr/lib/alxconfig-ng/functions/serial_functions  source ${ALX_FUNCTIONS}/serial_functions
32  source /usr/lib/alxconfig-ng/functions/config_modules  source ${ALX_FUNCTIONS}/config_modules
33  source /usr/lib/alxconfig-ng/functions/config_network  source ${ALX_FUNCTIONS}/config_plugins
34  source /usr/lib/alxconfig-ng/functions/config_printers  source ${ALX_FUNCTIONS}/config_network
35  source /usr/lib/alxconfig-ng/functions/config_sessions  source ${ALX_FUNCTIONS}/config_printers
36  source /usr/lib/alxconfig-ng/functions/config_x11  source ${ALX_FUNCTIONS}/config_sessions
37  source /usr/lib/alxconfig-ng/functions/config_auth  source ${ALX_FUNCTIONS}/config_x11
38  source /usr/lib/alxconfig-ng/functions/config_ssh_auth  source ${ALX_FUNCTIONS}/config_auth
39  source /usr/lib/alxconfig-ng/functions/config_versions  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 59  update_system_settings() Line 60  update_system_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 83  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 117  get_system_serial() Line 122  get_system_serial()
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 125  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   rc_mecho "Hardware autodetection forced by system-administrator"   rc_mecho "Hardware autodetection forced by system-administrator"
# Line 151  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 164  get_system_serial() Line 173  get_system_serial()
173   exit 1   exit 1
174   fi   fi
175    
   
176   CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
177   CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | 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)
# Line 180  get_system_serial() Line 188  get_system_serial()
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 188  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 214  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 234  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 274  import_settings_to_db() Line 290  import_settings_to_db()
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   rc_mecho "Importing detected settings to database"   rc_mecho "Importing detected settings to database"
295    
296   # network   # network
# Line 420  import_settings_to_db() Line 436  import_settings_to_db()
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 447  update_settings_in_db() Line 463  update_settings_in_db()
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   rc_mecho "Updating detected settings in database"   rc_mecho "Updating detected settings in database"
468    
469   # network   # network
# Line 544  import_settings_local() Line 560  import_settings_local()
560   # get setting from hwsetup   # get setting from hwsetup
561   source /etc/conf.d/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
562    
563   echo   rc_echo
564   rc_mecho "Importing detected settings to local system"   rc_mecho "Importing detected settings to local system"
565    
566   if [[ ${ALX_CONFD_NETWORKING} = false ]]   if [[ ${ALX_CONFD_NETWORKING} = false ]]
# Line 766  preliminary_network() Line 782  preliminary_network()
782   ;;   ;;
783    
784   *)   *)
785   echo "Usage: preliminary_network {start|stop}"   rc_echo "Usage: preliminary_network {start|stop}"
786   ;;   ;;
787   esac   esac
788  }  }
# Line 774  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     [ -x /sbin/loadkmap ] && loadkmap < /usr/share/busybox/keymaps/de.kmap
795   rc_echo   rc_echo
796   rc_echo -en ${COLRED}   rc_echo -en "${COLRED}"
797   rc_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!'
798   rc_echo -e ${COLDEFAULT}   rc_echo -e "${COLDEFAULT}"
799   rc_echo "*** Do you really want to continue ?"   rc_echo '--- Do you really want to continue ?'
800   rc_echo -n "*** Enter 'yes' to continue, anything else to abort: "   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   rc_echo -en ${COLRED}   rc_echo -en "${COLRED}"
805   rc_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   rc_echo -n " ${i}"   rc_echo -n " ${i}"
809   sleep 1   sleep 1
810   done   done
811   rc_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/printcap   :> /etc/printcap
825    
826   # remove lprng   # remove lprng
827   rc-config del lprng &> /dev/null   rc-config del lprng &> /dev/null
828     rc-config del nmbd &> /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/modprobe.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   rc_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   rc_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 949  case $1 in Line 978  case $1 in
978   ;;   ;;
979    
980   *)   *)
981   echo "Usage: $0 {start|stop} ..."   rc_echo "Usage: $0 {start|stop} ..."
982   ;;   ;;
983  esac  esac

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