Magellan Linux

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

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

revision 2156 by niro, Tue May 17 21:41:48 2011 UTC revision 3466 by niro, Fri Apr 13 17:27:25 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 51  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   rc_mecho Checking system setup ...   rc_mecho Checking system setup ...
# Line 73  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 97  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   local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE CONFIG
91    
92   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
93   then   then
# Line 139  get_system_serial() Line 129  get_system_serial()
129   else   else
130   # abort on non valid serial   # abort on non valid serial
131   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
132   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state   CONFIG="/etc/alxconfig-ng/state/state"
133     clearconfig
134     addconfig "ALX_STATE=\"${ALX_STATE}\""
135   show_invalid_serial_msg   show_invalid_serial_msg
136   exit 1   exit 1
137   fi   fi
# Line 165  get_system_serial() Line 157  get_system_serial()
157   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"
158    
159   # update the hostname on the system for sure   # update the hostname on the system for sure
160   echo "${HOSTNAME}" > /etc/hostname   CONFIG="/etc/hostname"
161     clearconfig
162     addconfig "${HOSTNAME}"
163    
164   # start preliminary networking (dhcp)   # start preliminary networking (dhcp)
165   preliminary_network start   preliminary_network start
# Line 178  get_system_serial() Line 172  get_system_serial()
172   exit 1   exit 1
173   fi   fi
174    
175     CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
176   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
  CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)  
177   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
178    
179   # abort now if this is a forced re-check   # abort now if this is a forced re-check
# Line 202  get_system_serial() Line 195  get_system_serial()
195   else   else
196   # abort on non valid serial   # abort on non valid serial
197   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
198   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   CONFIG="/etc/alxconfig-ng/state/state"
199     clearconfig
200     addconfig "ALX_STATE=\"${ALX_STATE}\""
201   show_invalid_serial_msg   show_invalid_serial_msg
202   exit 1   exit 1
203   fi   fi
204    
205   # write current state to temp file   # write current state to temp file
206   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state   CONFIG="/etc/alxconfig-ng/state/state"
207     clearconfig
208     addconfig "ALX_STATE=\"${ALX_STATE}\""
209   [ -f /hardware-auto-detection ] && rm /hardware-auto-detection   [ -f /hardware-auto-detection ] && rm /hardware-auto-detection
210    
211   # now export ALX_FORCED_RECHECK=true   # now export ALX_FORCED_RECHECK=true
# Line 233  get_system_serial() Line 230  get_system_serial()
230   # set ALX_STATE to ok so everybody knows that everything was ok   # set ALX_STATE to ok so everybody knows that everything was ok
231   ALX_STATE=ok   ALX_STATE=ok
232    
233   echo "ALX_SERIAL=\"${ALX_SERIAL}\"" > /etc/alxconfig-ng/serial   CONFIG="/etc/alxconfig-ng/serial"
234   echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial   clearconfig
235     addconfig "ALX_SERIAL=\"${ALX_SERIAL}\""
236     addconfig "ALX_REG_DATE=\"${CUR_MTIME}\""
237    
238   evaluate_retval   evaluate_retval
239   else   else
# Line 253  get_system_serial() Line 252  get_system_serial()
252   fi   fi
253    
254   # write current state to temp file   # write current state to temp file
255   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state   CONFIG="/etc/alxconfig-ng/state/state"
256   echo "ALX_IFACE=\"${ALX_IFACE}\"" >> /etc/alxconfig-ng/state/state   clearconfig
257     addconfig "ALX_STATE=\"${ALX_STATE}\""
258     addconfig "ALX_IFACE=\"${ALX_IFACE}\""
259  }  }
260    
261    
# Line 434  import_settings_to_db() Line 435  import_settings_to_db()
435   local alx_os   local alx_os
436   local alx_utils   local alx_utils
437   alx_os="$(< /etc/mageversion)"   alx_os="$(< /etc/mageversion)"
438   alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')"   alx_utils="$(magequery -n alxconfig-ng | sed 's:.*\[\ \(.*\)\ \].*:\1:')"
439   alx_utils="${alx_utils/alxconfig-ng-alx-}"   alx_utils="${alx_utils/alxconfig-ng-}"
440   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}')"
441    
442   evaluate_retval   evaluate_retval
# Line 565  import_settings_local() Line 566  import_settings_local()
566   then   then
567   # set an device alias for modprobe.conf   # set an device alias for modprobe.conf
568   [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d   [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d
569   echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0.conf   # update only if not the same (to speed up bootprocess - no depmod)
570     CONFIG="/etc/modprobe.d/net.${ALX_IFACE}.conf"
571     clearconfig
572     addconfig "alias ${ALX_IFACE} ${cfg_network_module}"
573    
574     # update confd-networking default iface
575     [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}
576     CONFIG="${SETTINGSPATH}/confd-networking"
577     clearconfig
578     addconfig "${ALX_IFACE}"
579    
580   # regenerate modprobe.conf   # regenerate modprobe.conf
581   [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!"   [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!"
# Line 588  import_settings_local() Line 598  import_settings_local()
598   # now generate fluxbox config files   # now generate fluxbox config files
599    
600   # fluxbox main config   # fluxbox main config
601   cat ${ALX_SKELETONS}/fluxbox/init > ${ALX_UNPRIV_HOME}/.fluxbox/init   local fbinit
602     if [ -f ${ALX_SKELETONS}/fluxbox/init ]
603     then
604     fbinit="${ALX_SKELETONS}/fluxbox/init"
605     else
606     fbinit="/usr/share/fluxbox/init"
607     fi
608     cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init
609    
610   # fluxbox autostart   # fluxbox autostart
611   cat ${ALX_SKELETONS}/fluxbox/apps > ${ALX_UNPRIV_HOME}/.fluxbox/apps   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
612     # do not show decorations on messages generated with xmessage
613     if [ -x /usr/bin/xmessage ]
614     then
615     addconfig '[app] (xmessage)'
616     addconfig ' [Deco] {NONE}'
617     addconfig '[end]'
618     fi
619     # add icon utility
620     [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
621     # add numlock utility
622     [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}'
623    
624     # fluxbox hotkeys
625     local fbkeys
626     if [ -f ${ALX_SKELETONS}/fluxbox/keys ]
627     then
628     fbkeys="${ALX_SKELETONS}/fluxbox/keys"
629     else
630     fbkeys="/usr/share/fluxbox/keys"
631     fi
632     cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys
633    
634   # fluxbox menu header   # fluxbox menu header
635   cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu   cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu
# Line 609  import_settings_local() Line 647  import_settings_local()
647   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
648   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
649    
   
650   # setup some standart icons (sysinfo.lnk)   # setup some standart icons (sysinfo.lnk)
  # basic config  
  cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc  
   
651   # clean desktop icon location   # clean desktop icon location
652   [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop   [ -d ${ALX_UNPRIV_HOME}/.idesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.idesktop
653   install -d ${ALX_UNPRIV_HOME}/.xtdesktop   install -d ${ALX_UNPRIV_HOME}/.idesktop
654    
655     # add shutdown, reboot icons
656     local name
657     # default settings
658     declare -i x=30
659     declare -i y=30
660     for i in shutdown reboot
661     do
662     case ${i} in
663     shutdown) name="Herunterfahren" ;;
664     reboot) name="Neustarten" ;;
665     esac
666    
667     generate_icon \
668     --name "${name}" \
669     --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \
670     --icon "${ALX_SESSIONS_ICONS}/${i}.png" \
671     --dest "${dest}/${i}.lnk" \
672     --xres "${x}" \
673     --yres "${y}"
674    
675     y=$((${y} + 80))
676     done
677    
678   # last but not least gen a icon with some sys informations   # last but not least gen a icon with some sys informations
679   local sysinfo   local sysinfo
# Line 638  import_settings_local() Line 695  import_settings_local()
695   --name "${sysinfo}" \   --name "${sysinfo}" \
696   --command "exit 0" \   --command "exit 0" \
697   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
698   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \   --dest "${ALX_UNPRIV_HOME}/.idesktop/sysinfo.lnk" \
699   --xres "${xres}" \   --xres "${xres}" \
700   --yres "${yres}" \   --yres "${yres}" \
701   --icon-width "1" \   --icon-width "1" \
702   --icon-height "1"   --icon-height "1"
703    
  # create a xinitrc  
  echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc  
   
704   # set correct permissions   # set correct permissions
705   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
706   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
707   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
708   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop
709   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc   if [ -f ${ALX_UNPRIV_HOME}/.ideskrc ]
710   chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc   then
711     chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc
712     fi
713  }  }
714    
715  # start|stop  # start|stop
# Line 702  preliminary_network() Line 758  preliminary_network()
758   ${rc_base}/init.d/network start   ${rc_base}/init.d/network start
759   else   else
760   rc_print "Starting default dhcp based networking ... "   rc_print "Starting default dhcp based networking ... "
761   ${ALX_DHCP_PROG} ${ALX_DHCP_START} &> /dev/null   ${ALX_DHCP_PROG} ${ALX_DHCP_START} ${ALX_IFACE} &> /dev/null
762   evaluate_retval   evaluate_retval
763   fi   fi
764   ;;   ;;
# Line 733  preliminary_network() Line 789  preliminary_network()
789  reset_system_settings()  reset_system_settings()
790  {  {
791   # force load of de kbdkeys   # force load of de kbdkeys
792   loadkeys -q de   [ -x /usr/bin/loadkeys ] && loadkeys -q de
793     [ -x /sbin/loadkmap ] && loadkmap < /usr/share/busybox/keymaps/de.kmap
794   rc_echo   rc_echo
795   rc_echo -en ${COLRED}   rc_echo -en "${COLRED}"
796   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!'
797   rc_echo -e ${COLDEFAULT}   rc_echo -e "${COLDEFAULT}"
798   rc_echo "*** Do you really want to continue ?"   rc_echo '--- Do you really want to continue ?'
799   rc_echo -n "*** Enter 'yes' to continue, anything else to abort: "   rc_echo -n '--- Enter 'yes' to continue, anything else to abort: '
800   read kbinsert   read kbinsert
801   if [[ ${kbinsert} = yes ]]   if [[ ${kbinsert} = yes ]]
802   then   then
803   rc_echo -en ${COLRED}   rc_echo -en "${COLRED}"
804   rc_echo -n "*** OK, you really want it ... killing all settings: "   rc_echo -n '--- OK, you really want it ... killing all settings: '
805   for i in 3 2 1 now   for i in 3 2 1 now
806   do   do
807   rc_echo -n " ${i}"   rc_echo -n " ${i}"
808   sleep 1   sleep 1
809   done   done
810   rc_echo -e ${COLDEFAULT}   rc_echo -e "${COLDEFAULT}"
811    
812   ## reset all settings:   ## reset all settings:
813   rm -rf ${SETTINGSPATH}/*   rm -rf ${SETTINGSPATH}
814   rm -f /etc/alxconfig-ng/serial   rm -f /etc/alxconfig-ng/serial
815   rm -rf /etc/alxconfig-ng/state   rm -rf /etc/alxconfig-ng/state
816     local i
817     for i in xserver netcard knoppix mouse
818     do
819     [[ -f /etc/conf.d/hwsetup/${i} ]] && rm /etc/conf.d/hwsetup/${i}
820     done
821    
822   # clear all printers & net-shares   # clear all printers & net-shares
823   :> /etc/printcap   :> /etc/printcap
824    
825   # remove lprng   # remove lprng
826   rc-config del lprng &> /dev/null   rc-config del lprng &> /dev/null
827     rc-config del nmbd &> /dev/null
828    
829   # remove all user settings   # remove all user settings
830   [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}   [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}
831     install -o ${ALX_UNPRIV_USER} -g ${ALX_UNPRIV_GROUP} -d ${ALX_UNPRIV_HOME}
832    
833   # remove all ica-sessions   # remove all ica-sessions
834   find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm   find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs --no-run-if-empty rm
835    
836   # remove all old nics and modules configs   # remove all old nics and modules configs
837   find /etc/conf.d -type f -name 'net.*' | xargs rm   find /etc/conf.d -type f -name 'net.*' | xargs --no-run-if-empty rm
838   find /etc/modprobe.d -type f -name 'net.*' | xargs rm   find /etc/modprobe.d -type f -name 'net.*' | xargs --no-run-if-empty rm
839    
840   # restore default networking   # restore default networking
841   cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0   cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0
842     local CONFIG="/etc/hostname"
843     clearconfig
844     addconfig "${ALX_DEFAULT_HOSTNAME}"
845    
846   rc_echo "I am done now, press [Enter] to reboot system ..."   rc_echo -n "I am done now, press [Enter] to reboot system ..."
847   else   else
848   rc_echo "Aborted, press [Enter] to reboot system ..."   rc_echo -n "Aborted, press [Enter] to reboot system ..."
849   fi   fi
850   read   read
851   reboot   sync
852     mount -oremount,ro /
853     reboot -f
854  }  }
855    
856  onboot_interface_list()  onboot_interface_list()

Legend:
Removed from v.2156  
changed lines
  Added in v.3466