--- alx-src/branches/alxconf-060/init.d/alxsettings 2011/05/17 21:41:48 2156 +++ alx-src/branches/alxconf-060/init.d/alxsettings 2012/04/13 17:27:25 3466 @@ -26,17 +26,18 @@ source /etc/alxconfig-ng/config.rc # helper functions -source /usr/lib/alxconfig-ng/functions/common -source /usr/lib/alxconfig-ng/functions/mysqlfunctions -source /usr/lib/alxconfig-ng/functions/serial_functions -source /usr/lib/alxconfig-ng/functions/config_modules -source /usr/lib/alxconfig-ng/functions/config_network -source /usr/lib/alxconfig-ng/functions/config_printers -source /usr/lib/alxconfig-ng/functions/config_sessions -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 -source /usr/lib/alxconfig-ng/functions/config_versions +source ${ALX_FUNCTIONS}/common +source ${ALX_FUNCTIONS}/mysqlfunctions +source ${ALX_FUNCTIONS}/serial_functions +source ${ALX_FUNCTIONS}/config_modules +source ${ALX_FUNCTIONS}/config_plugins +source ${ALX_FUNCTIONS}/config_network +source ${ALX_FUNCTIONS}/config_printers +source ${ALX_FUNCTIONS}/config_sessions +source ${ALX_FUNCTIONS}/config_x11 +source ${ALX_FUNCTIONS}/config_auth +source ${ALX_FUNCTIONS}/config_ssh_auth +source ${ALX_FUNCTIONS}/config_versions # other needed vars ALX_HW_DETECT=false @@ -51,20 +52,6 @@ # setup needed directories [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state - -# read_cmdline ${item} -read_cmdline() -{ - local i - - for i in $(< /proc/cmdline) - do - [[ ${i} = $1 ]] && return 0 - done - - return 1 -} - update_system_settings() { rc_mecho Checking system setup ... @@ -73,6 +60,9 @@ # ! is the first thing that must be configured ! config_modules + # install or uninstall plugins + config_plugins + # imports network settings from db config_networking @@ -97,7 +87,7 @@ get_system_serial() { - local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE + local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE CONFIG if [[ ${ALX_CONFD_NETWORKING} = true ]] then @@ -139,7 +129,9 @@ else # abort on non valid serial ALX_STATE="invalid serial" - echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state + CONFIG="/etc/alxconfig-ng/state/state" + clearconfig + addconfig "ALX_STATE=\"${ALX_STATE}\"" show_invalid_serial_msg exit 1 fi @@ -165,7 +157,9 @@ HOSTNAME="${ALX_DEFAULT_HOSTNAME}" # update the hostname on the system for sure - echo "${HOSTNAME}" > /etc/hostname + CONFIG="/etc/hostname" + clearconfig + addconfig "${HOSTNAME}" # start preliminary networking (dhcp) preliminary_network start @@ -178,9 +172,8 @@ exit 1 fi - - CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') - CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) + CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') + CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) CUR_MTIME=$(date +%s) # abort now if this is a forced re-check @@ -202,13 +195,17 @@ else # abort on non valid serial ALX_STATE="invalid serial" - echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state + CONFIG="/etc/alxconfig-ng/state/state" + clearconfig + addconfig "ALX_STATE=\"${ALX_STATE}\"" show_invalid_serial_msg exit 1 fi # write current state to temp file - echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state + CONFIG="/etc/alxconfig-ng/state/state" + clearconfig + addconfig "ALX_STATE=\"${ALX_STATE}\"" [ -f /hardware-auto-detection ] && rm /hardware-auto-detection # now export ALX_FORCED_RECHECK=true @@ -233,8 +230,10 @@ # 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 + CONFIG="/etc/alxconfig-ng/serial" + clearconfig + addconfig "ALX_SERIAL=\"${ALX_SERIAL}\"" + addconfig "ALX_REG_DATE=\"${CUR_MTIME}\"" evaluate_retval else @@ -253,8 +252,10 @@ 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 + CONFIG="/etc/alxconfig-ng/state/state" + clearconfig + addconfig "ALX_STATE=\"${ALX_STATE}\"" + addconfig "ALX_IFACE=\"${ALX_IFACE}\"" } @@ -434,8 +435,8 @@ 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-}" + alx_utils="$(magequery -n alxconfig-ng | sed 's:.*\[\ \(.*\)\ \].*:\1:')" + alx_utils="${alx_utils/alxconfig-ng-}" mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')" evaluate_retval @@ -565,7 +566,16 @@ then # set an device alias for modprobe.conf [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d - echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0.conf + # update only if not the same (to speed up bootprocess - no depmod) + CONFIG="/etc/modprobe.d/net.${ALX_IFACE}.conf" + clearconfig + addconfig "alias ${ALX_IFACE} ${cfg_network_module}" + + # update confd-networking default iface + [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} + CONFIG="${SETTINGSPATH}/confd-networking" + clearconfig + addconfig "${ALX_IFACE}" # regenerate modprobe.conf [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!" @@ -588,10 +598,38 @@ # now generate fluxbox config files # fluxbox main config - cat ${ALX_SKELETONS}/fluxbox/init > ${ALX_UNPRIV_HOME}/.fluxbox/init + local fbinit + if [ -f ${ALX_SKELETONS}/fluxbox/init ] + then + fbinit="${ALX_SKELETONS}/fluxbox/init" + else + fbinit="/usr/share/fluxbox/init" + fi + cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init # fluxbox autostart - cat ${ALX_SKELETONS}/fluxbox/apps > ${ALX_UNPRIV_HOME}/.fluxbox/apps + CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps" + # do not show decorations on messages generated with xmessage + if [ -x /usr/bin/xmessage ] + then + addconfig '[app] (xmessage)' + addconfig ' [Deco] {NONE}' + addconfig '[end]' + fi + # add icon utility + [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}' + # add numlock utility + [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}' + + # fluxbox hotkeys + local fbkeys + if [ -f ${ALX_SKELETONS}/fluxbox/keys ] + then + fbkeys="${ALX_SKELETONS}/fluxbox/keys" + else + fbkeys="/usr/share/fluxbox/keys" + fi + cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys # fluxbox menu header cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu @@ -609,14 +647,33 @@ # add a newline (maybe there is no crlf in the footer) echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu - # setup some standart icons (sysinfo.lnk) - # basic config - cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc - # clean desktop icon location - [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop - install -d ${ALX_UNPRIV_HOME}/.xtdesktop + [ -d ${ALX_UNPRIV_HOME}/.idesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.idesktop + install -d ${ALX_UNPRIV_HOME}/.idesktop + + # add shutdown, reboot icons + local name + # default settings + declare -i x=30 + declare -i y=30 + for i in shutdown reboot + do + case ${i} in + shutdown) name="Herunterfahren" ;; + reboot) name="Neustarten" ;; + esac + + generate_icon \ + --name "${name}" \ + --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \ + --icon "${ALX_SESSIONS_ICONS}/${i}.png" \ + --dest "${dest}/${i}.lnk" \ + --xres "${x}" \ + --yres "${y}" + + y=$((${y} + 80)) + done # last but not least gen a icon with some sys informations local sysinfo @@ -638,22 +695,21 @@ --name "${sysinfo}" \ --command "exit 0" \ --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ - --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ + --dest "${ALX_UNPRIV_HOME}/.idesktop/sysinfo.lnk" \ --xres "${xres}" \ --yres "${yres}" \ --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 + chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop + if [ -f ${ALX_UNPRIV_HOME}/.ideskrc ] + then + chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc + fi } # start|stop @@ -702,7 +758,7 @@ ${rc_base}/init.d/network start else rc_print "Starting default dhcp based networking ... " - ${ALX_DHCP_PROG} ${ALX_DHCP_START} &> /dev/null + ${ALX_DHCP_PROG} ${ALX_DHCP_START} ${ALX_IFACE} &> /dev/null evaluate_retval fi ;; @@ -733,55 +789,68 @@ reset_system_settings() { # force load of de kbdkeys - loadkeys -q de + [ -x /usr/bin/loadkeys ] && loadkeys -q de + [ -x /sbin/loadkmap ] && loadkmap < /usr/share/busybox/keymaps/de.kmap rc_echo - rc_echo -en ${COLRED} - rc_echo -n "*** Warning: you are about to reset *all* local settings on this system!" - rc_echo -e ${COLDEFAULT} - rc_echo "*** Do you really want to continue ?" - rc_echo -n "*** Enter 'yes' to continue, anything else to abort: " + rc_echo -en "${COLRED}" + rc_echo -n '--- Warning: you are about to reset *all* local settings on this system!' + rc_echo -e "${COLDEFAULT}" + rc_echo '--- Do you really want to continue ?' + rc_echo -n '--- Enter 'yes' to continue, anything else to abort: ' read kbinsert if [[ ${kbinsert} = yes ]] then - rc_echo -en ${COLRED} - rc_echo -n "*** OK, you really want it ... killing all settings: " + rc_echo -en "${COLRED}" + rc_echo -n '--- OK, you really want it ... killing all settings: ' for i in 3 2 1 now do rc_echo -n " ${i}" sleep 1 done - rc_echo -e ${COLDEFAULT} + rc_echo -e "${COLDEFAULT}" ## reset all settings: - rm -rf ${SETTINGSPATH}/* + rm -rf ${SETTINGSPATH} rm -f /etc/alxconfig-ng/serial rm -rf /etc/alxconfig-ng/state + local i + for i in xserver netcard knoppix mouse + do + [[ -f /etc/conf.d/hwsetup/${i} ]] && rm /etc/conf.d/hwsetup/${i} + done # clear all printers & net-shares :> /etc/printcap # remove lprng rc-config del lprng &> /dev/null + rc-config del nmbd &> /dev/null # remove all user settings [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} + install -o ${ALX_UNPRIV_USER} -g ${ALX_UNPRIV_GROUP} -d ${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 --no-run-if-empty rm # remove all old nics and modules configs - find /etc/conf.d -type f -name 'net.*' | xargs rm - find /etc/modprobe.d -type f -name 'net.*' | xargs rm + find /etc/conf.d -type f -name 'net.*' | xargs --no-run-if-empty rm + find /etc/modprobe.d -type f -name 'net.*' | xargs --no-run-if-empty rm # restore default networking cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 + local CONFIG="/etc/hostname" + clearconfig + addconfig "${ALX_DEFAULT_HOSTNAME}" - rc_echo "I am done now, press [Enter] to reboot system ..." + rc_echo -n "I am done now, press [Enter] to reboot system ..." else - rc_echo "Aborted, press [Enter] to reboot system ..." + rc_echo -n "Aborted, press [Enter] to reboot system ..." fi read - reboot + sync + mount -oremount,ro / + reboot -f } onboot_interface_list()