diff options
author | Benedikt Boehm <hollow@gentoo.org> | 2006-06-22 06:41:06 +0000 |
---|---|---|
committer | Benedikt Boehm <hollow@gentoo.org> | 2006-06-22 06:41:06 +0000 |
commit | c112f89a3e891e961d618935007c828acd6cc2ab (patch) | |
tree | 40ffbfed957757dc6c166cedcb0969f025d50d47 | |
parent | first part of baselayout cleanup (diff) | |
download | baselayout-vserver-c112f89a3e891e961d618935007c828acd6cc2ab.tar.gz baselayout-vserver-c112f89a3e891e961d618935007c828acd6cc2ab.tar.bz2 baselayout-vserver-c112f89a3e891e961d618935007c828acd6cc2ab.zip |
second part of baselayout cleanup
svn path=/baselayout-vserver/branches/baselayout-1_12/; revision=385
-rwxr-xr-x | bin/rc-status | 4 | ||||
-rw-r--r-- | etc/conf.d/domainname | 20 | ||||
-rw-r--r-- | etc/conf.d/rc | 6 | ||||
-rwxr-xr-x | init.d/checkfs | 50 | ||||
-rwxr-xr-x | init.d/checkroot | 51 | ||||
-rwxr-xr-x | init.d/clock | 138 | ||||
-rwxr-xr-x | init.d/consolefont | 68 | ||||
-rwxr-xr-x | init.d/domainname | 63 | ||||
-rwxr-xr-x | init.d/keymaps | 79 | ||||
-rwxr-xr-x | init.d/localmount | 59 | ||||
-rwxr-xr-x | init.d/modules | 124 | ||||
-rwxr-xr-x | init.d/netmount | 110 | ||||
-rwxr-xr-x | init.d/numlock | 34 | ||||
-rwxr-xr-x | init.d/urandom | 37 |
14 files changed, 759 insertions, 84 deletions
diff --git a/bin/rc-status b/bin/rc-status index 64b7807..b5065c8 100755 --- a/bin/rc-status +++ b/bin/rc-status @@ -90,7 +90,9 @@ if [[ -z ${runlevel} ]] ; then runlevel=$(<${svcdir}/softlevel) else ewarn "Could not locate current runlevel in ${svcdir}/softlevel" - if [[ -d ${runleveldir}/default ]] ; then + if [[ -d ${runleveldir}/single ]] ; then + runlevel=single + elif [[ -d ${runleveldir}/default ]] ; then runlevel=default else eerror "Your installation is probably broken ... please \`emerge baselayout-vserver\`" diff --git a/etc/conf.d/domainname b/etc/conf.d/domainname deleted file mode 100644 index 3a32173..0000000 --- a/etc/conf.d/domainname +++ /dev/null @@ -1,20 +0,0 @@ -# /etc/conf.d/domainname - -# When setting up resolv.conf, what should take precedence? -# 0 = let dhcp/whatever override DNSDOMAIN -# 1 = override dhcp/whatever with DNSDOMAIN - -OVERRIDE=1 - -# To have a proper FQDN, you need to setup /etc/hosts and /etc/resolv.conf -# (domain entry in /etc/resolv.conf and FQDN in /etc/hosts). -# -# DNSDOMAIN merely sets the domain entry in /etc/resolv.conf, see -# the resolv.conf(5) manpage for more info. - -DNSDOMAIN="" - -# For information on setting up NIS, please see: -# http://www.linux-nis.org/nis-howto/HOWTO/ - -NISDOMAIN="" diff --git a/etc/conf.d/rc b/etc/conf.d/rc index 217562d..1f65fd4 100644 --- a/etc/conf.d/rc +++ b/etc/conf.d/rc @@ -69,6 +69,12 @@ RC_VERBOSE="no" RC_BOOTLOG="no" +# RC_USE_FSTAB allows you to override the default mount options for the +# standard /proc, /sys, /dev, and /dev/pts mount points. Note that this +# is the new way for selecting ramfs/tmpfs/etc... for udev mounting. + +RC_USE_FSTAB="no" + # RC_USE_CONFIG_PROFILE allows you to have different /etc/conf.d files # based on your runlevel - if a conf.d file for your profile does not exist # then we try and use the default one. diff --git a/init.d/checkfs b/init.d/checkfs new file mode 100755 index 0000000..b5b442c --- /dev/null +++ b/init.d/checkfs @@ -0,0 +1,50 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need checkroot modules +} + +start() { + local retval=0 + + # Setup dm-crypt mappings if any + start_addon dm-crypt + + if [[ -f /fastboot ]] || [[ -n ${CDBOOT} ]] || is_vps_sys ; then + rm -f /fastboot + else + ebegin "Checking all filesystems" + if [[ -f /forcefsck ]] ; then + ewarn "A full fsck has been forced" + fsck -C -T -R -A -a -f + retval=$? + rm -f /forcefsck + else + fsck -C -T -R -A -a + retval=$? + fi + if [[ ${retval} -eq 0 ]] ; then + eend 0 + elif [[ ${retval} -ge 1 && ${retval} -le 3 ]] ; then + ewend 1 "Filesystem errors corrected." + # Everything should be ok, so return a pass + return 0 + else + if [[ ${RC_FORCE_AUTO} == "yes" ]] ; then + eend 2 "Fsck could not correct all errors, rerunning" + fsck -C -T -R -A -y + retval=$? + fi + + if [[ ${retval} -gt 3 ]] ; then + eend 2 "Fsck could not correct all errors, manual repair needed" + /sbin/sulogin ${CONSOLE} + fi + fi + fi +} + + +# vim:ts=4 diff --git a/init.d/checkroot b/init.d/checkroot new file mode 100755 index 0000000..9a38b56 --- /dev/null +++ b/init.d/checkroot @@ -0,0 +1,51 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + before * +} + +start() { + local retval=0 + + if [[ ${BOOT} == "yes" ]] ; then + local x= + local y= + + # + # Create /etc/mtab + # + + # Don't create mtab if /etc is readonly + if ! touch /etc/mtab 2> /dev/null ; then + ewarn "Skipping /etc/mtab initialization (ro root?)" + return 0 + fi + + # Clear the existing mtab + > /etc/mtab + + # Add the entry for / to mtab + mount -f / + + # Don't list root more than once + awk '$2 != "/" {print}' /proc/mounts >> /etc/mtab + + # Now make sure /etc/mtab have additional info (gid, etc) in there + for x in $(awk '{ print $2 }' /proc/mounts | sort -u) ; do + for y in $(awk '{ print $2 }' /etc/fstab) ; do + if [[ ${x} == ${y} ]] ; then + mount -f -o remount $x + continue + fi + done + done + + # Remove stale backups + rm -f /etc/mtab~ /etc/mtab~~ + fi +} + + +# vim:ts=4 diff --git a/init.d/clock b/init.d/clock new file mode 100755 index 0000000..9478200 --- /dev/null +++ b/init.d/clock @@ -0,0 +1,138 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +opts="save" + +depend() { + need localmount +} + +setupopts() { + if is_uml_sys ; then + TBLURB="UML" + fakeit=1 + elif is_vps_sys ; then + TBLURB="VPS" + fakeit=1 + elif is_xenU_sys ; then + TBLURB="xen" + fakeit=1 + elif grep -q ' cobd$' /proc/devices ; then + TBLURB="coLinux" + fakeit=1 + elif [[ $(uname -m) == s390* ]] ; then + TBLURB="s390" + fakeit=1 + elif [[ ${CLOCK} == "UTC" ]] ; then + myopts="--utc" + TBLURB="UTC" + else + myopts="--localtime" + TBLURB="Local Time" + fi + [[ ${fakeit} -eq 1 ]] && return 0 + + if [[ ${readonly} == "yes" ]] ; then + myadj="--noadjfile" + else + myadj="--adjust" + fi + + if [[ ${SRM} == "yes" ]] ; then + myopts="${myopts} --srm" + fi + if [[ ${ARC} == "arc" ]] ; then + myopts="${myopts} --arc" + fi + myopts="${myopts} ${CLOCK_OPTS}" + + # Make sure user isn't using rc.conf anymore. + if grep -qs ^CLOCK= /etc/rc.conf ; then + ewarn "CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock" + fi +} + +start() { + local myopts="" + local myadj="" + local TBLURB="" fakeit=0 + local errstr="" + local readonly="no" + local ret=0 + + if ! touch /etc/adjtime 2>/dev/null ; then + readonly="yes" + elif [[ ! -s /etc/adjtime ]] ; then + echo "0.0 0 0.0" > /etc/adjtime + fi + + setupopts + + if [[ ${fakeit} -ne 1 && -e /proc/modules && ! -e /dev/rtc ]] ; then + modprobe rtc &> /dev/null + fi + + ebegin "Setting system clock using the hardware clock [${TBLURB}]" + if [[ ${fakeit} -eq 1 ]] ; then + ret=0 + + elif [[ -x /sbin/hwclock ]] ; then + # Since hwclock always exit's with a 0, need to check its output. + errstr=$(/sbin/hwclock ${myadj} ${myopts} 2>&1 >/dev/null) + errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)" + + if [[ -n ${errstr} ]] ; then + ewarn "${errstr}" + ret=1 + else + ret=0 + fi + errstr="Failed to set system clock to hardware clock" + else + ret=1 + errstr="/sbin/hwclock not found" + fi + eend ${ret} "${errstr}" +} + +stop() { + # Don't tweak the hardware clock on LiveCD halt. + [[ -n ${CDBOOT} ]] && return 0 + + [[ ${CLOCK_SYSTOHC} != "yes" ]] && return 0 + + local myopts="" + local TBLURB="" + local errstr="" + local ret=0 + + setupopts + + ebegin "Setting hardware clock using the system clock [${TBLURB}]" + if [[ ${fakeit} -eq 1 ]] ; then + ret=0 + + elif [[ -x /sbin/hwclock ]] ; then + errstr=$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null) + + if [[ -n ${errstr} ]] ; then + ret=1 + else + ret=0 + fi + errstr="Failed to sync clocks" + else + ret=1 + errstr="/sbin/hwclock not found" + fi + eend ${ret} "${errstr}" +} + +save() { + CLOCK_SYSTOHC="yes" + stop +} + + +# vim:ts=4 diff --git a/init.d/consolefont b/init.d/consolefont new file mode 100755 index 0000000..2fc846e --- /dev/null +++ b/init.d/consolefont @@ -0,0 +1,68 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need localmount + need keymaps # sets up terminal encoding scheme + after hotplug +} + +start() { + if is_uml_sys || is_xenU_sys || is_vps_sys ; then + ebegin "Setting user font" + eend 0 + return 0 + elif [[ -z ${CONSOLEFONT} ]] ; then + ebegin "Using the default console font" + eend 0 + return 0 + fi + + local x= + local param= + local sf_param= + local retval=1 + + # Get additional parameters + if [[ -n ${CONSOLETRANSLATION} ]] ; then + param="-m ${CONSOLETRANSLATION}" + fi + + # Set the console font + local errmsg="" + ebegin "Setting user font" + if [[ -x /bin/setfont ]] ; then + # We patched setfont to have --tty support ... + if [[ -n $(setfont --help 2>&1 | grep -e '--tty') || \ + -n $(setfont --help 2>&1 | grep -e '-C') ]] + then + if [[ -n $(setfont --help 2>&1 | grep -e '--tty') ]] ; then + sf_param="--tty=" + else + sf_param="-C " + fi + local ttydev= + [[ -d /dev/vc ]] \ + && ttydev=/dev/vc/ \ + || ttydev=/dev/tty + + for x in $(seq 1 "${RC_TTY_NUMBER}") ; do + /bin/setfont ${CONSOLEFONT} ${param} \ + ${sf_param}/${ttydev}${x} > /dev/null + retval=$? + done + else + /bin/setfont ${CONSOLEFONT} ${param} > /dev/null + retval=$? + fi + errmsg="Failed to set user font" + else + retval=1 + errmsg="/bin/setfont not found" + fi + eend ${retval} "${errmsg}" +} + + +# vim:ts=4 diff --git a/init.d/domainname b/init.d/domainname deleted file mode 100755 index 3dbc81c..0000000 --- a/init.d/domainname +++ /dev/null @@ -1,63 +0,0 @@ -#!/sbin/runscript -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -depend() { - need hostname - before bootmisc -} - -checkconfig_nis() { - if [[ -f /etc/nisdomainname ]] ; then - ewarn "You should stop using /etc/nisdomainname and use /etc/conf.d/domainname" - export NISDOMAIN=$(</etc/nisdomainname) - return 0 - fi - [[ -n ${NISDOMAIN} ]] -} - -checkconfig_dns() { - if [[ -f /etc/dnsdomainname ]] ; then - ewarn "You should stop using /etc/dnsdomainname and use /etc/conf.d/domainname" - export DNSDOMAIN=$(</etc/dnsdomainname) - fi - [[ -z ${DNSDOMAIN} ]] && return 1 - - if ! touch /etc/resolv.conf 2> /dev/null ; then - ewarn "Unable to set domain in resolv.conf (ro root?)" - return 1 - else - return 0 - fi -} - -start() { - # Ensure that we have a hostname binary or function - source /lib/rcscripts/net.modules.d/helpers.d/functions - - local retval=0 - local retval2=0 - - if checkconfig_nis ; then - ebegin "Setting NIS domainname to ${NISDOMAIN}" - hostname -y "${NISDOMAIN}" - retval=$? - eend ${retval} "Failed to set the NIS domainname" - fi - - if checkconfig_dns ; then - ebegin "Setting DNS domainname to ${DNSDOMAIN}" - resolv=$(grep -v '^[[:space:]]*domain' /etc/resolv.conf) - [[ ${OVERRIDE} == "1" ]] \ - && resolv="${resolv}"$'\n'"domain ${DNSDOMAIN}" \ - || resolv="domain ${DNSDOMAIN}"$'\n'"${resolv}" - echo "${resolv}" > /etc/resolv.conf - retval2=$? - eend ${retval2} "Failed to set the DNS domainname" - fi - - return $((retval + retval2)) -} - - -# vim:ts=4 diff --git a/init.d/keymaps b/init.d/keymaps new file mode 100755 index 0000000..e6cde27 --- /dev/null +++ b/init.d/keymaps @@ -0,0 +1,79 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need localmount +} + +checkconfig() { + if [[ -z ${KEYMAP} ]] ; then + eerror "You need to setup KEYMAP in /etc/conf.d/keymaps first" + return 1 + fi + + # Make sure user isn't using rc.conf anymore + if grep -qs ^KEYMAP= /etc/rc.conf ; then + ewarn "KEYMAP should not be set in /etc/rc.conf but in /etc/conf.d/keymaps" + fi +} + +start() { + if is_uml_sys || is_xenU_sys || is_vps_sys ; then + ebegin "Loading key mappings" + eend 0 + return 0 + fi + + local WINDOWKEYS_KEYMAP= + + checkconfig || return 1 + + # Force linux keycodes for PPC. + if [[ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]] ; then + echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes + fi + + # Turn on unicode if user wants it + if [[ ${UNICODE} == "yes" ]] ; then + /usr/bin/kbd_mode -u + fi + + ebegin "Loading key mappings" + if [[ -x /bin/loadkeys ]] ; then + [[ ${SET_WINDOWKEYS} == "yes" ]] && WINDOWKEYS_KEYMAP="windowkeys" + /bin/loadkeys -q ${WINDOWKEYS_KEYMAP} ${KEYMAP} \ + ${EXTENDED_KEYMAPS} > /dev/null + eend $? "Error loading key mappings" + else + eend 1 "/bin/loadkeys not found" + return 1 + fi + + # Set terminal encoding to either ASCII or UNICODE. + # See utf-8(7) for more information. + local termencoding="" termmsg="" + if [[ ${UNICODE} == "yes" ]] ; then + local dumpkey_opts="" + [[ -n ${DUMPKEYS_CHARSET} ]] && dumpkey_opts="-c ${DUMPKEYS_CHARSET}" + + dumpkeys ${dumpkey_opts} | loadkeys --unicode + termencoding=$'\033%G' + termmsg="UTF-8" + else + termencoding=$'\033(K' + termmsg="ASCII" + fi + local n ttydev="" + [[ -d /dev/vc ]] \ + && ttydev=/dev/vc/ \ + || ttydev=/dev/tty + ebegin "Setting terminal encoding to ${termmsg}" + for n in $(seq 1 "${RC_TTY_NUMBER}") ; do + echo -n -e ${termencoding} > ${ttydev}${n} + done + eend 0 +} + + +# vim:ts=4 diff --git a/init.d/localmount b/init.d/localmount new file mode 100755 index 0000000..bbd93bb --- /dev/null +++ b/init.d/localmount @@ -0,0 +1,59 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need checkfs +} + +start() { + is_vps_sys && return 0 + + # Mount local filesystems in /etc/fstab. + ebegin "Mounting local filesystems" + mount -at noproc,noshm${NET_FS_LIST:+,no}${NET_FS_LIST// /,no} \ + -O no_netdev >/dev/null + eend $? "Some local filesystem failed to mount" + + # Make sure we insert usbcore if its a module + if [[ -f /proc/modules && ! -d /proc/bus/usb ]] ; then + # >/dev/null to hide errors from non-USB users + modprobe usbcore &> /dev/null + fi + + # Check what USB fs the kernel support. Currently + # 2.5+ kernels, and later 2.4 kernels have 'usbfs', + # while older kernels have 'usbdevfs'. + local usbfs=$(grep -Fow usbfs /proc/filesystems || + grep -Fow usbdevfs /proc/filesystems) + + if [[ -n ${usbfs} ]] && \ + [[ -e /proc/bus/usb && ! -e /proc/bus/usb/devices ]] + then + ebegin "Mounting USB device filesystem (${usbfs})" + usbgid=$(echo $(getent group usb) | awk -F: '{print $3}') + mount -t ${usbfs} usbfs /proc/bus/usb \ + -o ${usbgid:+devmode=0664,devgid=${usbgid},}noexec,nosuid + eend $? "Failed to mount USB device filesystem" + fi + + # Setup Kernel Support for miscellaneous Binary Formats + local binfmt=$(grep -Fow binfmt_misc /proc/filesystems) + if [[ -n ${binfmt} ]] && [[ -e /proc/sys/fs/binfmt_misc ]] ; then + ebegin $"Mounting misc binary format filesystem" + mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc \ + -o nodev,noexec,nosuid + eend $? + fi + + # We do our swapping here instead of rc so we can get urandom started + # before us for people that like an encrypted swap. + ebegin "Activating (possible) swap" + /sbin/swapon -a + eend $? + + # Start dm-crypt mappings, if any + start_addon dm-crypt +} + +# vim:ts=4 diff --git a/init.d/modules b/init.d/modules new file mode 100755 index 0000000..59cfa5e --- /dev/null +++ b/init.d/modules @@ -0,0 +1,124 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need checkroot + use isapnp +} + +load_modules() { + local x= + local i=0 + local retval=0 + local modules= + local modargs= + local modcount=0 + local config="$1" + + [[ -z ${config} || ! -r ${config} ]] && return 0 + + # Loop over every line in $config + eval $(awk ' + BEGIN { + COUNT = 0 # Make sure COUNT is set + } + + $0 !~ /(^[[:space:]]*(#|$))/ { + if (MODULES == "") + MODULES = $1 + else + MODULES = MODULES " " $1 + + # Not the greatest method to remove $1 from $0, but it works + sub(/^[[:space:]]*[^[:space:]]*[[:space:]]*/, "") + # Trim trailing comments on the line + sub(/#.*$/, "") + ARGS[COUNT] = $0 + COUNT++ + } + + END { + # 'eval' will make sure these are set to proper bash variables + print "modcount=" COUNT + print "modules=\"" MODULES "\"" + for (x = 0;x < COUNT;x++) + print "modargs[" x "]=\"" ARGS[x] "\"" + } + ' "${config}") + + if [[ ${modcount} -gt 0 ]]; then + einfo "Using ${config} as config:" + + for x in ${modules}; do + ebegin " Loading module ${x}" + modprobe -q ${x} ${modargs[${i}]} &>/dev/null + retval=$? + eend ${retval} " Failed to load ${x}" + + i=$((i+1)) + [[ ${retval} -eq 0 ]] || modcount=$((modcount-1)) + done + + einfo "Autoloaded ${modcount} module(s)" + fi + + return 0 +} + +start() { + local KV=$(uname -r) + local KV_MAJOR=$(KV_major "${KV}") + local KV_MINOR=$(KV_minor "${KV}") + local KV_MICRO=$(KV_micro "${KV}") + + is_vps_sys && return 0 + + # Should not fail if kernel do not have module + # support compiled in ... + [[ -f /proc/modules ]] || return 0 + + # Make sure depmod from modutils do not whine, but do not bother if + # we are on a 2.6 kernel without modprobe.old + if [[ -z "${CDBOOT}" ]] && [[ ! -e /etc/modules.conf ]] && \ + [[ $(get_KV) -lt $(KV_to_int '2.5.48') || -x /sbin/modprobe.old ]] + then + echo '### This file is automatically generated by modules-update' \ + > /etc/modules.conf 2>/dev/null + [[ ! -f /etc/modules.conf ]] && \ + ewarn "Cannot update /etc/modules.conf!" + fi + + # Only do this if we have modules.conf or a 2.6 kernel + if [[ -z "${CDBOOT}" ]] && \ + [[ -f /etc/modules.conf || $(get_KV) -ge $(KV_to_int '2.5.48') ]] + then + /sbin/modules-update + fi + + local autoload="" + if [[ -f /etc/modules.autoload && ! -L /etc/modules.autoload ]]; then + autoload=/etc/modules.autoload + else + local x + for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR} ; do + if [[ -f /etc/modules.autoload.d/kernel-"${x}" ]] ; then + autoload="/etc/modules.autoload.d/kernel-${x}" + break + fi + done + fi + [[ -n ${autoload} ]] && load_modules "${autoload}" + + # + # Just in case a sysadmin prefers generic symbolic links in + # /lib/modules/boot for boot time modules we will load these modules + # + [[ -n $(modprobe -l -t boot) ]] && modprobe -a -t boot \* &>/dev/null + + # Above test clobbers the return + return 0 +} + + +# vim:ts=4 diff --git a/init.d/netmount b/init.d/netmount new file mode 100755 index 0000000..1f98bd3 --- /dev/null +++ b/init.d/netmount @@ -0,0 +1,110 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + local myneed="net" + local myuse="" + + # Only have Portmap as a dependency if there is a nfs mount in fstab + # that should be mounted at boot time. Also filter out comments. + local nfsmounts=$(awk '!/^#/ && ($3=="nfs" || $3=="nfs4") && $4 !~ /noauto/ { print $0 }' /etc/fstab) + + if [[ -n ${nfsmounts} ]] ; then + myneed="${myneed} portmap" + myuse="${myuse} nfs nfsmount" + else + myuse="${myuse} portmap" + fi + + need ${myneed} + use ${myuse} +} + +remove_net_fs() { + local fs + rcfilesystems=" ${rcfilesystems} " + for fs in "$@" ; do + rcfilesystems=${rcfilesystems// ${fs} / } + done + rcfilesystems=${rcfilesystems# } # remove front and + rcfilesystems=${rcfilesystems% } # back spaces +} + +start() { + local rcfilesystems=${NET_FS_LIST} + + is_vps_sys && return 0 + + # Only try to mount NFS filesystems if portmap was started. + # This is to fix "hang" problems for new users who do not + # add portmap to the default runlevel. + if ! service_started portmap ; then + remove_net_fs nfs nfs4 + fi + rcfilesystems=${rcfilesystems// /,} # convert to comma-separated + + ebegin "Mounting network filesystems" + mount -at ${rcfilesystems} >/dev/null + + if [[ $? != 0 ]] ; then + ewend 1 "Could not mount all network filesystems!" + else + eend 0 + fi + + return 0 +} + +stop() { + local rcfilesystems=${NET_FS_LIST} + + is_vps_sys && return 0 + + # We let the afs init script handle unmounting afs stuff + # because it requires special handling of the afs daemon + # and similar ugly cruft + if service_started afs-client ; then + remove_net_fs afs + fi + + rcfilesystems=${rcfilesystems// /,} # convert to comma-separated + + local ret + ebegin "Unmounting network filesystems" + [[ -z $(umount -art ${rcfilesystems} 2>&1) ]] + ret=$? + eend ${ret} "Failed to simply unmount filesystems" + [[ ${ret} == 0 ]] && return 0 + + # `umount -a` will fail if the filesystems are in use. + # Here we use fuser to kill off processes that are using + # the filesystems so that we can unmount properly. + # We will gradually use harsher kill signals so that the + # processes know we aren't screwing around here ;). + declare -a siglist=( "TERM" "KILL" "KILL" ) + local retry=0 + local remaining="go" + + while [[ -n ${remaining} && ${retry} -lt 3 ]] ; do + # Populate $remaining with a newline-delimited list of network + # filesystems. Mount points have spaces swapped for '\040' (see + # fstab(5)) so we have to translate them back to spaces. + remaining="$(awk '$3 ~ /'${NET_FS_LIST// /|}'/ { if ($2 != "/") print $2 }' /proc/mounts | sort -r)" + # Since we have to worry about the spaces being quoted properly, + # we'll use `set --` and then "$@" to get the correct result. + IFS=$'\n' + set -- ${remaining//\\040/ } + unset IFS + [[ -z ${remaining} ]] && break + + # try to unmount again + ebegin $'\t'"Unmounting network filesystems (retry #$((retry+1)))" + /bin/fuser -s -k -${siglist[$((retry++))]} -m "$@" + sleep 5 + umount "$@" &>/dev/null + eend $? $'\t'"Failed to unmount filesystems" + done +} + +# vim:ts=4 diff --git a/init.d/numlock b/init.d/numlock new file mode 100755 index 0000000..71922e8 --- /dev/null +++ b/init.d/numlock @@ -0,0 +1,34 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need localmount +} + +start() { + ebegin "Enabling numlock on ttys" + local dev + [[ -d /dev/vc ]] \ + && dev=/dev/vc/ \ + || dev=/dev/tty + for tty in $(seq 1 "${RC_TTY_NUMBER}") ; do + setleds -D +num < ${dev}${tty} &> /dev/null + done + eend $? "Failed to enable numlock" +} + +stop() { + ebegin "Disabling numlock on ttys" + local dev + [[ -d /dev/vc ]] \ + && dev=/dev/vc/ \ + || dev=/dev/tty + for tty in $(seq 1 "${RC_TTY_NUMBER}") ; do + setleds -D -num < ${dev}${tty} &> /dev/null + done + eend $? "Failed to disable numlock" +} + + +# vim:ts=4 diff --git a/init.d/urandom b/init.d/urandom new file mode 100755 index 0000000..65f06ca --- /dev/null +++ b/init.d/urandom @@ -0,0 +1,37 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need localmount +} + +start() { + [[ -c /dev/urandom ]] || return + if [[ -f /var/run/random-seed ]] ; then + cat /var/run/random-seed > /dev/urandom + fi + if ! rm -f /var/run/random-seed &> /dev/null ; then + ewarn "Skipping /var/run/random-seed initialization (ro root?)" + return 0 + fi + ebegin "Initializing random number generator" + umask 077 + dd if=/dev/urandom of=/var/run/random-seed count=1 &> /dev/null + eend $? "Error initializing random number generator" + umask 022 +} + +stop() { + [[ -n ${CDBOOT} ]] && return 0 + + ebegin "Saving random seed" + # Carry a random seed from shut-down to start-up; + # see documentation in linux/drivers/char/random.c + umask 077 + dd if=/dev/urandom of=/var/run/random-seed count=1 &> /dev/null + eend $? "Failed to save random seed" +} + + +# vim:ts=4 |