--- alx-src/trunk/alxconfig-ng/init.d/alxsettings 2005/10/10 21:06:03 357 +++ alx-src/branches/alxconf-060/init.d/alxsettings 2011/05/09 15:48:19 2011 @@ -1,8 +1,8 @@ #!/bin/bash - +# $Id$ # -#%rlevels: 7:s 0:k 6:k +#%rlevels: 7:s 0:k #%start: 41 #%stop: 01 @@ -11,8 +11,6 @@ #%before: #%after: -# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.25 2005-10-10 21:06:03 niro Exp $ - # checks first if the client was already configured and if it has an valid serial # if not it runs the autoconfiguration script # these settings will be used for client setup @@ -21,7 +19,7 @@ # if no changes are at server side they will be kept, if yes the get updated. # the server settings has higher priority. -source /etc/sysconfig/rc +source /etc/conf.d/rc source $rc_functions # mysql settings @@ -37,9 +35,7 @@ source /usr/lib/alxconfig-ng/functions/config_x11 source /usr/lib/alxconfig-ng/functions/config_auth source /usr/lib/alxconfig-ng/functions/config_ssh_auth - -# check if mysql is available -[ -x /usr/bin/mysql ] && MYSQL_ALX=true +source /usr/lib/alxconfig-ng/functions/config_versions # other needed vars ALX_HW_DETECT=false @@ -93,6 +89,9 @@ # exchange ssh rsa keys HOME=/root config_ssh_auth + + # import version info + config_version } get_system_serial() @@ -122,8 +121,8 @@ exit 1 fi - CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') - CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) + CUR_IP=$(ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') + CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) CUR_MTIME=$(date +%s) echo -e ${COLOREDSTAR} "Trying to validate my serial ..." @@ -139,7 +138,7 @@ else # abort on non valid serial ALX_STATE="invalid serial" - echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state + echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state show_invalid_serial_msg exit 1 fi @@ -150,11 +149,13 @@ if [[ ${ALX_FORCED_RECHECK} = true ]] then echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} + # always disable CONFD_NETWORKING here + export ALX_CONFD_NETWORKING="false" else echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} fi ALX_HW_DETECT=true - /etc/init.d/hwdetect start + hwsetup # set hostname to alx_default_hostname # use old hostname if this is a forced re-check @@ -205,7 +206,7 @@ fi # write current state to temp file - echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state + echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state [ -f /hardware-auto-detection ] && rm /hardware-auto-detection # now export ALX_FORCED_RECHECK=true @@ -230,8 +231,8 @@ # set ALX_STATE to ok so everybody knows that everything was ok ALX_STATE=ok - echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial - echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial + echo "ALX_SERIAL=\"${ALX_SERIAL}\"" > /etc/alxconfig-ng/serial + echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial evaluate_retval else @@ -250,8 +251,8 @@ fi # write current state to temp file - echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state - echo "ALX_IFACE=${ALX_IFACE}" >> /etc/alxconfig-ng/state/state + echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state + echo "ALX_IFACE=\"${ALX_IFACE}\"" >> /etc/alxconfig-ng/state/state } @@ -276,14 +277,14 @@ [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx - # vars used by hwdetect + # vars used by hwsetup local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER local MOUSETYPE XMOUSETYPE FULLNAME DEVICE - # get setting from hwdetect - source /etc/sysconfig/hwsetup/knoppix - source /etc/sysconfig/hwsetup/mouse + # get setting from hwsetup + source /etc/conf.d/hwsetup/knoppix + source /etc/conf.d/hwsetup/mouse echo echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} @@ -377,14 +378,14 @@ module, resolution, depth, - monitorid + refresh_rate ) values( '${ALX_SERIAL}', '${XMODULE}', '1024x768', '16', - '0' + '60' );"; ) evaluate_retval @@ -427,6 +428,14 @@ echo -e " Screensaver settings ..." mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" + # version info + local alx_os + local alx_utils + alx_os="$(< /etc/mageversion)" + alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" + alx_utils="${alx_utils/alxconfig-ng-alx-}" + mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')" + evaluate_retval } @@ -441,14 +450,14 @@ [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx - # vars used by hwdetect + # vars used by hwsetup local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER local MOUSETYPE XMOUSETYPE FULLNAME DEVICE - # get setting from hwdetect - source /etc/sysconfig/hwsetup/knoppix - source /etc/sysconfig/hwsetup/mouse + # get setting from hwsetup + source /etc/conf.d/hwsetup/knoppix + source /etc/conf.d/hwsetup/mouse echo echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT} @@ -509,7 +518,7 @@ module='${XMODULE}', resolution='1024x768', depth='16', - monitorid='0' + refresh_rate='60' where serial=${ALX_SERIAL};" evaluate_retval @@ -517,6 +526,14 @@ echo -e " Input settings ..." mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};" evaluate_retval + + # version info + local alx_os + local alx_utils + alx_os="$(< /etc/mageversion)" + alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" + alx_utils="${alx_utils/alxconfig-ng-alx-}" + mysqldo "update client_version set os='${alx_os}', utils='${alx_utils}' where serial=${ALX_SERIAL};" } # imports current settings to the local system resolved by the hardware detection @@ -530,13 +547,13 @@ [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx - # vars used by hwdetect + # vars used by hwsetup local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER local MOUSETYPE XMOUSETYPE FULLNAME DEVICE - # get setting from hwdetect - source /etc/sysconfig/hwsetup/knoppix + # get setting from hwsetup + source /etc/conf.d/hwsetup/knoppix echo echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} @@ -546,9 +563,11 @@ #[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} #echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules - # set an device alias for modprobe.conf + # set an device alias for modprobe.conf and modules.conf [ ! -d /etc/modules.d ] && install -d /etc/modules.d + [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0 + echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0 # regenerate modprobe.conf [ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf" @@ -558,6 +577,9 @@ # set system state to 'already configured' touch /etc/alxconfig-ng/state/configured + # install slim desktopmanager configuration + config_display_manager + # if only an recheck was forced than abort now [[ ${ALX_FORCED_RECHECK} = true ]] && return 0 @@ -629,18 +651,23 @@ --icon-width "1" \ --icon-height "1" + # create a xinitrc + echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc + # set correct permissions chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc + chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc } # start|stop preliminary_network() { local module + local modulesconf if [ -f /etc/alxconfig-ng/state/configured ] then @@ -651,13 +678,25 @@ module=$(cat ${SETTINGSPATH}/modules) modprobe ${module} fi + + # 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 else - # vars used by hwdetect + # vars used by hwsetup local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER - # get setting from hwdetect - source /etc/sysconfig/hwsetup/knoppix + # get setting from hwsetup + source /etc/conf.d/hwsetup/knoppix modprobe ${NETCARD_DRIVER} fi @@ -666,13 +705,11 @@ # keeping like always safe: # no network should be startet here, # so we can delete all pid files if one exists - if ps -A|grep dhcpcd > /dev/null + if ps -A|grep udhcpc > /dev/null then echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT} - dhcpcd -k + killall udhcpc &> /dev/null sleep 1 - else - rm -f /var/run/dhcpcd-eth?.pid fi [[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \ ${rc_base}/init.d/network stop @@ -686,7 +723,7 @@ else echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT} # -t 10 timeout of 10 secs - dhcpcd -t 10 &> /dev/null + udhcpc -t 10 &> /dev/null evaluate_retval fi ;; @@ -703,6 +740,7 @@ if ps -A|grep dhcpcd > /dev/null then dhcpcd -z &> /dev/null + sleep 1 fi evaluate_retval ;; @@ -753,7 +791,7 @@ [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} # remove all ica-sessions - find ${ALX_ICA_SESSIONS} -type -f -name '*.ica' | xargs rm + find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm # remove all old nics and modules configs find /etc/conf.d -type f -name 'net.*' | xargs rm