#!/sbin/runscript 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 mkxf86config 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)" svcs="${svcs} $(check_svc ${X11} mkxf86config x-setup)" echo ${svcs} } unpack_firmware() { # This unpacks any firmware tarballs. # This has been moved here from coldplug, but might not be very effective # since udev does coldplugging in 089 and higher. if [ -e /lib/firmware.tar.bz2 ] then ebegin "Unpacking hotplug firmware" tar xjf /lib/firmware.tar.bz2 -C /lib/firmware eend 0 fi } get_info() { local tmp if [ ! -z "${1}" -a ! -z "${2}" ] then tmp=$(grep "^$1[[:space:]]\+:" /proc/cpuinfo | head -n 1 | cut -d" " -f3-) # tmp=$([[ $'\n'$( /proc/sys/kernel/printk get_config # First off, we want hotplug/coldplug enabled, so let's re-enable it. # We do this even if we aren't startup up the hotplug/coldplug # services for the installer. sed -i 's/RC_COLDPLUG="no"/RC_COLDPLUG="yes"/' /etc/conf.d/rc # Now, we check if we're supposed to run a coldplug script. 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 else unpack_firmware [ -x /sbin/udevtrigger ] && /sbin/udevtrigger fi else ewarn "Hotplug/Coldplug disabled via cmdline ..." fi if [ "${DETECT}" = "yes" ] then ebegin "Hardware detection started" local numcpu="$(grep -c '^processor[[:space:]]\+:' /proc/cpuinfo)" # local numcpu=$([[ $'\n'$(/dev/null 2>&1 && \ einfo "APM BIOS found, power management functions enabled ..." [ -x /etc/init.d/apmd ] && start_service apmd else einfo "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 modprobe thermal >/dev/null 2>&1 modprobe video >/dev/null 2>&1 modprobe dock >/dev/null 2>&1 [ -x /etc/init.d/acpid ] && start_service acpid eend else einfo "Not Loading ACPI support ..." fi if [ "${IDEDMA}" = "yes" ] then [ -x /etc/init.d/hdparm ] && start_service hdparm 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 for i in `seq 0 4` do echo "config_eth$i=( \"none\" )" >> /etc/conf.d/net done ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..." fi # Read in what hwsetup has found [ -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 if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ] # if [ $([[ $'\n'$(>/etc/conf.d/gpm fi if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ] # if [ $([[ $'\n'$(>/etc/conf.d/gpm fi [ "${GPM}" = "yes" ] \ && [ -x /etc/init.d/gpm ] && start_service gpm fi 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 ..." if [ -f /var/run/dhcpcd-${nics}.pid ] then if [ -z "$(/sbin/ifconfig ${nics} | grep 'inet addr')" ] then kill $(cat /var/run/dhcpcd-${nics}.pid) sleep 2 dhcpcd -n -h $(hostname) ${nics} fi fi 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 | awk '{print $1}' | grep ^[[:digit:]]) 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 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}" if [ "${X11}" = "yes" ] then if [ -x /etc/init.d/mkxf86config ] then start_service mkxf86config fi if [ -x /etc/init.d/x-setup ] then start_service x-setup fi else touch /etc/init.d/.noxdm fi killall hwsetup 2>/dev/null echo "6" > /proc/sys/kernel/printk } # vim: ts=4