--- alx-src/trunk/alxconfig-ng/functions/config_x11.sh 2005/03/08 20:29:46 218 +++ alx-src/branches/alxconf-060/functions/config_x11.sh 2011/06/14 17:20:39 2386 @@ -1,356 +1,145 @@ +# $Id$ # configures the x11 server on the host via mysql db settings -#delme settings -SQL_USER=alx_install -SQL_PASS=@lx -SQL_HOST=128.20.41.110 -SQL_DB=alx_web -ALX_SERIAL=10 - -get_x11_settings() +config_display_manager() { - local x i all DB_X11SETTINGS - - # autodetect or not ? - if [ $(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select monitorid from cfg_graphic where serial='${ALX_SERIAL}") -gt 0 ] - then - # settings from db - - all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select cfg_graphic.module, - cfg_graphic.resolution, - cfg_graphic.depth, - list_monitors.vendor, - list_monitors.model, - list_monitors.hsync, - list_monitors.vrefresh - from list_monitors - inner join cfg_graphic - on cfg_graphic.monitorid=list_monitors.id - and cfg_graphic.serial='${ALX_SERIAL}';") - - echo "DEBUG: ${all}" + # setup slim + cat ${ALX_SKELETONS}/slim/slim.conf > /etc/slim.conf + sed -i "s:@@USERNAME@@:${ALX_UNPRIV_USER}:" /etc/slim.conf - #split'em up and put 'em in an array - declare -i i=0 - for x in ${all} - do - DB_X11SETTINGS[${i}]="${x}" - ((i++)) - done - - # and now put them in usable var names and export them systemwide - export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}" - export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}" - export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}" - export ALX_VENDOR="${DB_X11SETTINGS[3]:=NULL}" - export ALX_MODEL="${DB_X11SETTINGS[4]:=NULL}" - export ALX_HSYNC="${DB_X11SETTINGS[5]:=NULL}" - export ALX_VREF="${DB_X11SETTINGS[6]:=NULL}" - else - # autodetect - all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select module, - resolution, - depth - from cfg_graphic where serial='${ALX_SERIAL}'") - - echo "DEBUG: ${all}" - - #split'em up and put 'em in an array - declare -i i=0 - for x in ${all} - do - DB_X11SETTINGS[${i}]="${x}" - ((i++)) - done - - # and now put them in usable var names and export them systemwide - export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}" - export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}" - export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}" - export ALX_VENDOR="Autodetected" - export ALX_MODEL="Monitor" - export ALX_HSYNC="auto" - export ALX_VREF="auto" - fi - - #which input devices are we using ? - ALX_MOUSE=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select mouse from cfg_input where serial='${ALX_SERIAL}'") - export ALX_MOUSE + # windowmanager + echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc } -write_x11_config() { +config_x11() +{ + local has_tigervnc + local CONFIG # get our settings from the db - get_x11_settings - - # DEBUG - echo "MODULE: '${ALX_MODULE}'" - echo "RESOLUTION: '${ALX_RESOLUTION}'" - echo "DEPTH: '${ALX_DEPTH=}'" - echo "VENDOR: '${ALX_VENDOR}'" - echo "MODEL: '${ALX_MODEL}'" - echo "HSYNC: '${ALX_HSYNC}'" - echo "VREF: '${ALX_VREF}'" - echo "MOUSE: '${ALX_MOUSE}'" - - 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 + evaluate_table cfg_graphic + evaluate_table cfg_input - #got we vnc support ? - if [ -f /usr/X11R6/lib/modules/vnc.so ] + # setup displaymanager + config_display_manager + + # got we vnc support ? + if [ -f /usr/X11R6/lib/xorg/modules/extensions/libvnc.so ] then - HAS_VNC="yes" + has_tigervnc="yes" else - HAS_VNC="no" + has_tigervnc="no" fi - #show which server we use - echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server " + # show which server we use + echo -en ${COLOREDSTAR}"Configuring Xorg x11-server " - #show if we have vnc - if [ "${HAS_VNC}" = "yes" ] + # show if we have vnc + if [[ ${has_tigervnc} = yes ]] then - echo "with vnc enabled ..." + echo "with tigervnc 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 - echo '' >> ${xfconfig} - echo 'Section "InputDevice"' >> ${xfconfig} - echo ' Identifier "Mouse1"' >> ${xfconfig} - echo ' Driver "mouse"' >> ${xfconfig} - echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig} - - local device - case ${ALX_MOUSE} in - IMPS/2|PS/2) device=/dev/psaux;; - Auto) device=/dev/mouse;; - *) device=/dev/mouse;; - esac - - echo ' Option "Resolution" "1200"' >> ${xfconfig} - - [ "${ALX_MOUSE}" = "IMPS/2" ] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig} - - echo 'EndSection' >> ${xfconfig} - - #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 - if [ -x "/sbin/ddcxinfo-knoppix" ] && - [ "${ALX_HSYNC}" = "auto" ] || - [ "${ALX_VREF}" = "auto" ] - then - ddcxinfo-knoppix -monitor >> ${xfconfig} + # set_input_keyboard + CONFIG="/etc/X11/xorg.conf.d/25-layout.conf" + clearconfig + addconfig 'Section "InputClass"' + addconfig ' Identifier "keyboard layout"' + addconfig ' MatchIsKeyboard "on"' + addconfig ' Option "XkbLayout" "de"' + addconfig 'EndSection' + + # graphic driver + CONFIG="/etc/X11/xorg.conf.d/25-device.conf" + clearconfig + addconfig 'Section "Device"' + addconfig ' Identifier "Card0"' + addconfig " Driver \"${cfg_graphic_module}\"" + addconfig 'EndSection' + + # vnc module + if [[ ${has_tigervnc} = yes ]] + then + CONFIG="/etc/X11/xorg.conf.d/25-module.conf" + clearconfig + addconfig 'Section "Module"' + addconfig ' Load "vnc"' + addconfig 'EndSection' + fi + + # monitor + CONFIG="/etc/X11/xorg.conf.d/25-monitor.conf" + clearconfig + addconfig 'Section "Monitor"' + addconfig ' Identifier "Monitor0"' + addconfig ' Option "DPMS"' + + # add hsync, vrefresh + if [[ -x /sbin/ddcxinfo-knoppix ]] + then + local hsync="$(ddcxinfo-knoppix -hsync)" + local vsync="$(ddcxinfo-knoppix -vsync)" + # fallback + [[ ${hsync} = 0-0 ]] && hsync="28-96" + [[ ${vsync} = 0-0 ]] && vsync="50-60" + + addconfig + addconfig " HorizSync ${hsync}" + addconfig " VertRefresh ${vsync}" + fi + + # add cvt modelines + addconfig + local cvt="/usr/X11R6/bin/cvt" + local modeline + modeline=$("${cvt}" "${cfg_graphic_resolution%x*}" "${cfg_graphic_resolution#*x}" "${cfg_graphic_refresh_rate}" | sed -e 's:^:\t:g' -e 's:_.*\":\":') + addconfig "${modeline}" + # add ddcxinfo-knoppix modelines (fallback) + if [[ -x /sbin/ddcxinfo-knoppix ]] + then + addconfig + addconfig $(ddcxinfo-knoppix -modelines) + fi + addconfig 'EndSection' + + # screen + CONFIG="/etc/X11/xorg.conf.d/25-screen.conf" + clearconfig + addconfig 'Section "Screen"' + addconfig ' Identifier "Screen0"' + addconfig ' Monitor "Monitor0"' + addconfig " DefaultDepth ${cfg_graphic_depth}" + addconfig ' SubSection "Display"' + addconfig " Depth ${cfg_graphic_depth}" + addconfig " Modes \"${cfg_graphic_resolution}\"" + addconfig ' ViewPort 0 0' + addconfig ' EndSubSection' + # vnc auth + if [[ ${has_tigervnc} = yes ]] + then + addconfig ' Option "SecurityTypes" "VncAuth"' + addconfig ' Option "UserPasswdVerifier" "VncAuth"' + addconfig ' Option "PasswordFile" "/root/.vnc/passwd"' + fi + addconfig 'EndSection' + + # fixes + # disable LVDS-1 on zotacs + if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]] + then + CONFIG="/etc/X11/xorg.conf.d/30-fix-zotac.conf" + clearconfig + addconfig 'Section "Monitor"' + addconfig ' Identifier "LVDS1"' + addconfig ' Option "Ignore" "True"' + addconfig 'EndSection' else - echo '' >> ${xfconfig} - echo "# Monitor: ${ALX_VENDOR} ${ALX_MODEL}" >> ${xfconfig} - echo 'Section "Monitor"' >> ${xfconfig} - echo ' Identifier "Monitor0"' >> ${xfconfig} - echo " HorizSync ${ALX_HSYNC}" >> ${xfconfig} - echo " VertRefresh ${ALX_VREF}" >> ${xfconfig} - echo ' Option "DPMS"' >> ${xfconfig} - echo 'EndSection' >> ${xfconfig} - fi - - #vga - echo '' >> ${xfconfig} - echo 'Section "Device"' >> ${xfconfig} - echo ' Identifier "vga0"' >> ${xfconfig} - echo " Driver \"${ALX_MODULE}\"" >> ${xfconfig} - - #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} - - #screens - echo '' >> ${xfconfig} - echo 'Section "Screen"' >> ${xfconfig} - echo ' Identifier "Screen 1"' >> ${xfconfig} - echo ' Device "vga0"' >> ${xfconfig} - echo ' Monitor "Monitor0"' >> ${xfconfig} - echo " DefaultDepth ${ALX_DEPTH}" >> ${xfconfig} - echo ' Subsection "Display"' >> ${xfconfig} - echo " Depth ${ALX_DEPTH}" >> ${xfconfig} - echo " Modes \"${ALX_RESOLUTION}\"" >> ${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} + # clear this file + if [ -f /etc/X11/xorg.conf.d/30-fix-zotac.conf ] + then + rm /etc/X11/xorg.conf.d/30-fix-zotac.conf + fi fi - - echo 'EndSection' >> ${xfconfig} - - #dri (here disabled, use default of xserver) - echo '' >> ${xfconfig} - echo '# Section "DRI"' >> ${xfconfig} - echo '# Mode 0666' >> ${xfconfig} - echo '# EndSection' >> ${xfconfig} } -