#!/sbin/runscript # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo/src/livecd-tools/autoconfig,v 1.49 2005/11/22 16:21:56 wolf31o2 Exp $ DHCP="yes" DETECT="yes" GPM="yes" PCMCIA="no" HOTPLUG="yes" APM="no" ACPI="no" IDEDMA="yes" ALSA="yes" X11="yes" get_config() { CMDLINE="$(cat /proc/cmdline)" for x in ${CMDLINE} ; do case "${x}" in nodetect) DETECT="no" GPM="no" HOTPLUG="no" APM="no" ACPI="no" ALSA="no" X11="no" ;; nodhcp) DHCP="no" ;; nogpm) GPM="no" ;; dopcmcia) PCMCIA="yes" ;; doapm) APM="yes" ACPI="no" ;; acpi=on|acpi=force) APM="no" ACPI="yes" ;; ide=nodma) IDEDMA="no" ;; nohotplug) HOTPLUG="no" ;; nosound) ALSA="no" ;; nox) X11="no" ;; esac done } depend() { need modules before net # provide gpm pcmcia apmd acpid coldplug hdparm alsasound x-setup } # Checks whether a service will be started by autoconfig. # Usage: check_svc var service [service_alternative] check_svc() { if [ "$1" = "yes" ] then if [ -x "/etc/init.d/$2" ] then echo "$2" elif [ -n "$3" -a -x "/etc/init.d/$3" ] then echo "$3" fi fi } # Prints an ordered list of services that will be started by autoconfig. list_services() { get_config local svcs="$(check_svc ${APM} apmd)" svcs="${svcs} $(check_svc ${ACPI} acpid)" svcs="${svcs} $(check_svc ${IDEDMA} hdparm)" svcs="${svcs} $(check_svc ${PCMCIA} pcmcia)" svcs="${svcs} $(check_svc ${GPM} gpm)" svcs="${svcs} $(check_svc ${HOTPLUG} coldplug hotplug)" svcs="${svcs} $(check_svc ${ALSA} alsasound)" echo ${svcs} } # Only used on SGI CDs, this determines: # A) CPU Type # B) System detect_mips() { local cpuinfo="$(awk -F: '/^cpu model/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1 | cut -d" " -f2,3)" local machinfo="$(awk -F: '/^system type/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | cut -d" " -f2-)" local machtype="" case "${machinfo}" in "SGI Indy") machtype="SGI Indy" # Indy R4x00/R5000 ;; "SGI Indigo2") case "${cpuinfo}" in R4*) machtype="SGI Indigo2" # I2 R4x00 ;; R8*) machtype="SGI Indigo2 Power" # I2 R8000 ;; R10*) machtype="SGI Indigo2 Impact" # I2 R10000 ;; esac ;; "SGI O2"|"SGI IP32") machtype="SGI O2" # O2 R5K/RM5K2/RM7K/R10K/R12K ;; "SGI Octane"|"SGI IP30") machtype="SGI Octane" # Octane R10K/R12K/R14K ;; "SGI Origin"|"SGI IP27") machtype="SGI Origin" # Origin R10K/R12K ;; *) machtype="Unknown SGI MIPS" # ??? ;; esac PC="Detected an ${machtype} w/ ${numcpu} ${cpuinfo} ${bit}" } detect_x86_amd64() { local cpuinfo="$(awk -F: '/^model name/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)" local mhz="$(awk -F: '/^cpu MHz/{printf " %dMHz",int($2)};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)" PC="Detected ${numcpu} ${cpuinfo} ${mhz} ${bit}" } start() { echo "0" > /proc/sys/kernel/printk get_config if [ "${DETECT}" = "yes" ] then ebegin "Hardware detection started" local numcpu="$(awk -F: '/^processor/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | wc -l)" local arch="$(uname -m)" local ismips="no" [ "${numcpu}" -gt '1' ] && bit="CPUs" || bit="CPU" case ${arch} in mips|mips64) detect_mips ismips="yes" ;; i?86|x86_64) detect_x86_amd64 ;; *) PC="$(awk -F: '/^processor/{printf "Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>/dev/null)" ;; esac einfo "${PC}" [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null eend else ewarn "Hardware detection disabled via cmdline ..." fi if [ "${APM}" = "yes" ] then modprobe apm power_off=1 >/dev/null 2>&1 && \ einfo "APM BIOS found, power management functions enabled ..." [ -x /etc/init.d/apmd ] && start_service apmd else [ "${ismips}" = "no" ] && ewarn "Not Loading APM Bios support ..." fi if [ "${ACPI}" = "yes" ] then modprobe processor >/dev/null 2>&1 && \ ebegin "ACPI power management functions enabled" && \ modprobe thermal >/dev/null modprobe fan >/dev/null 2>&1 modprobe button >/dev/null 2>&1 modprobe battery >/dev/null 2>&1 modprobe ac >/dev/null 2>&1 [ -x /etc/init.d/acpid ] && start_service acpid eend else [ "${ismips}" = "no" ] && ewarn "Not Loading ACPI support ..." fi if [ "${IDEDMA}" = "yes" ] then if [ "${ismips}" = "no" ]; then [ -x /etc/init.d/hdparm ] && start_service hdparm fi fi if [ "${PCMCIA}" = "yes" ] then einfo "PCMCIA enabled via cmdline ..." [ -x /etc/init.d/pcmcia ] && start_service pcmcia fi if [ "${DHCP}" = "no" ] then sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \ -e '/^iface_eth.*dhcp.*/ s/^/#/' \ -e '/^config_eth.*dhcp.*/ s/^/#/' \ /etc/conf.d/net ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..." fi # Read in what hwsetup has found [ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo # Mouse if [ -n "${MOUSE_DEVICE}" ] then einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..." source /etc/sysconfig/mouse if [ -x /usr/sbin/gpm ] then [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ] \ && sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm \ || echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ] \ && sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm \ || echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm [ "${GPM}" = "yes" ] \ && [ -x /etc/init.d/gpm ] && start_service gpm fi fi if [ "${HOTPLUG}" = "yes" ] then # Check whether we should be using hotplug or coldplug if [ -x /etc/init.d/coldplug ] then start_service coldplug elif [ -x /etc/init.d/hotplug ] then start_service hotplug fi else ewarn "Hotplug disabled via cmdline ..." fi [ "${DETECT}" = "no" ] && DHCP="no" [ "${DETECT}" = "yes" ] \ && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)" if [ -n "${NETDEVICES}" ] then for nics in ${NETDEVICES} do if [ "${DHCP}" = "yes" ] then einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..." dhcpcd -n -h $(hostname) & fi done else ewarn "No Network device auto detected ..." fi if [ "${ALSA}" = "yes" ] then if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ] then local sndmsg="Soundcard:\n" [ -n "${SOUND_FULLNAME}" ] \ && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n" [ -n "${SOUND_DRIVER}" ] \ && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n" einfo "${sndmsg}" if [ -x /etc/init.d/alsasound ] then start_service alsasound fi if [ -e /proc/asound/cards ] then for i in $(cat /proc/asound/cards | cut -d" " -f1) do if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ] then amixer -c $i scontrols > /etc/amixer [ -n "$(grep Master /etc/amixer)" ] \ && amixer -c $i -q set Master 95% unmute \ >/dev/null 2>&1 [ -n "$(grep PCM /etc/amixer)" ] \ && amixer -c $i -q set PCM 95% unmute \ >/dev/null 2>&1 [ -n "$(grep Mic /etc/amixer)" ] \ && amixer -c $i -q set Mic 95% mute cap \ >/dev/null 2>&1 [ -n "$(grep Wave /etc/amixer)" ] \ && amixer -c $i -q set Wave 95% unmute \ >/dev/null 2>&1 [ -n "$(grep Capture /etc/amixer)" ] \ && amixer -c $i -q set Capture 95% unmute cap \ >/dev/null 2>&1 fi done fi fi else ewarn "Skipping ALSA detection as requested on command line ..." fi if [ "${DETECT}" = "yes" ] then [ -x /etc/init.d/x-setup ] && schedule_service_startup x-setup fi [ "${X11}" = "no" ] && touch /etc/init.d/.noxdm [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}" killall hwsetup 2>/dev/null echo "6" > /proc/sys/kernel/printk } # vim: ts=4