#!/bin/bash # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/hwdetect,v 1.7 2008-04-10 20:26:46 niro Exp $ # note: must be startet before /etc/rc.d/init.d/modules !!! #%rlevels: 7:s #%start: 52 #%stop: #deps #%needs: #%before: #%after: add_x11conf() { local var="$1" echo "${var}" >> ${xfconfig} || die "add_x11conf() adding \$var" } add_modconf() { local var="$1" local config # get the right config if [[ -f /etc/modules.autoload ]] then config=/etc/modules.autoload else config=/etc/modules.autoload.d/kernel-$(kernel_major_version) fi echo "${var}" >> ${config} } write_x11_config() { local xserver local xfconfig local HAS_VNC local USE_AIGLX local rgbpath local fontpath local modulespath local i # check command line for params for i in $(cat /proc/cmdline) do case "${i}" in aiglx) USE_AIGLX=yes;; esac done # 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 # have we vnc support ? if [[ -f /usr/X11R6/lib/modules/vnc.so ]] || [[ -f /usr/X11R6/lib/modules/extensions/vnc.so ]] || [[ -f /usr/lib/xorg/modules/extensions/vnc.so ]] then HAS_VNC="yes" else HAS_VNC="no" fi # show which xserver we going to 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 add_x11conf '' add_x11conf 'Section "Module"' add_x11conf ' Load "dbe"' add_x11conf ' SubSection "extmod"' add_x11conf ' Option "omit xfree86-dga"' add_x11conf ' EndSubSection' add_x11conf ' Load "type1"' add_x11conf ' Load "speedo"' add_x11conf ' Load "freetype"' add_x11conf '# Load "xtt"' if [[ ${USE_AIGLX} = yes ]] then add_x11conf ' Load "glx"' else add_x11conf '# Load "glx"' fi add_x11conf ' Load "dri"' [[ ${HAS_VNC} = yes ]] && add_x11conf ' Load "vnc"' add_x11conf 'EndSection' # enable composite for aiglx if [[ ${USE_AIGLX} = yes ]] then add_x11conf 'Section "Extensions"' add_x11conf ' Option "Composite" "Enable"' add_x11conf 'EndSection' fi # fonts case ${xserver} in Xorg) fontpath="/usr/share/fonts" rgbpath="/usr/share/X11" modulespath="/usr/lib/xorg/modules" ;; XFree86) fontpath="/usr/X11R6/lib/X11/fonts" rgbpath="/usr/X11R6/lib/X11" modulespath="/usr/X11R6/lib/modules" ;; esac add_x11conf '' add_x11conf 'Section "Files"' add_x11conf " RgbPath \"${rgbpath}/rgb\"" add_x11conf " FontPath \"${fontpath}/local/\"" add_x11conf " FontPath \"${fontpath}/misc/\"" add_x11conf " FontPath \"${fontpath}/75dpi/:unscaled\"" add_x11conf " FontPath \"${fontpath}/100dpi/:unscaled\"" add_x11conf ' #prevents slow startup when disabled -> speedo, type1' add_x11conf " #FontPath \"${fontpath}/Speedo/\"" add_x11conf " #FontPath \"${fontpath}/fonts/Type1/\"" add_x11conf " FontPath \"${fontpath}/fonts/TrueType/\"" add_x11conf " FontPath \"${fontpath}/freefont/\"" add_x11conf " FontPath \"${fontpath}/75dpi/\"" add_x11conf " FontPath \"${fontpath}/100dpi/\"" add_x11conf "# ModulePath \"${modulespath}\"" add_x11conf 'EndSection' # xserver flags add_x11conf '' add_x11conf 'Section "ServerFlags"' add_x11conf '# Option "DontVTSwitch"' add_x11conf '# Option "DontZap"' add_x11conf '# Option "Dont Zoom"' add_x11conf 'EndSection' # keyboard add_x11conf '' add_x11conf 'Section "InputDevice"' add_x11conf ' Identifier "Keyboard1"' case ${xserver} in Xorg) add_x11conf ' Driver "kbd"' ;; XFree86) add_x11conf ' Driver "Keyboard"' ;; esac add_x11conf ' Option "AutoRepeat" "500 30"' add_x11conf '# Option "Xleds" "1 2 3"' case ${xserver} in Xorg) add_x11conf ' Option "XkbRules" "xorg"' ;; XFree86) add_x11conf ' Option "XkbRules" "xfree86"' ;; esac add_x11conf ' Option "XkbModel" "pc104"' add_x11conf ' Option "XkbLayout" "de"' add_x11conf 'EndSection' # mouse # to be safe local MOUSETYPE XMOUSETYPE FULLNAME DEVICE # get config [ -f /etc/sysconfig/hwsetup/mouse ] && source /etc/sysconfig/hwsetup/mouse add_x11conf '' add_x11conf 'Section "InputDevice"' add_x11conf ' Identifier "Mouse1"' add_x11conf ' Driver "mouse"' if [[ -n ${XMOUSETYPE} ]] then add_x11conf " Option \"Protocol\" \"${XMOUSETYPE}\"" else add_x11conf ' Option "Protocol" "PS/2"' 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' ..." add_modconf 'psmouse' 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' ..." add_modconf 'sermouse' 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 add_x11conf " Option \"Device\" \"${DEVICE}\"" else add_x11conf ' Option "Device" "/dev/mouse"' fi add_x11conf ' Option "Resolution" "1200"' [[ ${XMOUSETYPE} = IMPS/2 ]] && add_x11conf ' Option "ZAxisMapping" "4 5"' add_x11conf 'EndSection' # to be safe unset MOUSETYPE XMOUSETYPE FULLNAME DEVICE # vnc keyboard && mouse if [[ ${HAS_VNC} = yes ]] then add_x11conf '' add_x11conf 'Section "InputDevice"' add_x11conf ' Identifier "vncKeyboard"' add_x11conf ' Driver "rfbkeyb"' add_x11conf 'EndSection' add_x11conf '' add_x11conf 'Section "InputDevice"' add_x11conf ' Identifier "vncMouse"' add_x11conf ' Driver "rfbmouse"' add_x11conf 'EndSection' fi # monitor add_x11conf '' # using knoppix ddcxinfo if [[ -x /sbin/ddcxinfo-knoppix ]] then ddcxinfo-knoppix -monitor >> ${xfconfig} else # some conservative default values add_x11conf 'Section "Monitor"' add_x11conf ' Identifier "mon0"' add_x11conf ' HorizSync 28 - 96' add_x11conf ' VertRefresh 50-60' add_x11conf ' Option "DPMS"' add_x11conf 'EndSection' fi # vga # to be safe local XSERVER XMODULE XDESC # get config [ -f /etc/sysconfig/hwsetup/xserver ] && source /etc/sysconfig/hwsetup/xserver add_x11conf '' add_x11conf 'Section "Device"' add_x11conf ' Identifier "vga0"' if [[ -n ${XMODULE} ]] then # vmware module has some probs with fb consoles # very dirty glyphes appear, so we use vesa instead [[ ${XMODULE} = vmware ]] && XMODULE="vesa" # i810 needs the intel-agp kernel module to run probably [[ ${XMODULE} = i810 ]] && \ [ -f /lib/modules/$(uname -r)/kernel/drivers/char/agp/intel-agp.ko ] && \ add_modconf 'intel-agp' echo -e ${COLOREDSTAR}"Video: ${XDESC}" echo -e ${COLOREDSTAR}"Video module: ${XMODULE}" add_x11conf " Driver \"${XMODULE}\"" else echo -e ${COLOREDSTAR}"Video unknown, trying to use the standard 'vesa' module ..." add_x11conf ' Driver "vesa"' fi if [[ ${USE_AIGLX} = yes ]] then add_x11conf '' [[ ${XMODULE} = radeon ]] && add_x11conf ' Option "XAANoOffscreenPixmaps" "true"' add_x11conf ' Option "DRI" "true"' add_x11conf '' fi # vnc server options if [[ ${HAS_VNC} = yes ]] then add_x11conf '' add_x11conf ' # rfb options' add_x11conf ' Option "rfbauth" "/root/.vnc/passwd"' add_x11conf ' Option "rfbport" "5900"' add_x11conf ' # Option "nevershared"' add_x11conf ' Option "alwaysshared"' add_x11conf ' Option "dontdisconnect"' add_x11conf ' Option "httpdir" "/usr/share/vnc/classes"' add_x11conf ' Option "httpport" "5800"' add_x11conf ' # Option "useraccept"' add_x11conf ' Option "usevnc"' add_x11conf ' # Option "localhost"' add_x11conf ' # Option "interface" "192.168.0.1"' add_x11conf ' # Option "viewonly"' add_x11conf ' # Option "loginauth"' add_x11conf '' fi add_x11conf 'EndSection' # to be safe unset XSERVER XMODULE XDESC # screens add_x11conf '' add_x11conf 'Section "Screen"' add_x11conf ' Identifier "Screen 1"' add_x11conf ' Device "vga0"' add_x11conf ' Monitor "Monitor0"' add_x11conf ' DefaultDepth 16' add_x11conf ' Subsection "Display"' add_x11conf ' Depth 8' add_x11conf ' Modes "1024x768"' add_x11conf ' ViewPort 0 0' add_x11conf ' EndSubsection' add_x11conf ' Subsection "Display"' add_x11conf ' Depth 16' add_x11conf ' Modes "1024x768"' add_x11conf ' ViewPort 0 0' add_x11conf ' EndSubsection' add_x11conf ' Subsection "Display"' add_x11conf ' Depth 24' add_x11conf ' Modes "1024x768"' add_x11conf ' ViewPort 0 0' add_x11conf ' EndSubsection' add_x11conf 'EndSection' # server layout add_x11conf '' add_x11conf 'Section "ServerLayout"' add_x11conf ' Identifier "Simple Layout"' add_x11conf ' Screen "Screen 1"' add_x11conf ' InputDevice "Mouse1" "CorePointer"' add_x11conf ' InputDevice "Keyboard1" "CoreKeyboard"' # load vnc keyboard && mouse if [[ ${HAS_VNC} = yes ]] then add_x11conf ' InputDevice "vncMouse" "ExtraPointer"' add_x11conf ' InputDevice "vncKeyboard" "ExtraKeyboard"' fi if [[ ${USE_AIGLX} = yes ]] then add_x11conf '' add_x11conf ' Option "AIGLX" "true"' add_x11conf '' fi add_x11conf 'EndSection' # dri (here disabled, use default of xserver) add_x11conf '' if [[ ${USE_AIGLX} = yes ]] then add_x11conf 'Section "DRI"' add_x11conf ' Group 0' add_x11conf ' Mode 0666' add_x11conf 'EndSection' else add_x11conf '# Section "DRI"' add_x11conf '# Group 0' add_x11conf '# Mode 0666' add_x11conf '# EndSection' fi } 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 if [ -f /etc/modules.autoload ] then echo -e ${COLOREDSTAR}"Cleaning up /etc/modules.autoload ..." echo > /etc/modules.autoload evaluate_retval fi # load module for parallel printing if exists if [ -e /lib/modules/$(uname -r)/kernel/drivers/char/lp.o ] then add_modconf 'lp' fi # get what hwsetup has found if [ -f /etc/sysconfig/hwsetup/knoppix ] then source /etc/sysconfig/hwsetup/knoppix fi # network setup (dhcp) if [[ -n ${NETCARD_DRIVER} ]] then echo -e ${COLOREDSTAR}"Network eth0: ${NETCARD_FULLNAME}" echo -e ${COLOREDSTAR}"Network module: ${NETCARD_DRIVER}" add_modconf "${NETCARD_DRIVER}" evaluate_retval fi # sound setup if [[ -n ${SOUND_DRIVER} ]] then echo -e ${COLOREDSTAR}"Sound (${SOUND_FULLNAME}) found" echo -e ${COLOREDSTAR}"Sound module: ${SOUND_DRIVER}" add_modconf "${SOUND_DRIVER}" 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