Move /etc/conf.d/rc to /etc/rc.conf.
Lowercase all configurable variables, non configurations remain uppercase. Replace rc_env_bool with rc_yesno. Split localmount info procfs (Linux) and dumpon, savecore (BSD)
This commit is contained in:
@@ -36,7 +36,7 @@ cleanup_tmp_dir() {
|
||||
|
||||
mkdir -p "${dir}"
|
||||
cd "${dir}"
|
||||
if [ "${WIPE_TMP}" = "yes" ]; then
|
||||
if [ "${wipe_tmp}" = "yes" ]; then
|
||||
ebegin "Wiping ${dir} directory"
|
||||
local startopts="-x . -depth"
|
||||
[ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth"
|
||||
@@ -116,7 +116,7 @@ start() {
|
||||
|
||||
# Clean up /tmp directories
|
||||
local tmp=
|
||||
for tmp in ${WIPE_TMP_DIRS-/tmp}; do
|
||||
for tmp in ${wipe_tmp_dirs-/tmp}; do
|
||||
cleanup_tmp_dir "${tmp}"
|
||||
done
|
||||
chmod +t /tmp /var/tmp
|
||||
|
@@ -63,7 +63,7 @@ do_checkfs() {
|
||||
ewend 1 "Operational error, continuing"
|
||||
retval=0
|
||||
else
|
||||
if [ "${RC_FORCE_AUTO}" = "yes" ] ; then
|
||||
if yesno ${rc_force_auto:-${RC_FORCE_AUTO}}; then
|
||||
eend 2 "Fsck could not correct all errors, rerunning"
|
||||
fsck ${opts} -y ${parts}
|
||||
retval=$?
|
||||
@@ -87,7 +87,9 @@ start() {
|
||||
|
||||
stop() {
|
||||
# fsck on shutdown if we need to
|
||||
[ "${FSCK_SHUTDOWN}" = "yes" -a ! -f /forcefsck ] && do_checkfs
|
||||
if yesno "${fsck_shutdown:-${FSCK_SHUTDOWN}}"; then
|
||||
[ ! -f /forcefsck ] && do_checkfs
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@@ -100,7 +100,7 @@ do_fsck() {
|
||||
retval=0
|
||||
elif [ ${retval} -eq 2 -o ${retval} -eq 3 ] ; then
|
||||
ewend 1 "Filesystem repaired, but reboot needed!"
|
||||
if [ "${RC_FORCE_AUTO}" != "yes" ] ; then
|
||||
if ! yesno ${rc_force_auto:-${RC_FORCE_AUTO}}; then
|
||||
printf "\a"; sleep 1; printf "\a"; sleep 1
|
||||
printf "\a"; sleep 1; printf "\a"; sleep 1
|
||||
ewarn "Rebooting in 10 seconds ..."
|
||||
@@ -109,7 +109,7 @@ do_fsck() {
|
||||
einfo "Rebooting"
|
||||
reboot -f
|
||||
else
|
||||
if [ "${RC_FORCE_AUTO}" = "yes" ] ; then
|
||||
if yesno ${rc_force_auto:-${RC_FORCE_AUTO}}; then
|
||||
eend 2 "Rerunning fsck in force mode"
|
||||
fsck ${opts} -y "${root}"
|
||||
retval=$?
|
||||
@@ -128,7 +128,6 @@ do_fsck() {
|
||||
reboot -f
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@@ -26,6 +26,7 @@
|
||||
|
||||
. /etc/init.d/functions.sh
|
||||
. "${RC_LIBDIR}"/sh/rc-functions.sh
|
||||
[ -r /etc/rc.conf ] && . /etc/rc.conf
|
||||
|
||||
# Support LiveCD foo
|
||||
if [ -r /sbin/livecd-functions.sh ] ; then
|
||||
@@ -43,12 +44,12 @@ if [ -x /sbin/killall5 ] ; then
|
||||
fi
|
||||
|
||||
# Flush all pending disk writes now
|
||||
sync ; sync
|
||||
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 [ "${RC_SYS}" = "VPS" ]; then
|
||||
if [ -e /etc/init.d/"$1".sh ] ; then
|
||||
. /etc/init.d/"$1".sh
|
||||
else
|
||||
@@ -93,7 +94,7 @@ if [ "${RC_UNAME}" = "Linux" ] ; then
|
||||
. "${RC_LIBDIR}"/sh/rc-mount.sh
|
||||
eindent
|
||||
fs=
|
||||
for x in ${RC_NET_FS_LIST} ; do
|
||||
for x in ${net_fs_list} ; do
|
||||
fs="${fs}${fs:+|}${x}"
|
||||
done
|
||||
[ -n "${fs}" ] && fs="^(${fs})$"
|
||||
|
@@ -31,13 +31,9 @@ depend() {
|
||||
}
|
||||
|
||||
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}"
|
||||
hostname=${hostname-${HOSTNAME-localhost}}
|
||||
ebegin "Setting hostname to ${hostname}"
|
||||
hostname "${hostname}"
|
||||
eend $? "Failed to set the hostname"
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,6 @@
|
||||
# SUCH DAMAGE.
|
||||
|
||||
description="Mounts disks and swap according to /etc/fstab."
|
||||
[ -e /proc/filessystems ] && description="${description} Also mounts various filesystems in /proc."
|
||||
[ -x /sbin/dumpon ] && description="${description} Also configures saving kernel dumps to swap."
|
||||
|
||||
depend() {
|
||||
need checkfs
|
||||
@@ -35,7 +33,7 @@ depend() {
|
||||
start() {
|
||||
# Mount local filesystems in /etc/fstab.
|
||||
local types="noproc" x=
|
||||
for x in ${RC_NET_FS_LIST} ; do
|
||||
for x in ${net_fs_list}; do
|
||||
types="${types},${x}"
|
||||
done
|
||||
|
||||
@@ -43,122 +41,6 @@ start() {
|
||||
mount -at "${types}"
|
||||
eend $? "Some local filesystem failed to mount"
|
||||
|
||||
if [ -x /sbin/savecore ] ; then
|
||||
local dumpdir=${KERNEL_DUMP_DIR:-/var/crash}
|
||||
if ! [ -d "${dumpdir}" ]; then
|
||||
mkdir -p "${dumpdir}"
|
||||
chmod 700 "${dumpdir}"
|
||||
fi
|
||||
|
||||
if [ "${RC_UNAME}" = "FreeBSD" ] ; then
|
||||
# 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
|
||||
savecore -C "${dumpdir}" ${KERNEL_DUMP_DEVICE} >/dev/null
|
||||
else
|
||||
ls "${dumpdir}"/bsd* > /dev/null 2>&1
|
||||
fi
|
||||
if [ $? = 0 ] ; then
|
||||
local sopts="${dumpdir} ${KERNEL_DUMP_DEVICE}"
|
||||
[ "${KERNEL_DUMP_COMPRESS}" = "yes" ] && sopts="-z ${sopts}"
|
||||
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
|
||||
modprobe -q usbcore
|
||||
fi
|
||||
|
||||
if [ -e /proc/filesystems ] ; 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 the NFS daemon status
|
||||
if [ -d /proc/fs/nfsd ] && ! mountinfo -q /proc/fs/nfsd ; then
|
||||
if grep -qs nfsd /proc/filesystems ; then
|
||||
ebegin "Mounting nfsd filesystem"
|
||||
mount -t nfsd -o nodev,noexec,nosuid \
|
||||
nfsd /proc/fs/nfsd
|
||||
eend $?
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup Kernel Support for miscellaneous Binary Formats
|
||||
if [ -d /proc/sys/fs/binfmt_misc ] && ! mountinfo -q /proc/sys/fs/binfmt_misc ; then
|
||||
if grep -qs 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
|
||||
|
||||
# Setup Kernel Support for securityfs
|
||||
if [ -d /sys/kernel/security ] && ! mountinfo -q /sys/kernel/security ; then
|
||||
if grep -qs securityfs /proc/filesystems ; then
|
||||
ebegin "Mounting security filesystem"
|
||||
mount -t securityfs securityfs /sys/kernel/security \
|
||||
-o nodev,noexec,nosuid
|
||||
eend $?
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup Kernel Support for debugfs
|
||||
if [ -d /sys/kernel/debug ] && ! mountinfo -q /sys/kernel/debug ; then
|
||||
if grep -qs debugfs /proc/filesystems ; then
|
||||
ebegin "Mounting debug filesystem"
|
||||
mount -t debugfs debugfs /sys/kernel/debug \
|
||||
-o nodev,noexec,nosuid
|
||||
eend $?
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup Kernel Support for SELinux
|
||||
if [ -d /selinux ] && ! mountinfo -q /selinux ; then
|
||||
if grep -qs selinuxfs /proc/filesystems ; then
|
||||
ebegin "Mounting SELinux filesystem"
|
||||
mount -t selinuxfs selinuxfs /selinux
|
||||
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
|
||||
|
||||
# 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
|
||||
}
|
||||
@@ -170,12 +52,10 @@ stop() {
|
||||
# We never unmount / or /dev or $RC_SVCDIR
|
||||
local x= no_umounts="/|/dev|/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
|
||||
# RC_NO_UMOUNTS is an env var that can be set by plugins
|
||||
OIFS=${IFS} SIFS=${IFS-y}
|
||||
IFS=$IFS:
|
||||
for x in ${NO_UMOUNTS} ${RC_NO_UMOUNTS} ; do
|
||||
for x in ${no_umounts} ${RC_NO_UMOUNTS}; do
|
||||
no_umounts="${no_umounts}|${x}"
|
||||
done
|
||||
if [ "${SIFS}" = "y" ] ; then
|
||||
@@ -184,13 +64,13 @@ stop() {
|
||||
unset IFS
|
||||
fi
|
||||
|
||||
if [ "${RC_UNAME}" = "Linux" ] ; then
|
||||
if [ "${RC_UNAME}" = "Linux" ]; then
|
||||
no_umounts="${no_umounts}|/proc|/proc/.*|/sys|/sys/.*"
|
||||
fi
|
||||
no_umounts="^(${no_umounts})$"
|
||||
|
||||
# Flush all pending disk writes now
|
||||
sync ; sync
|
||||
sync; sync
|
||||
|
||||
# Try to unmount all tmpfs filesystems not in use, else a deadlock may
|
||||
# occure, bug #13599.
|
||||
@@ -198,22 +78,6 @@ stop() {
|
||||
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
|
||||
@@ -228,7 +92,7 @@ stop() {
|
||||
einfo "Unmounting filesystems"
|
||||
eindent
|
||||
local fs=
|
||||
for x in ${RC_NET_FS_LIST} ; do
|
||||
for x in ${net_fs_list}; do
|
||||
fs="${fs}${fs:+|}${x}"
|
||||
done
|
||||
[ -n "${fs}" ] && fs="^(${fs})$"
|
||||
|
@@ -59,7 +59,7 @@ start() {
|
||||
[ -x /etc/init.d/rpcbind ] && pmap="rpcbind"
|
||||
|
||||
local x= fs=
|
||||
for x in ${RC_NET_FS_LIST}; do
|
||||
for x in ${net_fs_list}; do
|
||||
case "${x}" in
|
||||
nfs|nfs4)
|
||||
# If the nfsmount script took care of the nfs filesystems,
|
||||
@@ -89,7 +89,7 @@ stop() {
|
||||
ebegin "Unmounting network filesystems"
|
||||
. "${RC_LIBDIR}/sh/rc-mount.sh"
|
||||
|
||||
for x in ${RC_NET_FS_LIST} ; do
|
||||
for x in ${net_fs_list} ; do
|
||||
fs="${fs}${fs:+,}${x}"
|
||||
done
|
||||
if [ -n "${fs}" ]; then
|
||||
@@ -98,7 +98,7 @@ stop() {
|
||||
|
||||
eindent
|
||||
fs=
|
||||
for x in ${RC_NET_FS_LIST}; do
|
||||
for x in ${net_fs_list}; do
|
||||
fs="${fs}${fs:+|}${x}"
|
||||
done
|
||||
[ -n "${fs}" ] && fs="^(${fs})$"
|
||||
|
40
init.d/swap
Normal file
40
init.d/swap
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/sbin/runscript
|
||||
# Copyright 2007 Roy Marples
|
||||
# All rights reserved
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
depend() {
|
||||
need localmount
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Activating swap"
|
||||
swapon -a >/dev/null
|
||||
eend 0 # If swapon has nothing todo it errors, so always return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Deactivating swap"
|
||||
swapoff -a >/dev/null
|
||||
eend 0
|
||||
}
|
@@ -24,7 +24,7 @@
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
URANDOM_SEED=${URANDOM_SEED:-/var/run/random-seed}
|
||||
urandom_seed=${urandom_seed:-${URANDOM_SEED:-/var/run/random-seed}}
|
||||
|
||||
description="Initializes the random number generator."
|
||||
|
||||
@@ -41,22 +41,19 @@ save_seed() {
|
||||
|
||||
( # sub shell to prevent umask pollution
|
||||
umask 077
|
||||
dd if=/dev/urandom of="${URANDOM_SEED}" count=${poolsize} 2>/dev/null
|
||||
dd if=/dev/urandom of="${urandom_seed}" count=${poolsize} 2>/dev/null
|
||||
)
|
||||
}
|
||||
|
||||
start() {
|
||||
[ -c /dev/urandom ] || return
|
||||
if [ -f "${URANDOM_SEED}" ] ; then
|
||||
cat "${URANDOM_SEED}" > /dev/urandom
|
||||
if [ -f "${urandom_seed}" ] ; then
|
||||
ebegin "Initializing random number generator"
|
||||
cat "${urandom_seed}" > /dev/urandom
|
||||
eend $? "Error initializing random number generator"
|
||||
fi
|
||||
if ! rm -f "${URANDOM_SEED}" ; then
|
||||
ewarn "Skipping ${URANDOM_SEED} initialization (ro root?)"
|
||||
return 0
|
||||
fi
|
||||
ebegin "Initializing random number generator"
|
||||
save_seed
|
||||
eend $? "Error initializing random number generator"
|
||||
rm -f "${urandom_seed}" && save_seed
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
Reference in New Issue
Block a user