#!/bin/bash # note: must be startet before /etc/rc.d/init.d/modules !!! #%rlevels: 7:s #%start: 52 #%stop: #deps #%needs: #%before: #%after: write_x11_config() { local xserver local xfconfig local HAS_VNC #xfree or xorg ? xserver="$(readlink /usr/X11R6/bin/X)" case ${xserver} in Xorg) xfconfig=/etc/X11/xorg.conf ;; XFree86) xfconfig=/etc/X11/XF86Config ;; *) echo "Unkown xserver. aborting." exit 1 ;; esac #got we vnc support ? if [ -f /usr/X11R6/lib/modules/vnc.so ] then HAS_VNC="yes" else HAS_VNC="no" fi #show which server we use echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server " #show if we have vnc if [ "${HAS_VNC}" = "yes" ] then echo "with vnc enabled ..." else echo "..." fi #create a new clear xfconfig file echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig} echo '' >> ${xfconfig} #write modules echo '' >> ${xfconfig} echo 'Section "Module"' >> ${xfconfig} echo ' Load "dbe"' >> ${xfconfig} echo ' SubSection "extmod"' >> ${xfconfig} echo ' Option "omit xfree86-dga"' >> ${xfconfig} echo ' EndSubSection' >> ${xfconfig} echo ' Load "type1"' >> ${xfconfig} echo ' Load "speedo"' >> ${xfconfig} echo ' Load "freetype"' >> ${xfconfig} echo '# Load "xtt"' >> ${xfconfig} echo '# Load "glx"' >> ${xfconfig} echo ' Load "dri"' >> ${xfconfig} [ "${HAS_VNC}" = "yes" ] && echo ' Load "vnc"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} #fonts echo '' >> ${xfconfig} echo 'Section "Files"' >> ${xfconfig} echo ' RgbPath "/usr/X11R6/lib/X11/rgb"' >> ${xfconfig} case ${xserver} in Xorg) echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig} echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig} echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig} echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig} echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig} echo ' #FontPath "/usr/share/fonts/Speedo/"' >> ${xfconfig} echo ' #FontPath "/usr/share/fonts/Type1/"' >> ${xfconfig} echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig} echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig} echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig} echo ' FontPath "/usr/share/fonts/100dpi/"' >> ${xfconfig} ;; XFree86) echo ' FontPath "/usr/X11R6/lib/X11/fonts/local/"' >> ${xfconfig} echo ' FontPath "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig} echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig} echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig} echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig} echo ' #FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"' >> ${xfconfig} echo ' #FontPath "/usr/X11R6/lib/X11/fonts/Type1/"' >> ${xfconfig} echo ' FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig} echo ' FontPath "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig} echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig} echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"' >> ${xfconfig} ;; esac echo '# ModulePath "/usr/X11R6/lib/modules"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} #server flags echo '' >> ${xfconfig} echo 'Section "ServerFlags"' >> ${xfconfig} echo '# Option "DontVTSwitch"' >> ${xfconfig} echo '# Option "DontZap"' >> ${xfconfig} echo '# Option "Dont Zoom"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} #keyboard echo '' >> ${xfconfig} echo 'Section "InputDevice"' >> ${xfconfig} echo ' Identifier "Keyboard1"' >> ${xfconfig} case ${xserver} in Xorg) echo ' Driver "kbd"' >> ${xfconfig} ;; XFree86) echo ' Driver "Keyboard"' >> ${xfconfig} ;; esac echo ' Option "AutoRepeat" "500 30"' >> ${xfconfig} echo '# Option "Xleds" "1 2 3"' >> ${xfconfig} case ${xserver} in Xorg) echo ' Option "XkbRules" "xorg"' >> ${xfconfig} ;; XFree86) echo ' Option "XkbRules" "xfree86"' >> ${xfconfig} ;; esac echo ' Option "XkbModel" "pc104"' >> ${xfconfig} echo ' Option "XkbLayout" "de"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} #mouse #to be safe local MOUSETYPE XMOUSETYPE FULLNAME DEVICE #get config [ -f /etc/sysconfig/hwsetup/mouse ] && source /etc/sysconfig/hwsetup/mouse echo '' >> ${xfconfig} echo 'Section "InputDevice"' >> ${xfconfig} echo ' Identifier "Mouse1"' >> ${xfconfig} echo ' Driver "mouse"' >> ${xfconfig} if [ -n "${XMOUSETYPE}" ] then echo " Option \"Protocol\" \"${XMOUSETYPE}\"" >> ${xfconfig} else echo ' Option "Protocol" "PS/2"' >> ${xfconfig} fi if [ -n "${DEVICE}" ] then #show what we got echo -e ${COLOREDSTAR}"Mouse (${MOUSE_FULLNAME} found at ${MOUSE_DEVICE}" #is there any mouse module than try to load it if [ "${MOUSETYPE}" = "ps2" ] then #kernel 2.6 if [ -f /lib/modules/$(uname -r)/kernel/drivers/input/mouse/psmouse.ko ] then echo -e ${COLOREDSTAR}"Loading kernel-module 'psmouse' ..." echo "psmouse" >> /etc/modules.autoload.d/kernel-$(kernel_major_version) fi #kernel 2.4 #if [ -f /lib/modules/$(uname -r)/kernel/drivers/input/mouse/psmouse.ko ] #then # echo -e ${COLOREDSTAR}"Loading kernel-module 'psmouse' ..." # echo "psmouse" >> /etc/modules.autoload.d/kernel-$(kernel_major_version) #fi else #kernel 2.6 if [ -a /lib/modules/$(uname -r)/kernel/drivers/input/mouse/sermouse.ko ] then echo -e ${COLOREDSTAR}"Loading kernel-module 'sermouse' ..." echo "sermouse" >> /etc/modules.autoload.d/kernel-$(kernel_major_version) fi #kernel 2.4 #if [ -f /lib/modules/$(uname -r)/kernel/drivers/input/mouse/psmouse.ko ] #then # echo -e ${COLOREDSTAR}"Loading kernel-module 'psmouse' ..." # echo "psmouse" >> /etc/modules.autoload.d/kernel-$(kernel_major_version) #fi fi echo " Option \"Device\" \"${DEVICE}\"" >> ${xfconfig} else echo ' Option "Device" "/dev/mouse"' >> ${xfconfig} fi echo ' Option "Resolution" "1200"' >> ${xfconfig} [ "${XMOUSETYPE}" = "IMPS/2" ] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} #to be safe unset MOUSETYPE XMOUSETYPE FULLNAME DEVICE #vnc keyboard && mouse if [ "${HAS_VNC}" = "yes" ] then echo '' >> ${xfconfig} echo 'Section "InputDevice"' >> ${xfconfig} echo ' Identifier "vncKeyboard"' >> ${xfconfig} echo ' Driver "rfbkeyb"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} echo '' >> ${xfconfig} echo 'Section "InputDevice"' >> ${xfconfig} echo ' Identifier "vncMouse"' >> ${xfconfig} echo ' Driver "rfbmouse"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} fi #monitor echo '' >> ${xfconfig} echo 'Section "Monitor"' >> ${xfconfig} echo ' Identifier "mon0"' >> ${xfconfig} echo ' HorizSync 28 - 96' >> ${xfconfig} echo ' VertRefresh 50-60' >> ${xfconfig} echo ' Option "DPMS"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} #vga #to be safe local XSERVER XMODULE XDESC #get config [ -f /etc/sysconfig/hwsetup/xserver ] && source /etc/sysconfig/hwsetup/xserver echo '' >> ${xfconfig} echo 'Section "Device"' >> ${xfconfig} echo ' Identifier "vga0"' >> ${xfconfig} if [ -n "${XMODULE}" ] then echo -e ${COLOREDSTAR}"Video: ${XDESC}" echo -e ${COLOREDSTAR}"Video module: ${XMODULE}" echo " Driver \"${XMODULE}\"" >> ${xfconfig} else echo -e ${COLOREDSTAR}"Video unknown, trying to use the standard 'vesa' module ..." echo ' Driver "vesa"' >> ${xfconfig} fi #vnc server options if [ "${HAS_VNC}" = "yes" ] then echo '' >> ${xfconfig} echo ' # rfb options' >> ${xfconfig} echo ' Option "rfbauth" "/root/.vnc/passwd"' >> ${xfconfig} echo ' Option "rfbport" "5900"' >> ${xfconfig} echo ' #Option "nevershared"' >> ${xfconfig} echo ' Option "alwaysshared"' >> ${xfconfig} echo ' Option "dontdisconnect"' >> ${xfconfig} echo ' Option "httpdir" "/usr/share/vnc/classes"' >> ${xfconfig} echo ' Option "httpport" "5800"' >> ${xfconfig} echo ' # Option "useraccept"' >> ${xfconfig} echo ' Option "usevnc"' >> ${xfconfig} echo ' # Option "localhost"' >> ${xfconfig} echo ' # Option "interface" "192.168.0.1"' >> ${xfconfig} echo ' # Option "viewonly"' >> ${xfconfig} echo ' # Option "loginauth"' >> ${xfconfig} echo '' >> ${xfconfig} fi echo 'EndSection' >> ${xfconfig} #to be safe unset XSERVER XMODULE XDESC #screens echo '' >> ${xfconfig} echo 'Section "Screen"' >> ${xfconfig} echo ' Identifier "Screen 1"' >> ${xfconfig} echo ' Device "vga0"' >> ${xfconfig} echo ' Monitor "mon0"' >> ${xfconfig} echo ' DefaultDepth 16' >> ${xfconfig} echo ' Subsection "Display"' >> ${xfconfig} echo ' Depth 8' >> ${xfconfig} echo ' Modes "1024x768"' >> ${xfconfig} echo ' ViewPort 0 0' >> ${xfconfig} echo ' EndSubsection' >> ${xfconfig} echo ' Subsection "Display"' >> ${xfconfig} echo ' Depth 16' >> ${xfconfig} echo ' Modes "1024x768"' >> ${xfconfig} echo ' ViewPort 0 0' >> ${xfconfig} echo ' EndSubsection' >> ${xfconfig} echo ' Subsection "Display"' >> ${xfconfig} echo ' Depth 24' >> ${xfconfig} echo ' Modes "1024x768"' >> ${xfconfig} echo ' ViewPort 0 0' >> ${xfconfig} echo ' EndSubsection' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} #server layout echo '' >> ${xfconfig} echo 'Section "ServerLayout"' >> ${xfconfig} echo ' Identifier "Simple Layout"' >> ${xfconfig} echo ' Screen "Screen 1"' >> ${xfconfig} echo ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig} echo ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig} #load vnc keyboard && mouse if [ "${HAS_VNC}" = "yes" ] then echo ' InputDevice "vncMouse" "ExtraPointer"' >> ${xfconfig} echo ' InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig} fi echo 'EndSection' >> ${xfconfig} #dri (here disabled, use default of xserver) echo '' >> ${xfconfig} echo '# Section "DRI"' >> ${xfconfig} echo '# Mode 0666' >> ${xfconfig} echo '# EndSection' >> ${xfconfig} } run_hwdetection() { echo -e ${COLOREDSTAR}"Hardware Autodetection started ..." echo -e ${COLOREDSTAR}"Prozessor: $(cat /proc/cpuinfo |grep "model name" | sed -e 's:model\ name*.*\: ::')" #cleaning up old data-crap if [ -e /etc/sysconfig/hwsetup ] then echo -e ${COLOREDSTAR}"Cleaning up old data ..." rm -f /etc/sysconfig/hwsetup/* fi echo -en "${COLOREDSTAR}";hwsetup -p > /dev/null #clean up modules if [ -f /etc/modules.autoload.d/kernel-$(kernel_major_version) ] then echo -e ${COLOREDSTAR}"Cleaning up /etc/modules.autoload.d/kernel-$(kernel_major_version) ..." echo > /etc/modules.autoload.d/kernel-$(kernel_major_version) evaluate_retval fi #load module for parallel printing if exists if [ -e /lib/modules/`uname -r`/kernel/drivers/char/lp.o ] then echo "lp" >> /etc/modules.autoload.d/kernel-$(kernel_major_version) fi #get what hwsetup has found if [ -f /etc/sysconfig/hwsetup/knoppix ] then source /etc/sysconfig/hwsetup/knoppix fi #network setup (dhcp) #for i in $(cat /proc/net/dev|grep eth.|cut -d ':' -f1) #do # echo -e ${COLOREDSTAR}"Network ${i}: ${NETCARD_FULLNAME}" if [ -n "${NETCARD_DRIVER}" ] then echo -e ${COLOREDSTAR}"Network eth0: ${NETCARD_FULLNAME}" echo -e ${COLOREDSTAR}"Network module: ${NETCARD_DRIVER}" echo "${NETCARD_DRIVER}" >> /etc/modules.autoload.d/kernel-$(kernel_major_version) evaluate_retval fi #done #sound setup if [ -n "${SOUND_DRIVER}" ] then echo -e ${COLOREDSTAR}"Sound (${SOUND_FULLNAME}) found" echo -e ${COLOREDSTAR}"Sound module: ${SOUND_DRIVER}" echo "${SOUND_DRIVER}" >> /etc/modules.autoload.d/kernel-$(kernel_major_version) evaluate_retval fi #write default xfree-config echo -e ${COLOREDSTAR}"Generating x11 configuration ..." write_x11_config evaluate_retval } ########### main part starts here ############## source /etc/sysconfig/rc source $rc_functions case $1 in start) #we wouldn't start hwdetection if settings where imported (alx-only) if [ ! -e /etc/alx-config/imported ] then run_hwdetection fi update_svcstatus $1 splash svc_started "$(basename $0)" 0 ;; restart) $0 start ;; *) echo "Usage: $0 {start|restart}" exit 1 ;; esac