--- alx-src/branches/alxconf-060/init.d/alxsettings 2011/05/11 09:19:45 2039 +++ alx-src/branches/alxconf-060/init.d/alxsettings 2011/06/27 15:20:33 2479 @@ -51,23 +51,9 @@ # 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() { - echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} + rc_mecho Checking system setup ... # get the modules settings # ! is the first thing that must be configured ! @@ -126,7 +112,7 @@ CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) CUR_MTIME=$(date +%s) - echo -e ${COLOREDSTAR} "Trying to validate my serial ..." + rc_print "Trying to validate my serial ..." # nice serial output $CURS_UP @@ -149,11 +135,11 @@ echo if [[ ${ALX_FORCED_RECHECK} = true ]] then - echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} + rc_mecho "Hardware autodetection forced by system-administrator" # always disable CONFD_NETWORKING here export ALX_CONFD_NETWORKING="false" else - echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} + rc_mecho "Preparing system for first boot" fi ALX_HW_DETECT=true hwsetup @@ -189,7 +175,7 @@ # but first check the serial source /etc/alxconfig-ng/serial - echo -e ${COLOREDSTAR} "Trying to validate my serial ..." + rc_print "Trying to validate my serial ..." # nice serial output $CURS_UP @@ -217,7 +203,7 @@ return 0 fi - echo -e ${COLOREDSTAR} "Trying to get new serial ..." + rc_print "Trying to get new serial ..." # request a new serial; one command now (cause must be done in the same session) ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); @@ -289,20 +275,19 @@ source /etc/conf.d/hwsetup/mouse echo - echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} + rc_mecho "Importing detected settings to database" # network - echo -e " Network settings ..." + rc_mecho " Network settings ..." if [[ ${ALX_CONFD_NETWORKING} = true ]] then # get settings - #source ${rc_base}/init.d/network &> /dev/null for iface in $(onboot_interface_list ${network_settings}/net.*) do [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue - echo "WARNING: only importing settings for interface [ ${iface} ] !" - source ${network_settings}/net.${iface} || exit 1 - NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" + rc_echo "WARNING: only importing settings for interface [ ${iface} ] !" + source ${network_settings}/net.${iface} || echo "Error: could not read '${network_settings}/net.${iface}'" + NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)" mysqldo "insert into cfg_network( hostname, @@ -373,7 +358,7 @@ evaluate_retval # xserver - echo -e " Graphic settings ..." + rc_mecho " Graphic settings ..." # xserver general ( mysqldo "insert into cfg_graphic( serial, @@ -392,12 +377,12 @@ evaluate_retval # input - echo -e " Input settings ..." + rc_mecho " Input settings ..." mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');" evaluate_retval # auth - echo -e " Authentification settings ..." + rc_mecho " Authentification settings ..." mysqldo "insert into client_auth( serial, username, @@ -418,19 +403,20 @@ # exchange ssh rsa keys - the first boot needs this ! # or no reboot will work via the webadmin - echo -e " SSH authentification settings ..." + rc_mecho " SSH authentification settings ..." HOME=/root config_ssh_auth evaluate_retval # autostart - echo -e " Autostart settings ..." + rc_mecho " Autostart settings ..." mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" # screensaver - echo -e " Screensaver settings ..." + rc_mecho " Screensaver settings ..." mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" # version info + rc_mecho " OS version info ..." local alx_os local alx_utils alx_os="$(< /etc/mageversion)" @@ -462,10 +448,10 @@ source /etc/conf.d/hwsetup/mouse echo - echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT} + rc_mecho "Updating detected settings in database" # network - echo -e " Network settings ..." + rc_mecho " Network settings ..." if [[ ${ALX_CONFD_NETWORKING} = true ]] then # get settings @@ -473,9 +459,9 @@ for iface in $(onboot_interface_list ${network_settings}/net.*) do [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue - echo "WARNING: only importing settings for interface [ ${iface} ] !" + rc_echo "WARNING: only importing settings for interface [ ${iface} ] !" source ${network_settings}/net.${iface} || exit 1 - NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)" + NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)" mysqldo "update cfg_network set hostname='${ALX_DEFAULT_HOSTNAME}', @@ -514,7 +500,7 @@ evaluate_retval # xserver - echo -e " Graphic settings ..." + rc_mecho " Graphic settings ..." # xserver general mysqldo "update cfg_graphic set module='${XMODULE}', @@ -525,11 +511,12 @@ evaluate_retval # input - echo -e " Input settings ..." + rc_mecho " Input settings ..." mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};" evaluate_retval # version info + rc_mecho " OS version info ..." local alx_os local alx_utils alx_os="$(< /etc/mageversion)" @@ -558,7 +545,7 @@ source /etc/conf.d/hwsetup/knoppix echo - echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} + rc_mecho "Importing detected settings to local system" if [[ ${ALX_CONFD_NETWORKING} = false ]] then @@ -567,7 +554,7 @@ echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0.conf # regenerate modprobe.conf - [ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf" + [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!" evaluate_retval fi @@ -587,10 +574,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 @@ -608,14 +623,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 @@ -637,22 +671,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 @@ -685,40 +718,39 @@ # keeping like always safe: # no network should be startet here, # so we can delete all pid files if one exists - if [[ ! -z $(pidof udhcpc) ]] + if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]] then - echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT} - killall udhcpc &> /dev/null + rc_mecho "Forcing network down" + killall $(basename ${ALX_DHCP_PROG}) &> /dev/null sleep 1 fi [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop - echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} + rc_mecho "Starting preliminary networking ... " # start network configured from /etc/conf.d if [[ ${ALX_CONFD_NETWORKING} = true ]] then ${rc_base}/init.d/network start else - echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT} - # -t 10 timeout of 10 secs - udhcpc -t 10 &> /dev/null + rc_print "Starting default dhcp based networking ... " + ${ALX_DHCP_PROG} ${ALX_DHCP_START} &> /dev/null evaluate_retval fi ;; stop) - echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT} + rc_mecho "Stopping preliminary networking ... " if [[ ${ALX_CONFD_NETWORKING} = true ]] then ${rc_base}/init.d/network stop else - echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT} - ifconfig eth0 down + rc_print "Stopping default dhcp based networking ... " + ifconfig ${ALX_IFACE} down fi - if [[ ! -z $(pidof udhcpc) ]] + if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]] then - killall udhcpc &> /dev/null + killall $(basename ${ALX_DHCP_PROG}) &> /dev/null sleep 1 fi evaluate_retval @@ -734,23 +766,23 @@ { # force load of de kbdkeys loadkeys -q de - echo - echo -en ${COLRED} - echo -n "*** Warning: you are about to reset *all* local settings on this system!" - echo -e ${COLDEFAULT} - echo "*** Do you really want to continue ?" - echo -n "*** Enter 'yes' to continue, anything else to abort: " + 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: " read kbinsert if [[ ${kbinsert} = yes ]] then - echo -en ${COLRED} - 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 - echo -n " ${i}" + rc_echo -n " ${i}" sleep 1 done - echo -e ${COLDEFAULT} + rc_echo -e ${COLDEFAULT} ## reset all settings: rm -rf ${SETTINGSPATH}/* @@ -758,13 +790,10 @@ rm -rf /etc/alxconfig-ng/state # clear all printers & net-shares - :> /etc/cups/printers.conf - :> /etc/samba/smb.conf + :> /etc/printcap - # remove inetd, cups & smb from init - rc-config del inetd &> /dev/null - rc-config del cups &> /dev/null - rc-config del samba &> /dev/null + # remove lprng + rc-config del lprng &> /dev/null # remove all user settings [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} @@ -774,14 +803,14 @@ # remove all old nics and modules configs find /etc/conf.d -type f -name 'net.*' | xargs rm - find /etc/modules.d -type f -name 'net.*' | xargs rm + find /etc/modprobe.d -type f -name 'net.*' | xargs rm # restore default networking cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 - echo "I am done now, press [Enter] to reboot system ..." + rc_echo "I am done now, press [Enter] to reboot system ..." else - echo "Aborted, press [Enter] to reboot system ..." + rc_echo "Aborted, press [Enter] to reboot system ..." fi read reboot @@ -914,4 +943,3 @@ echo "Usage: $0 {start|stop} ..." ;; esac -