summaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
Diffstat (limited to 'init.d')
-rw-r--r--init.d/.gitignore5
-rw-r--r--init.d/Makefile4
-rw-r--r--init.d/Makefile.Linux8
-rw-r--r--init.d/halt.in23
-rw-r--r--init.d/halt.sh.in112
-rw-r--r--init.d/killprocs.in15
-rw-r--r--init.d/romount.in43
-rw-r--r--init.d/savecache.in25
8 files changed, 118 insertions, 117 deletions
diff --git a/init.d/.gitignore b/init.d/.gitignore
index d7322d6..dace4de 100644
--- a/init.d/.gitignore
+++ b/init.d/.gitignore
@@ -2,12 +2,15 @@ bootmisc
devfs
dmesg
fsck
-halt.sh
+halt
hostname
+killprocs
local
localmount
netmount
+romount
root
+savecache
swap
sysctl
urandom
diff --git a/init.d/Makefile b/init.d/Makefile
index 07d41a1..fd2c87d 100644
--- a/init.d/Makefile
+++ b/init.d/Makefile
@@ -1,6 +1,6 @@
DIR= ${INITDIR}
-SRCS= bootmisc.in fsck.in halt.sh.in hostname.in local.in localmount.in \
- netmount.in root.in swap.in sysctl.in urandom.in
+SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in \
+ netmount.in root.in savecache.in swap.in sysctl.in urandom.in
BIN= ${OBJS}
INSTALLAFTER= _installafter
diff --git a/init.d/Makefile.Linux b/init.d/Makefile.Linux
index be519c8..1bf3fe7 100644
--- a/init.d/Makefile.Linux
+++ b/init.d/Makefile.Linux
@@ -1,7 +1,11 @@
NET_LO= net.lo
-SRCS+= devfs.in dmesg.in hwclock.in consolefont.in keymaps.in modules.in \
- mtab.in numlock.in procfs.in sysfs.in termencoding.in
+SRCS+= devfs.in dmesg.in hwclock.in consolefont.in keymaps.in killprocs.in \
+ modules.in mtab.in numlock.in procfs.in romount.in sysfs.in \
+ termencoding.in
+
+# This really belongs with sysvinit
+SRCS+= halt.in
.SUFFIXES: .Linux.in
.Linux.in:
diff --git a/init.d/halt.in b/init.d/halt.in
new file mode 100644
index 0000000..b8f9ed9
--- /dev/null
+++ b/init.d/halt.in
@@ -0,0 +1,23 @@
+#!@PREFIX@/sbin/runscript
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+# This script really belongs with the Linux sysvinit package
+
+depend()
+{
+ after *
+ use romount
+}
+
+start()
+{
+ case "${RUNLEVEL}" in
+ 0) runlevel=shutdown;;
+ 6) runlevel=reboot;;
+ *) eerror "Unknown runlevel ${RUNLEVEL}"; return 1
+ esac
+
+ . /etc/init.d/"${runlevel}".sh
+ return 0
+}
diff --git a/init.d/halt.sh.in b/init.d/halt.sh.in
deleted file mode 100644
index ab73d8d..0000000
--- a/init.d/halt.sh.in
+++ /dev/null
@@ -1,112 +0,0 @@
-#!@SHELL@
-# Copyright 2007-2008 Roy Marples <roy@marples.name>
-# All rights reserved. Released under the 2-clause BSD license.
-
-. @SYSCONFDIR@/init.d/functions.sh
-. "${RC_LIBDIR}"/sh/rc-functions.sh
-[ -r @SYSCONFDIR@/conf.d/localmount ] && . @SYSCONFDIR@/conf.d/localmount
-[ -r @SYSCONFDIR@/rc.conf ] && . @SYSCONFDIR@/rc.conf
-
-# Really kill things off before unmounting
-if [ -x /sbin/killall5 ]; then
- killall5 -15
- killall5 -9
-fi
-
-# 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}" = "VSERVER" -o "${RC_SYS}" = "OPENVZ" ]; then
- [ "${RC_SYS}" = "OPENVZ" -a "$1" = "reboot" ] && echo "" > /reboot
- if [ -e @SYSCONFDIR@/init.d/"$1".sh ]; then
- . @SYSCONFDIR@/init.d/"$1".sh
- else
- exit 0
- fi
-fi
-
-# If $svcdir is still mounted, preserve it if we can
-mnt=$(mountinfo --node "${RC_SVCDIR}")
-if [ -n "${mnt}" ] && \
- rm -rf "${RC_LIBDIR}/tmp.$$" && \
- mkdir -p "${RC_LIBDIR}/tmp.$$" 2>/dev/null \
-; then
- rmdir "${RC_LIBDIR}/tmp.$$"
- f_opts="-m -c"
- [ "${RC_UNAME}" = "Linux" ] && f_opts="-c"
- if type fuser >/dev/null 2>&1; then
- if [ -n "$(fuser ${f_opts} "${svcdir}" 2>/dev/null)" ]; then
- fuser -k ${f_opts} "${svcdir}" >/dev/null 2>&1
- sleep 2
- fi
- fi
- cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
- "${RC_SVCDIR}"/softlevel "${RC_SVCDIR}"/nettree \
- "${RC_SVCDIR}"/rc.log \
- "${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}"/depconfig \
- "${RC_LIBDIR}"/softlevel "${RC_LIBDIR}"/nettree \
- "${RC_LIBDIR}"/rc.log \
- "${RC_SVCDIR}" 2>/dev/null
- rm -f "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/depconfig \
- "${RC_LIBDIR}"/softlevel "${RC_LIBDIR}"/nettree \
- "${RC_LIBDIR}"/rc.log
- # 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
-# Most BSD's don't need this as the kernel handles it nicely
-if [ "${RC_UNAME}" = "Linux" ]; then
- ebegin "Remounting remaining filesystems read-only"
- # We need the do_unmount function
- . "${RC_LIBDIR}"/sh/rc-mount.sh
- eindent
- no_umounts_r="/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_r="${no_umounts_r}|${x}"
- done
- if [ "${SIFS}" = "y" ]; then
- IFS=$OIFS
- else
- unset IFS
- fi
- no_umounts_r="${no_umounts_r}|/proc|/proc/.*|/sys|/sys/.*"
- no_umounts_r="^(${no_umounts_r})$"
- fs=
- for x in ${net_fs_list}; do
- fs="${fs}${fs:+|}${x}"
- done
- [ -n "${fs}" ] && fs="^(${fs})$"
- do_unmount "mount -n -o remount,ro" \
- --skip-point-regex "${no_umounts_r}" \
- ${fs:+--skip-fstype-regex} ${fs} --nonetdev
- eoutdent
- eend $?
- unmounted=$?
-fi
-
-if [ ${unmounted} -ne 0 ]; then
- if [ -x /sbin/sulogin ]; then
- ewarn "$1 timeout in 30 seconds"
- sulogin -t 30 /dev/console
- fi
-fi
-
-# Load the final script - not needed on BSD so they should not exist
-[ -e @SYSCONFDIR@/init.d/"$1".sh ] && . @SYSCONFDIR@/init.d/"$1".sh
-
-# Always exit 0 here
-exit 0
diff --git a/init.d/killprocs.in b/init.d/killprocs.in
new file mode 100644
index 0000000..a969d52
--- /dev/null
+++ b/init.d/killprocs.in
@@ -0,0 +1,15 @@
+#!@PREFIX@/sbin/runscript
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+start()
+{
+ ebegin "Terminating remaining processes"
+ killall5 -15
+ sleep 1
+ eend 0
+ ebegin "Killing remaining processes"
+ killall5 -9
+ sleep 1
+ eend 0
+}
diff --git a/init.d/romount.in b/init.d/romount.in
new file mode 100644
index 0000000..d1adaad
--- /dev/null
+++ b/init.d/romount.in
@@ -0,0 +1,43 @@
+#!@PREFIX@/sbin/runscript
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+depend()
+{
+ need killprocs savecache
+ keywords noopenvz novserver
+}
+
+start()
+{
+ # Flush all pending disk writes now
+ sync; sync
+
+ ebegin "Remounting remaining filesystems read-only"
+ # We need the do_unmount function
+ . "${RC_LIBDIR}"/sh/rc-mount.sh
+ eindent
+ local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|${RC_SVCDIR}" x= fs=
+ # RC_NO_UMOUNTS is an env var that can be set by plugins
+ local OIFS=$IFS SIFS=${IFS-y} IFS=$IFS
+ IFS=$IFS:
+ for x in ${no_umounts} ${RC_NO_UMOUNTS}; do
+ m="${m}|${x}"
+ done
+ if [ "${SIFS}" = y ]; then
+ IFS=$OIFS
+ else
+ unset IFS
+ fi
+ m="^(${m})$"
+ fs=
+ for x in ${net_fs_list}; do
+ fs="${fs}${fs:+|}${x}"
+ done
+ [ -n "${fs}" ] && fs="^(${fs})$"
+ do_unmount "mount -n -o remount,ro" \
+ --skip-point-regex "${m}" \
+ ${fs:+--skip-fstype-regex} ${fs} --nonetdev
+ eoutdent
+ eend $?
+}
diff --git a/init.d/savecache.in b/init.d/savecache.in
new file mode 100644
index 0000000..57ed50c
--- /dev/null
+++ b/init.d/savecache.in
@@ -0,0 +1,25 @@
+#!@PREFIX@/sbin/runscript
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+description="Saves the caches OpenRC uses to non volatile storage"
+
+start()
+{
+ ebegin "Saving dependency cache"
+ if [ ! -d "${RC_LIBDIR}"/cache ]; then
+ rm -rf "${RC_LIBDIR}"/cache
+ if ! mkdir "${RC_LIBDIR}"/cache; then
+ eend $?
+ return $?
+ fi
+ fi
+ local save=
+ for x in deptree depconfig softlevel nettree rc.log; do
+ [ -e "${RC_SVCDIR}/${x}" ] && save="${save} ${RC_SVCDIR}/${x}"
+ done
+ if [ -n "${save}" ]; then
+ cp -p ${save} "${RC_LIBDIR}"/cache 2>/devnull
+ fi
+ eend $?
+}