diff options
Diffstat (limited to 'init.d')
-rw-r--r-- | init.d/Makefile | 6 | ||||
-rwxr-xr-x | init.d/bootmisc | 138 | ||||
-rwxr-xr-x | init.d/checkfs | 77 | ||||
-rwxr-xr-x | init.d/checkroot | 149 | ||||
-rwxr-xr-x | init.d/halt.sh | 94 | ||||
-rwxr-xr-x | init.d/hostname | 20 | ||||
-rwxr-xr-x | init.d/local | 34 | ||||
-rwxr-xr-x | init.d/localmount | 183 | ||||
-rwxr-xr-x | init.d/netmount | 85 | ||||
-rwxr-xr-x | init.d/rmnologin | 16 | ||||
-rwxr-xr-x | init.d/urandom | 34 |
11 files changed, 836 insertions, 0 deletions
diff --git a/init.d/Makefile b/init.d/Makefile new file mode 100644 index 00000000..c86468ac --- /dev/null +++ b/init.d/Makefile @@ -0,0 +1,6 @@ +DIR = /etc/init.d +EXES = bootmisc checkfs checkroot hostname local localmount \ + netmount rmnologin urandom halt.sh + +TOPDIR = .. +include $(TOPDIR)/default.mk diff --git a/init.d/bootmisc b/init.d/bootmisc new file mode 100755 index 00000000..1428e874 --- /dev/null +++ b/init.d/bootmisc @@ -0,0 +1,138 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + use hostname + need localmount + before logger + after clock sysctl +} + +start() { + # Put a nologin file in /etc to prevent people from logging + # in before system startup is complete. + if [ "${DELAYLOGIN}" = "yes" ] ; then + echo "System bootup in progress - please wait" \ + > /etc/nologin + cp /etc/nologin /etc/nologin.boot + fi + + if ! touch -c /var/run 2> /dev/null ; then + ewarn "Skipping /var and /tmp initialization (ro root?)" + return 0 + fi + + if [ "${RC_UNAME}" = "Linux" ] ; then + # Setup login records + > /var/run/utmp + touch /var/log/wtmp + chgrp utmp /var/run/utmp /var/log/wtmp + chmod 0664 /var/run/utmp /var/log/wtmp + fi + + ebegin "Updating environment" + /sbin/env-update + eend $? + + # Take care of random stuff [ /var/lock | /var/run | pam ] + ebegin "Cleaning" /var/lock, /var/run + rm -rf /var/run/console.lock /var/run/console/* + + # Clean up any stale locks. + find /var/lock -type f -print0 | xargs -0 rm -f -- + + # Clean up /var/run and create /var/run/utmp so we can login. + for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid ! -name random-seed ! -name ld-elf.so.hints); do + [ ! -f "${x}" ] && continue + # Do not remove pidfiles of already running daemons + case "${x}" in + *.pid) + start-stop-daemon --test --quiet --stop --pidfile "${x}" + [ $? -eq 0 ] && continue + ;; + esac + rm -f "${x}" + done + + # Reset pam_console permissions if we are actually using it + if [ -x /sbin/pam_console_apply -a ! -c /dev/.devfsd ] ; then + if [ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ] ; then + /sbin/pam_console_apply -r + fi + fi + + # Create the .keep to stop portage from removing /var/lock + > /var/lock/.keep + eend 0 + + # Clean up /tmp directory + if [ -d /tmp ] ; then + cd /tmp + if [ "${WIPE_TMP}" = "yes" ] ; then + ebegin "Wiping /tmp directory" + local startopts="-x . -depth" + [ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth" + + # Faster than find + rm -rf [b-ikm-pr-zA-Z]* + + find ${startopts} ! -name . \ + ! -path ./lost+found \ + ! -path "./lost+found/*" \ + ! -path ./quota.user \ + ! -path "./quota.user/*" \ + ! -path ./aquota.user \ + ! -path "./aquota.user/*" \ + ! -path ./quota.group \ + ! -path "./quota.group/*" \ + ! -path ./aquota.group \ + ! -path "./aquota.group/*" \ + ! -path ./journal \ + ! -path "./journal/*" \ + -delete + eend 0 + else + ebegin "Cleaning /tmp directory" + rm -rf /tmp/.X*-lock /tmp/esrv* /tmp/kio* /tmp/jpsock.* \ + /tmp/.fam* /tmp/.esd* /tmp/orbit-* /tmp/ssh-* \ + /tmp/ksocket-* /tmp/.*-unix + eend 0 + fi + + # Make sure our X11 stuff have the correct permissions + # Omit the chown as bootmisc is run before network is up + # and users may be using lame LDAP auth #139411 + rm -rf /tmp/.ICE-unix /tmp/.X11-unix + mkdir -p /tmp/.ICE-unix /tmp/.X11-unix + chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix + [ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix + fi + + # Create an 'after-boot' dmesg log + touch /var/log/dmesg + chmod 640 /var/log/dmesg + dmesg > /var/log/dmesg + + # Check for /etc/resolv.conf, and create if missing + [ -f /etc/resolv.conf ] || touch /etc/resolv.conf 2>/dev/null +} + +stop() { + # Reset pam_console permissions if we are actually using it + if [ -x /sbin/pam_console_apply -a ! -c /dev/.devfsd ] && \ + [ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ] ; then + /sbin/pam_console_apply -r + fi + + # Write a halt record if we're shutting down + case "${SOFTLEVEL}" in + reboot|shutdown) + [ "${RC_UNAME}" = "Linux" ] && halt -w + ;; + esac + + return 0 +} + +# vim: set ts=4 : diff --git a/init.d/checkfs b/init.d/checkfs new file mode 100755 index 00000000..2f9ead02 --- /dev/null +++ b/init.d/checkfs @@ -0,0 +1,77 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need checkroot + use volumes + after modules +} + +do_checkfs() { + local retval=0 + + ebegin "Checking all filesystems" + if [ "${RC_UNAME}" = "Linux" ] ; then + if get_bootparam "forcefsck" ; then + ewarn "A full fsck has been forced" + fsck -C0 -T -R -A -a -f + else + fsck -C0 -T -R -A -a + fi + retval=$? + else + local parts="$(fstabinfo --passno ">1")" + if [ -n "${parts}" ] ; then + fsck -p ${parts} + retval=$? + fi + fi + if [ ${retval} -eq 0 ] ; then + eend 0 + elif [ ${retval} -eq 1 ] ; then + ewend 1 "Filesystem errors corrected." + retval=0 + elif [ ${retval} -eq 2 ] ; then + ewend 1 "System should be rebooted" + elif [ ${retval} -eq 8 ] ; then + ewend 1 "Operational error, continuing" + retval=0 + else + if [ "${RC_FORCE_AUTO}" = "yes" ] ; then + eend 2 "Fsck could not correct all errors, rerunning" + if [ "${RC_UNAME}" = "Linux" ] ; then + fsck -C0 -T -R -A -y + else + fsck -y + fi + retval=$? + eend $? + fi + + if [ ${retval} -gt 3 ] ; then + eend 2 "Fsck could not correct all errors, manual repair needed" + if [ "${RC_SYS}" = "VPS" ] ; then + halt -f + elif [ -x /sbin/sulogin ] ; then + sulogin "${CONSOLE}" + else + return 1 + fi + fi + fi + + return ${retval} +} + +start() { + do_checkfs +} + +stop() { + # fsck on shutdown if we need to + [ "${FSCK_SHUTDOWN}" = "yes" -a ! -f /forcefsck ] && do_checkfs + return 0 +} + +# vim: set ts=4 : diff --git a/init.d/checkroot b/init.d/checkroot new file mode 100755 index 00000000..c7fb66d3 --- /dev/null +++ b/init.d/checkroot @@ -0,0 +1,149 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +do_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 + grep -v "^[^ ]* / " /proc/mounts >> /etc/mtab + + # Now make sure /etc/mtab have additional info (gid, etc) in there + local mnt= mnts="$(mountinfo | sed -e "s/^/'/g" -e "s/$/'/g")" + eval set -- ${mnts} + for mnt in "$@" ; do + if fstabinfo --mount-cmd "${mnt}" >/dev/null ; then + mount -f -o remount "${mnt}" + fi + done + + # Remove stale backups + rm -f /etc/mtab~ /etc/mtab~~ +} + +start() { + local retval=0 + + # Don't bother doing a fsck on these + if [ -n "${CDBOOT}" ] || is_net_fs / || is_union_fs / ; then + return 0 + fi + + if touch /.test.$$ 2> /dev/null ; then + einfo "root filesystem is mounted read-write - skipping" + rm -f /.test.$$ + return 0 + fi + + if get_bootparam "forcefsck" ; then + ebegin "Checking root filesystem (full fsck forced)" + if [ "${RC_UNAME}" = "Linux" ] ; then + fsck -C -a -f / + else + fsck -F / + fi + # /forcefsck isn't deleted because checkfs needs it. + # it'll be deleted in that script. + retval=$? + else + # Obey the fs_passno setting for / (see fstab(5)) + # - find the / entry + # - make sure we have 6 fields + # - see if fs_passno is something other than 0 + local pass=$(fstabinfo --passno /) + if [ ${pass:-0} != "0" ] ; then + ebegin "Checking root filesystem" + if [ "${RC_UNAME}" = "Linux" ] ; then + fsck -C -T -a / + else + fsck -p -F / + fi + retval=$? + else + ebegin "Skipping root filesystem check" "(fstab's passno == 0)" + retval=0 + fi + fi + + if [ ${retval} -eq 0 ] ; then + eend 0 + elif [ ${retval} -eq 1 ] ; then + ewend 1 "Filesystem repaired" + retval=0 + elif [ ${retval} -eq 8 ] ; then + ewend 1 $"Operational error, continuing" + retval=0 + elif [ ${retval} -eq 2 -o ${retval} -eq 3 ] ; then + ewend 1 "Filesystem repaired, but reboot needed!" + if [ "${RC_FORCE_AUTO}" != "yes" ] ; then + printf "\a"; sleep 1; printf "\a"; sleep 1 + printf "\a"; sleep 1; printf "\a"; sleep 1 + ewarn "Rebooting in 10 seconds ..." + sleep 10 + fi + einfo "Rebooting" + /sbin/reboot -f + else + if [ "${RC_FORCE_AUTO}" = "yes" ] ; then + eend 2 "Rerunning fsck in force mode" + if [ "${RC_UNAME}" = "Linux" ] ; then + fsck -y -C -T / + else + fsck -y / + fi + retval=$? + else + eend 2 "Filesystem couldn't be fixed :(" + [ "${RC_UNAME}" = "Linux" ] || return 1 + sulogin "${CONSOLE}" + fi + if [ ${retval} != "0" ] ; then + einfo "Unmounting filesystems" + if [ "${RC_UNAME}" = "Linux" ] ; then + mount -a -o remount,ro / + else + mount -u -o ro / + fi + einfo "Rebooting" + reboot -f + fi + fi + + ebegin "Remounting root filesystem read/write" + if [ "${RC_UNAME}" = "Linux" ] ; then + mount -n -o remount,rw / + else + mount -u -o rw / + fi + eend $? "Root filesystem could not be mounted read/write :(" || return 1 + + # Only Linux has mtab + [ "${RC_UNAME}" = "Linux" ] && do_mtab + + # If the user's /dev/null or /dev/console are missing, we + # should help them out and explain how to rectify the situation + if [ ! -c /dev/null -o ! -c /dev/console ] ; then + if [ -e /usr/share/baselayout/issue.devfix ] ; then + # Backup current /etc/issue + if [ -e /etc/issue -a ! -e /etc/issue.devfix ] ; then + mv -f /etc/issue /etc/issue.devfix + fi + cp -f /usr/share/baselayout/issue.devfix /etc/issue + fi + fi + + # We got here, so return 0 + return 0 +} + +# vim: set ts=4 : diff --git a/init.d/halt.sh b/init.d/halt.sh new file mode 100755 index 00000000..eabc8980 --- /dev/null +++ b/init.d/halt.sh @@ -0,0 +1,94 @@ +#!/bin/sh +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +. /etc/init.d/functions.sh +. "${RC_LIBDIR}"/sh/rc-functions.sh + +# Support LiveCD foo +if [ -r /sbin/livecd-functions.sh ] ; then + . /sbin/livecd-functions.sh + livecd_read_commandline +fi + +stop_addon devfs +stop_addon udev + +# Flush all pending disk writes now +sync ; sync + +# If we are in a VPS, we don't need anything below here, because +# 1) we don't need (and by default can't) umount anything (VServer) or +# 2) the host utils take care of all umounting stuff (OpenVZ) +if [ "${RC_SYS}" = "VPS" ] ; then + if [ -e /etc/init.d/"$1".sh ] ; then + . /etc/init.d/"$1".sh + else + exit 0 + fi +fi + +# If $svcdir is still mounted, preserve it if we can +if mountinfo "${RC_SVCDIR}" >/dev/null && [ -w "${RC_LIBDIR}" ] ; then + f_opts="-m -c" + [ "${RC_UNAME}" = "Linux" ] && f_opts="-c" + if [ -n "$(fuser ${f_opts} "${svcdir}" 2>/dev/null)" ] ; then + fuser -k ${f_opts} "${svcdir}" 1>/dev/null 2>/dev/null + sleep 2 + fi + cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/softlevel \ + "${RC_SVCDIR}"/nettree "${RC_LIBDIR}" 2>/dev/null + umount "${RC_SVCDIR}" + rm -rf "${RC_SVCDIR}"/* + # Pipe errors to /dev/null as we may have future timestamps + cp -p "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/softlevel \ + "${RC_LIBDIR}"/nettree "${RC_SVCDIR}" 2>/dev/null + rm -f "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/softlevel \ + "${RC_LIBDIR}"/nettree + # Release the memory disk if we used it + case "${mnt}" in + "/dev/md"[0-9]*) mdconfig -d -u "${mnt#/dev/md*}" ;; + esac +fi + +unmounted=0 +# Remount the remaining filesystems read-only +if [ "${RC_UNAME}" != "FreeBSD" ] ; then + ebegin "Remounting remaining filesystems read-only" + # We need the do_unmount function + . "${RC_LIBDIR}"/sh/rc-mount.sh + eindent + do_unmount "mount -n -o remount,ro" "^(/dev|/dev/pts|/dev/shm|/proc|/proc/.*|/sys)$" + eoutdent + eend $? + unmounted=$? +fi + +# This UPS code should be moved to out of here and to an addon +if [ -f /etc/killpower ] ; then + UPS_CTL=/sbin/upsdrvctl + UPS_POWERDOWN="${UPS_CTL} shutdown" +elif [ -f /etc/apcupsd/powerfail ] ; then + UPS_CTL=/etc/apcupsd/apccontrol + UPS_POWERDOWN="${UPS_CTL} killpower" +fi +if [ -x "${UPS_CTL}" ] ; then + ewarn "Signalling ups driver(s) to kill the load!" + ${UPS_POWERDOWN} + ewarn "Halt system and wait for the UPS to kill our power" + halt -id + sleep 60 +fi + +if [ ${unmounted} -ne 0 ] ; then + [ -x /sbin/sulogin ] && sulogin -t 10 /dev/console + exit 1 +fi + +# Load the final script - not needed on BSD so they should not exist +[ -e /etc/init.d/"$1".sh ] && . /etc/init.d/"$1".sh + +# Always exit 0 here +exit 0 + +# vim: set ts=4 : diff --git a/init.d/hostname b/init.d/hostname new file mode 100755 index 00000000..86eb989a --- /dev/null +++ b/init.d/hostname @@ -0,0 +1,20 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need checkroot +} + +start() { + if [ -f /etc/hostname ] ; then + ewarn "You should stop using /etc/hostname and use /etc/conf.d/hostname" + HOSTNAME=$(cat /etc/hostname) + fi + + ebegin "Setting hostname to ${HOSTNAME}" + hostname "${HOSTNAME}" + eend $? "Failed to set the hostname" +} + +# vim: ts=4 : diff --git a/init.d/local b/init.d/local new file mode 100755 index 00000000..4e4c265c --- /dev/null +++ b/init.d/local @@ -0,0 +1,34 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + after * +} + +start() { + ebegin "Starting local" + + # Add any misc programs that should be started + # to /etc/conf.d/local.start + if [ -e /etc/conf.d/local.start ] ; then + . /etc/conf.d/local.start + fi + + eend $? "Failed to start local" +} + +stop() { + ebegin "Stopping local" + + # Add any misc programs that should be stopped + # to /etc/conf.d/local.stop + if [ -e /etc/conf.d/local.stop ] ; then + . /etc/conf.d/local.stop + fi + + eend $? $"Failed to stop local" +} + + +# vim:ts=4 diff --git a/init.d/localmount b/init.d/localmount new file mode 100755 index 00000000..303f5a2c --- /dev/null +++ b/init.d/localmount @@ -0,0 +1,183 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need checkfs +} + +start() { + # Mount local filesystems in /etc/fstab. + local types="noproc" x= + for x in ${RC_NET_FS_LIST} ; do + types="${types},${x}" + done + + ebegin "Mounting local filesystems" + mount -at "${types}" + eend $? "Some local filesystem failed to mount" + + # Change the mount options of already mounted paritions + # This is needed when /usr is separate and coming back from single user + if [ "${RC_UNAME}" != "Linux" ] ; then + mount -uao fstab -t "${types},linprocfs" + fi + + if [ -x /sbin/savecore ] ; then + local dumpdir=${KERNEL_DUMP_DIR:-/var/crash} + if ! [ -d "${dumpdir}" ]; then + mkdir -p "${dumpdir}" + chmod 700 "${dumpdir}" + fi + + # Don't quote ${KERNEL_DUMP_DEVICE}, so that if it's unset, savecore + # will check on the partitions listed in fstab without errors in the + # output + if savecore -C "${dumpdir}" ${KERNEL_DUMP_DEVICE} >/dev/null ; then + local savecoreopts="${dumpdir} ${KERNEL_DUMP_DEVICE}" + [ "${KERNEL_DUMP_COMPRESS}" = "yes" ] \ + && savecoreopts="-z ${savecoreopts}" + ebegin "Saving kernel core dump in" "${dumpdir}" + savecore ${savecoreopts} >/dev/null + eend $? + fi + fi + + # Sync bootlog now as /var should be mounted + if type bootlog >/dev/null 2>/dev/null ; then + bootlog sync 2>/dev/null + fi + + # Make sure we insert usbcore if its a module + if [ -f /proc/modules -a ! -d /proc/bus/usb ] ; then + # >/dev/null to hide errors from non-USB users + modprobe usbcore &> /dev/null + fi + + if [ -e /proc/filessystems ] ; then + # Check what USB fs the kernel support. Currently + # 2.5+ kernels, and later 2.4 kernels have 'usbfs', + # while older kernels have 'usbdevfs'. + if [ -d /proc/bus/usb -a ! -e /proc/bus/usb/devices ] ; then + local usbfs=$(grep -Fow usbfs /proc/filesystems || + grep -Fow usbdevfs /proc/filesystems) + + if [ -n "${usbfs}" ] ; then + ebegin $"Mounting USB device filesystem" "(${usbfs})" + local usbgid="$(getent group usb | \ + sed -e 's/.*:.*:\(.*\):.*/\1/')" + mount -t ${usbfs} \ + -o ${usbgid:+devmode=0664,devgid=${usbgid},}noexec,nosuid \ + usbfs /proc/bus/usb + eend $? + fi + fi + + # Setup Kernel Support for miscellaneous Binary Formats + if [ -d /proc/sys/fs/binfmt_misc ] ; then + if [ -n "$(grep -Fow binfmt_misc /proc/filesystems)" ] ; then + ebegin "Mounting misc binary format filesystem" + mount -t binfmt_misc -o nodev,noexec,nosuid \ + binfmt_misc /proc/sys/fs/binfmt_misc + eend $? + fi + fi + if [ -d /sys/kernel/security ] ; then + if [ -n "$(grep -Fow securityfs /proc/filesystems)" ] ; then + ebegin "Mounting security filesystem" + mount -t securityfs securityfs /sys/kernel/security \ + -o nodev,noexec,nosuid + eend $? + fi + fi + 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" + swapon -a >/dev/null + eend 0 # If swapon has nothing todo it errors, so always return 0 + + # Start dm-crypt mappings, if any + start_addon dm-crypt + + # Setup any user requested dump device + if [ -x /sbin/dumpon -a -n "${KERNEL_DUMP_DEVICE}" ] ; then + ebegin "Activating kernel core dump device" "(${KERNEL_DUMP_DEVICE})" + dumpon "${KERNEL_DUMP_DEVICE}" + eend $? + fi + + # Always return 0 - some local mounts may not be critical for boot + return 0 +} + +stop() { + # Don't unmount anything for VPS systems + [ "${RC_SYS}" = "VPS" ] && return 0 + + # We never unmount / or /dev or $RC_LIBDIR + local x= no_umounts="/|/dev|${RC_SVCDIR}" + + # NO_UMOUNTS is taken from /etc/conf.d/localmount + # RC_NO_UMOUNTS is taken from /etc/conf.d/rc and can also be + # set by plugins + local OIFS=$IFS SIFS=${IFS-y} + IFS=$IFS: + for x in ${NO_UMOUNTS} ${RC_NO_UMOUNTS} ; do + no_umounts="${no_umounts}|${x}" + done + if [ "${SIFS}" = "y" ] ; then + IFS=$OIFS + else + unset IFS + fi + + if [ "${RC_UNAME}" = "Linux" ] ; then + no_umounts="${no_umounts}|/dev/pts|/dev/shm|/proc|/proc/.*|/sys" + fi + no_umounts="^(${no_umounts})$" + + # Flush all pending disk writes now + sync ; sync + + # Try to unmount all tmpfs filesystems not in use, else a deadlock may + # occure, bug #13599. + # As $RC_SVCDIR may also be tmpfs we cd to it to lock it + cd "${RC_SVCDIR}" + umount -a -t tmpfs 2>/dev/null + + # As we're turning off swap below, we need to disable kernel dumps + [ -x /sbin/dumpon ] && dumpon off + + local swap_list= + # Turn off swap + if [ -r /proc/swaps ] ;then + swap_list=$(sed -e '1d' /proc/swaps) + else + swap_list=$(swapctl -l 2>/dev/null | sed -e '1d') + fi + if [ -n "${swap_list}" ] ; then + ebegin "Deactivating swap" + swapoff -a >/dev/null + eend $? + fi + + . "${RC_LIBDIR}"/sh/rc-mount.sh + + # Umount loopback devices + einfo "Unmounting loopback devices" + eindent + do_unmount "umount -d" "${no_umounts}" "^/dev/loop" + eoutdent + + # Now everything else + einfo "Unmounting filesystems" + eindent + do_unmount "umount" "${no_umounts}" + eoutdent + + return 0 +} + +# vim: set ts=4 : diff --git a/init.d/netmount b/init.d/netmount new file mode 100755 index 00000000..28c65489 --- /dev/null +++ b/init.d/netmount @@ -0,0 +1,85 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +have_nfs() { + local IFS=\n x= + set -- $(fstabinfo --fstype nfs,nfs4) + for x in "$@" ; do + ! fstabinfo --opts "${x}" | grep -q noauto && return 0 + done + return 1 +} + +depend() { + local myneed= myuse= pmap="portmap" nfsmounts= x + [ -x /etc/init.d/rpcbind ] && pmap="rpcbind" + + # Only have Portmap as a dependency if there is a nfs mount in fstab that + # is set to mount at boot + if have_nfs ; then + myneed="${myneed} ${pmap}" + else + myuse="${myuse} ${pmap}" + fi + + need net ${myneed} + use afc-client amd autofs dns nfs nfsmount ${myuse} +} + +start() { + local myneed= myuse= pmap="portmap" nfsmounts= + [ -x /etc/init.d/rpcbind ] && pmap="rpcbind" + + local x= fs= + for x in ${RC_NET_FS_LIST} ; do + case "${x}" in + nfs|nfs4) + # If the nfsmount script took care of the nfs filesystems, + # then there's no point in trying them twice + service_started nfsmount && continue + + # 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 have_nfs && ! service_started "${pmap}" ; then + continue + fi + ;; + esac + fs="${fs}${fs:+,}${x}" + done + + ebegin "Mounting network filesystems" + mount -at ${fs} + ewend $? "Could not mount all network filesystems!" + return 0 +} + +stop() { + local x= fs= + for x in ${RC_NET_FS_LIST} ; do + fs="${fs}${fs:+,}${x}" + done + + ebegin "Unmounting network filesystems" + umount -at ${fs} + local retval=$? + eend ${retval} "Failed to simply unmount filesystems" + + if [ ${retval} -ne 0 ] ; then + . "${RC_SVCLIB}/sh/rc-mount.sh" + eindent + fs= + for x in ${RC_NET_FS_LIST} ; do + fs="${fs:+|}${x}" + done + do_unmount "umount" "" "" "^(${fs})$" + retval=$? + eoutent + fi + + return ${retval} +} + +# vim: set ts=4 : diff --git a/init.d/rmnologin b/init.d/rmnologin new file mode 100755 index 00000000..56b20ea1 --- /dev/null +++ b/init.d/rmnologin @@ -0,0 +1,16 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need localmount +} + +start() { + if [ -f /etc/nologin.boot ] ; then + rm -f /etc/nologin /etc/nologin.boot + fi +} + + +# vim:ts=4 diff --git a/init.d/urandom b/init.d/urandom new file mode 100755 index 00000000..a09153a5 --- /dev/null +++ b/init.d/urandom @@ -0,0 +1,34 @@ +#!/sbin/runscript +# Copyright 1999-2007 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 ; 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 2>/dev/null + eend $? "Error initializing random number generator" + umask 022 +} + +stop() { + 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 2>/dev/null + eend $? "Failed to save random seed" +} + +# vim:ts=4 |