From a12dbdc6c93a7d63591610378e3e570b7c7d2143 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sun, 2 Mar 2008 21:13:21 +0000 Subject: Don't check for root in prefix. --- init.d/bootmisc | 131 -------------------------------------------------- init.d/bootmisc.in | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++ init.d/fsck | 76 ----------------------------- init.d/fsck.in | 76 +++++++++++++++++++++++++++++ init.d/hostname | 13 ----- init.d/hostname.in | 17 +++++++ init.d/local | 43 ----------------- init.d/local.in | 43 +++++++++++++++++ init.d/localmount | 87 --------------------------------- init.d/localmount.in | 87 +++++++++++++++++++++++++++++++++ init.d/netmount | 96 ------------------------------------- init.d/netmount.in | 96 +++++++++++++++++++++++++++++++++++++ init.d/root | 26 ---------- init.d/root.in | 26 ++++++++++ init.d/swap | 23 --------- init.d/swap.in | 23 +++++++++ init.d/urandom | 46 ------------------ init.d/urandom.in | 46 ++++++++++++++++++ 18 files changed, 546 insertions(+), 541 deletions(-) delete mode 100755 init.d/bootmisc create mode 100644 init.d/bootmisc.in delete mode 100644 init.d/fsck create mode 100644 init.d/fsck.in delete mode 100755 init.d/hostname create mode 100644 init.d/hostname.in delete mode 100755 init.d/local create mode 100644 init.d/local.in delete mode 100755 init.d/localmount create mode 100644 init.d/localmount.in delete mode 100755 init.d/netmount create mode 100644 init.d/netmount.in delete mode 100644 init.d/root create mode 100644 init.d/root.in delete mode 100644 init.d/swap create mode 100644 init.d/swap.in delete mode 100755 init.d/urandom create mode 100644 init.d/urandom.in (limited to 'init.d') diff --git a/init.d/bootmisc b/init.d/bootmisc deleted file mode 100755 index a66c93f..0000000 --- a/init.d/bootmisc +++ /dev/null @@ -1,131 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - use hostname - need localmount - before logger - after clock sysctl -} - -cleanup_tmp_dir() -{ - local dir=$1 - - mkdir -p "${dir}" - cd "${dir}" - if yesno ${wipe_tmp:-${WIPE_TMP:-yes}}; then - ebegin "Wiping ${dir} directory" - local startopts="-x . -depth" delete="-exec rm -rf -- {} ;" - - if [ "${RC_UNAME}" = "Linux" ]; then - startopts=". -xdev -depth" - # busybox find / rm cannot handle -- - delete="-delete" - fi - - # Faster than find - rm -rf -- [b-ikm-pr-zA-Z0-9\.]* - - 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} \ - -type d -prune - eend 0 - else - ebegin "Cleaning ${dir} directory" - rm -rf -- "${dir}"/.X*-lock "${dir}"/esrv* "${dir}"/kio* \ - "${dir}"/jpsock.* "${dir}"/.fam* "${dir}"/.esd* \ - "${dir}"/orbit-* "${dir}"/ssh-* "${dir}"/ksocket-* \ - "${dir}"/.*-unix - eend 0 - fi -} - -start() -{ - if ! mkdir /.test.$$ 2>/dev/null; then - ewarn "Skipping /var and /tmp initialization (ro root?)" - return 0 - fi - rmdir /.test.$$ - - # Ensure that our basic dirs exist - for x in /var/log /var/run /tmp; do - if ! [ -d "${x}" ]; then - if ! mkdir -p "${x}"; then - eend 1 "failed to create needed directory ${x}" - return 1 - fi - fi - done - - ebegin "Creating user login records" - cp /dev/null /var/run/utmp - [ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp - chmod 0644 /var/run/utmp /var/log/wtmp - eend 0 - - ebegin "Cleaning /var/run" - for x in $(find /var/run ! -type d ! -name utmp ! -name random-seed \ - ! -name ld-elf.so.hints ! -name ld.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 - eend 0 - - # Clean up /tmp directories - local tmp= - for tmp in ${wipe_tmp_dirs-/tmp}; do - cleanup_tmp_dir "${tmp}" - done - chmod +t /tmp /var/tmp - - # 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 - - # Create an 'after-boot' dmesg log - if [ "${RC_SYS}" != "VPS" ]; then - dmesg > /var/log/dmesg - chmod 640 /var/log/dmesg - fi - - rm -f /etc/nologin -} - -stop() -{ - # Write a halt record if we're shutting down - case "${RC_SOFTLEVEL}" in - reboot|shutdown) [ "${RC_UNAME}" = "Linux" ] && halt -w;; - esac - - return 0 -} diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in new file mode 100644 index 0000000..a14a2c7 --- /dev/null +++ b/init.d/bootmisc.in @@ -0,0 +1,132 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + use hostname + need localmount + before logger + after clock sysctl + keyword noprefix +} + +cleanup_tmp_dir() +{ + local dir=$1 + + mkdir -p "${dir}" + cd "${dir}" + if yesno ${wipe_tmp:-${WIPE_TMP:-yes}}; then + ebegin "Wiping ${dir} directory" + local startopts="-x . -depth" delete="-exec rm -rf -- {} ;" + + if [ "${RC_UNAME}" = "Linux" ]; then + startopts=". -xdev -depth" + # busybox find / rm cannot handle -- + delete="-delete" + fi + + # Faster than find + rm -rf -- [b-ikm-pr-zA-Z0-9\.]* + + 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} \ + -type d -prune + eend 0 + else + ebegin "Cleaning ${dir} directory" + rm -rf -- "${dir}"/.X*-lock "${dir}"/esrv* "${dir}"/kio* \ + "${dir}"/jpsock.* "${dir}"/.fam* "${dir}"/.esd* \ + "${dir}"/orbit-* "${dir}"/ssh-* "${dir}"/ksocket-* \ + "${dir}"/.*-unix + eend 0 + fi +} + +start() +{ + if ! mkdir /.test.$$ 2>/dev/null; then + ewarn "Skipping /var and /tmp initialization (ro root?)" + return 0 + fi + rmdir /.test.$$ + + # Ensure that our basic dirs exist + for x in /var/log /var/run /tmp; do + if ! [ -d "${x}" ]; then + if ! mkdir -p "${x}"; then + eend 1 "failed to create needed directory ${x}" + return 1 + fi + fi + done + + ebegin "Creating user login records" + cp /dev/null /var/run/utmp + [ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp + chmod 0644 /var/run/utmp /var/log/wtmp + eend 0 + + ebegin "Cleaning /var/run" + for x in $(find /var/run ! -type d ! -name utmp ! -name random-seed \ + ! -name ld-elf.so.hints ! -name ld.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 + eend 0 + + # Clean up /tmp directories + local tmp= + for tmp in ${wipe_tmp_dirs-/tmp}; do + cleanup_tmp_dir "${tmp}" + done + chmod +t /tmp /var/tmp + + # 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 + + # Create an 'after-boot' dmesg log + if [ "${RC_SYS}" != "VPS" ]; then + dmesg > /var/log/dmesg + chmod 640 /var/log/dmesg + fi + + rm -f /etc/nologin +} + +stop() +{ + # Write a halt record if we're shutting down + case "${RC_SOFTLEVEL}" in + reboot|shutdown) [ "${RC_UNAME}" = "Linux" ] && halt -w;; + esac + + return 0 +} diff --git a/init.d/fsck b/init.d/fsck deleted file mode 100644 index fec912b..0000000 --- a/init.d/fsck +++ /dev/null @@ -1,76 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Check and repair filesystems according to /etc/fstab" -_ISF=" -" - -depend() -{ - after clock modules - keyword nojail notimeout -} - -_abort() { - rc-abort - return 1 -} - -# We should only reboot when first booting -_reboot() { - if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" ]; then - reboot "$@" - _abort || return 1 - fi -} - -start() -{ - local reboot_opts= fsck_opts= p= - - ebegin "Checking local filesystems" - for p in ${fsck_passno}; do - local IFS="${_IFS}" - case "${p}" in - [0-9]*) p="=${p}";; - esac - set -- "$@" "$(fstabinfo --passno "${p}")" - unset IFS - done - - if [ "${RC_UNAME}" = "Linux" ]; then - fsck_opts="-C0 -T" - if [ -z "${fsck_passno}" ]; then - fsck_args=${fsck_args--A -p} - if echo 2>/dev/null >/.test.$$; then - rm -f /.test.$$ - fsck_opts="${fsck_args} -R" - fi - fi - reboot_opts="-f" - fi - - trap : QUIT - fsck ${fsck_args--p} ${fsck_opts} "$@" - case $? in - 0) eend 0; return 0;; - 1) ewend 1 "Filesystems repaired"; return 0;; - 2|3|4) ewend 1 "Filesystems repaired, but reboot needed" - _reboot ${reboot_opts} || return 1;; - 8) ewend 1 "Operational error"; return 0;; - 12) ewend 1 "fsck interupted"; return 1;; - *) eend 2 "Filesystems couldn't be fixed" - _abort || return 1;; - esac -} - -stop() -{ - # Fake function so we always shutdown correctly. - _abort() { return 0; } - _reboot() { return 0; } - - yesno "${fsck_shutdown}" && start - return 0 -} diff --git a/init.d/fsck.in b/init.d/fsck.in new file mode 100644 index 0000000..f34a852 --- /dev/null +++ b/init.d/fsck.in @@ -0,0 +1,76 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Check and repair filesystems according to /etc/fstab" +_ISF=" +" + +depend() +{ + after clock modules + keyword nojail noprefix notimeout +} + +_abort() { + rc-abort + return 1 +} + +# We should only reboot when first booting +_reboot() { + if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" ]; then + reboot "$@" + _abort || return 1 + fi +} + +start() +{ + local reboot_opts= fsck_opts= p= + + ebegin "Checking local filesystems" + for p in ${fsck_passno}; do + local IFS="${_IFS}" + case "${p}" in + [0-9]*) p="=${p}";; + esac + set -- "$@" "$(fstabinfo --passno "${p}")" + unset IFS + done + + if [ "${RC_UNAME}" = "Linux" ]; then + fsck_opts="-C0 -T" + if [ -z "${fsck_passno}" ]; then + fsck_args=${fsck_args--A -p} + if echo 2>/dev/null >/.test.$$; then + rm -f /.test.$$ + fsck_opts="${fsck_args} -R" + fi + fi + reboot_opts="-f" + fi + + trap : QUIT + fsck ${fsck_args--p} ${fsck_opts} "$@" + case $? in + 0) eend 0; return 0;; + 1) ewend 1 "Filesystems repaired"; return 0;; + 2|3|4) ewend 1 "Filesystems repaired, but reboot needed" + _reboot ${reboot_opts} || return 1;; + 8) ewend 1 "Operational error"; return 0;; + 12) ewend 1 "fsck interupted"; return 1;; + *) eend 2 "Filesystems couldn't be fixed" + _abort || return 1;; + esac +} + +stop() +{ + # Fake function so we always shutdown correctly. + _abort() { return 0; } + _reboot() { return 0; } + + yesno "${fsck_shutdown}" && start + return 0 +} diff --git a/init.d/hostname b/init.d/hostname deleted file mode 100755 index a777cb3..0000000 --- a/init.d/hostname +++ /dev/null @@ -1,13 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Sets the hostname of the machine." - -start() -{ - hostname=${hostname-${HOSTNAME-localhost}} - ebegin "Setting hostname to ${hostname}" - hostname "${hostname}" - eend $? "Failed to set the hostname" -} diff --git a/init.d/hostname.in b/init.d/hostname.in new file mode 100644 index 0000000..646ceb8 --- /dev/null +++ b/init.d/hostname.in @@ -0,0 +1,17 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Sets the hostname of the machine." + +depend() { + keyword noprefix +} + +start() +{ + hostname=${hostname-${HOSTNAME-localhost}} + ebegin "Setting hostname to ${hostname}" + hostname "${hostname}" + eend $? "Failed to set the hostname" +} diff --git a/init.d/local b/init.d/local deleted file mode 100755 index 9b83752..0000000 --- a/init.d/local +++ /dev/null @@ -1,43 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Executes user commands in /etc/conf.d/local" - -depend() -{ - after * - keyword notimeout -} - -start() -{ - ebegin "Starting local" - - if type local_start >/dev/null 2>&1; then - local_start - fi - - # Support old configs - if [ -e /etc/conf.d/local.start ]; then - . /etc/conf.d/local.start - fi - - eend $? "Failed to start local" -} - -stop() -{ - ebegin "Stopping local" - - if type local_start >/dev/null 2>&1; then - local_stop - fi - - # Support old configs - if [ -e /etc/conf.d/local.stop ]; then - . /etc/conf.d/local.stop - fi - - eend $? $"Failed to stop local" -} diff --git a/init.d/local.in b/init.d/local.in new file mode 100644 index 0000000..9b83752 --- /dev/null +++ b/init.d/local.in @@ -0,0 +1,43 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Executes user commands in /etc/conf.d/local" + +depend() +{ + after * + keyword notimeout +} + +start() +{ + ebegin "Starting local" + + if type local_start >/dev/null 2>&1; then + local_start + fi + + # Support old configs + if [ -e /etc/conf.d/local.start ]; then + . /etc/conf.d/local.start + fi + + eend $? "Failed to start local" +} + +stop() +{ + ebegin "Stopping local" + + if type local_start >/dev/null 2>&1; then + local_stop + fi + + # Support old configs + if [ -e /etc/conf.d/local.stop ]; then + . /etc/conf.d/local.stop + fi + + eend $? $"Failed to stop local" +} diff --git a/init.d/localmount b/init.d/localmount deleted file mode 100755 index a598a71..0000000 --- a/init.d/localmount +++ /dev/null @@ -1,87 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Mounts disks and swap according to /etc/fstab." - -depend() -{ - need fsck - use modules mtab - keyword nojail -} - -start() -{ - # Mount local filesystems in /etc/fstab. - local types="noproc" x= - for x in ${net_fs_list}; do - types="${types},${x}" - done - - ebegin "Mounting local filesystems" - mount -at "${types}" - eend $? "Some local filesystem failed to mount" - - # 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_SVCDIR - local x= no_umounts="/|/dev|/dev/.*|${RC_SVCDIR}" - - # 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 - 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}|/proc|/proc/.*|/sys|/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 - - . "${RC_LIBDIR}"/sh/rc-mount.sh - - # Umount loopback devices - einfo "Unmounting loopback devices" - eindent - do_unmount "umount -d" --skip-point-regex "${no_umounts}" \ - --node-regex "^/dev/loop" - eoutdent - - # Now everything else, except network filesystems as the - # network should be down by this point. - einfo "Unmounting filesystems" - eindent - local fs= - for x in ${net_fs_list}; do - fs="${fs}${fs:+|}${x}" - done - [ -n "${fs}" ] && fs="^(${fs})$" - do_unmount "umount" --skip-point-regex "${no_umounts}" \ - ${fs:+--skip-fstype-regex} ${fs} --nonetdev - eoutdent - - return 0 -} diff --git a/init.d/localmount.in b/init.d/localmount.in new file mode 100644 index 0000000..bc16f70 --- /dev/null +++ b/init.d/localmount.in @@ -0,0 +1,87 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Mounts disks and swap according to /etc/fstab." + +depend() +{ + need fsck + use modules mtab + keyword nojail noprefix +} + +start() +{ + # Mount local filesystems in /etc/fstab. + local types="noproc" x= + for x in ${net_fs_list}; do + types="${types},${x}" + done + + ebegin "Mounting local filesystems" + mount -at "${types}" + eend $? "Some local filesystem failed to mount" + + # 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_SVCDIR + local x= no_umounts="/|/dev|/dev/.*|${RC_SVCDIR}" + + # 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 + 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}|/proc|/proc/.*|/sys|/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 + + . "${RC_LIBDIR}"/sh/rc-mount.sh + + # Umount loopback devices + einfo "Unmounting loopback devices" + eindent + do_unmount "umount -d" --skip-point-regex "${no_umounts}" \ + --node-regex "^/dev/loop" + eoutdent + + # Now everything else, except network filesystems as the + # network should be down by this point. + einfo "Unmounting filesystems" + eindent + local fs= + for x in ${net_fs_list}; do + fs="${fs}${fs:+|}${x}" + done + [ -n "${fs}" ] && fs="^(${fs})$" + do_unmount "umount" --skip-point-regex "${no_umounts}" \ + ${fs:+--skip-fstype-regex} ${fs} --nonetdev + eoutdent + + return 0 +} diff --git a/init.d/netmount b/init.d/netmount deleted file mode 100755 index 688b0f4..0000000 --- a/init.d/netmount +++ /dev/null @@ -1,96 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Mounts network shares according to /etc/fstab." - -need_portmap() -{ - local opts= - local IFS=" -" - set -- $(fstabinfo --options --fstype nfs,nfs4) - for opts; do - case ,${opts}, in - *,noauto,*|*,nolock,*);; - *) return 0;; - esac - done - return 1 -} - -depend() -{ - # Only have portmap as a dependency if there is a nfs mount in fstab - # that is set to mount at boot - local pmap="" - if need_portmap; then - pmap="${pmap} rpc.statd" - [ -x /etc/init.d/rpcbind ] \ - && pmap="rpcbind" \ - || pmap="portmap" - fi - - config /etc/fstab - need net ${pmap} - use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd - keyword nojail -} - -start() -{ - local myneed= myuse= pmap="portmap" nfsmounts= - [ -x /etc/init.d/rpcbind ] && pmap="rpcbind" - - local x= fs= - for x in ${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 need_portmap && ! 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= - - ebegin "Unmounting network filesystems" - . "${RC_LIBDIR}/sh/rc-mount.sh" - - for x in ${net_fs_list}; do - fs="${fs}${fs:+,}${x}" - done - if [ -n "${fs}" ]; then - umount -at ${fs} || eerror "Failed to simply unmount filesystems" - fi - - eindent - fs= - for x in ${net_fs_list}; do - fs="${fs}${fs:+|}${x}" - done - [ -n "${fs}" ] && fs="^(${fs})$" - do_unmount "umount" ${fs:+--fstype-regex} ${fs} --netdev - retval=$? - - eoutdent - eend ${retval} "Failed to unmount network filesystems" -} diff --git a/init.d/netmount.in b/init.d/netmount.in new file mode 100644 index 0000000..3aa46e1 --- /dev/null +++ b/init.d/netmount.in @@ -0,0 +1,96 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Mounts network shares according to /etc/fstab." + +need_portmap() +{ + local opts= + local IFS=" +" + set -- $(fstabinfo --options --fstype nfs,nfs4) + for opts; do + case ,${opts}, in + *,noauto,*|*,nolock,*);; + *) return 0;; + esac + done + return 1 +} + +depend() +{ + # Only have portmap as a dependency if there is a nfs mount in fstab + # that is set to mount at boot + local pmap="" + if need_portmap; then + pmap="${pmap} rpc.statd" + [ -x /etc/init.d/rpcbind ] \ + && pmap="rpcbind" \ + || pmap="portmap" + fi + + config /etc/fstab + need net ${pmap} + use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd + keyword nojail noprefix +} + +start() +{ + local myneed= myuse= pmap="portmap" nfsmounts= + [ -x /etc/init.d/rpcbind ] && pmap="rpcbind" + + local x= fs= + for x in ${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 need_portmap && ! 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= + + ebegin "Unmounting network filesystems" + . "${RC_LIBDIR}/sh/rc-mount.sh" + + for x in ${net_fs_list}; do + fs="${fs}${fs:+,}${x}" + done + if [ -n "${fs}" ]; then + umount -at ${fs} || eerror "Failed to simply unmount filesystems" + fi + + eindent + fs= + for x in ${net_fs_list}; do + fs="${fs}${fs:+|}${x}" + done + [ -n "${fs}" ] && fs="^(${fs})$" + do_unmount "umount" ${fs:+--fstype-regex} ${fs} --netdev + retval=$? + + eoutdent + eend ${retval} "Failed to unmount network filesystems" +} diff --git a/init.d/root b/init.d/root deleted file mode 100644 index ff4726b..0000000 --- a/init.d/root +++ /dev/null @@ -1,26 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Mount the root fs read/write" - -depend() -{ - need fsck - keyword nojail -} - -start() -{ - if echo 2>/dev/null >/.test.$$; then - rm -f /.test.$$ - return 0 - fi - - ebegin "Remounting root filesystem read/write" - case "${RC_UNAME}" in - Linux) mount -n -o remount,rw /;; - *) mount -u -o rw /;; - esac - eend $? "Root filesystem could not be mounted read/write" -} diff --git a/init.d/root.in b/init.d/root.in new file mode 100644 index 0000000..b7ffbf8 --- /dev/null +++ b/init.d/root.in @@ -0,0 +1,26 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Mount the root fs read/write" + +depend() +{ + need fsck + keyword nojail noprefix +} + +start() +{ + if echo 2>/dev/null >/.test.$$; then + rm -f /.test.$$ + return 0 + fi + + ebegin "Remounting root filesystem read/write" + case "${RC_UNAME}" in + Linux) mount -n -o remount,rw /;; + *) mount -u -o rw /;; + esac + eend $? "Root filesystem could not be mounted read/write" +} diff --git a/init.d/swap b/init.d/swap deleted file mode 100644 index c8b1ab8..0000000 --- a/init.d/swap +++ /dev/null @@ -1,23 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - need localmount - keyword nojail -} - -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 -} diff --git a/init.d/swap.in b/init.d/swap.in new file mode 100644 index 0000000..b9f4fc9 --- /dev/null +++ b/init.d/swap.in @@ -0,0 +1,23 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + need localmount + keyword nojail noprefix +} + +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 +} diff --git a/init.d/urandom b/init.d/urandom deleted file mode 100755 index 3fc0a6d..0000000 --- a/init.d/urandom +++ /dev/null @@ -1,46 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -urandom_seed=${urandom_seed:-${URANDOM_SEED:-/var/run/random-seed}} - -description="Initializes the random number generator." - -depend() -{ - need localmount - keyword nojail -} - -save_seed() -{ - local psz=1 - - if [ -e /proc/sys/kernel/random/poolsize ]; then - psz=$(($(cat /proc/sys/kernel/random/poolsize) / 4096)) - fi - - ( # sub shell to prevent umask pollution - umask 077 - dd if=/dev/urandom of="${urandom_seed}" count=${psz} 2>/dev/null - ) -} - -start() -{ - [ -c /dev/urandom ] || return - if [ -f "${urandom_seed}" ]; then - ebegin "Initializing random number generator" - cat "${urandom_seed}" > /dev/urandom - eend $? "Error initializing random number generator" - fi - rm -f "${urandom_seed}" && save_seed - return 0 -} - -stop() -{ - ebegin "Saving random seed" - save_seed - eend $? "Failed to save random seed" -} diff --git a/init.d/urandom.in b/init.d/urandom.in new file mode 100644 index 0000000..6e90100 --- /dev/null +++ b/init.d/urandom.in @@ -0,0 +1,46 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +urandom_seed=${urandom_seed:-${URANDOM_SEED:-/var/run/random-seed}} + +description="Initializes the random number generator." + +depend() +{ + need localmount + keyword nojail noprefix +} + +save_seed() +{ + local psz=1 + + if [ -e /proc/sys/kernel/random/poolsize ]; then + psz=$(($(cat /proc/sys/kernel/random/poolsize) / 4096)) + fi + + ( # sub shell to prevent umask pollution + umask 077 + dd if=/dev/urandom of="${urandom_seed}" count=${psz} 2>/dev/null + ) +} + +start() +{ + [ -c /dev/urandom ] || return + if [ -f "${urandom_seed}" ]; then + ebegin "Initializing random number generator" + cat "${urandom_seed}" > /dev/urandom + eend $? "Error initializing random number generator" + fi + rm -f "${urandom_seed}" && save_seed + return 0 +} + +stop() +{ + ebegin "Saving random seed" + save_seed + eend $? "Failed to save random seed" +} -- cgit v1.2.3