aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-11-03 15:31:01 +0000
committerRoy Marples <roy@marples.name>2008-11-03 15:31:01 +0000
commit0af7d5bc204cd6b7d03f22aacf4072c5f526c0ee (patch)
treeaa819c4140f8c34bd3814ae5894a8b6214fff914 /sh
parent895c4f41492199d6aee75bb6c5a935134d67c29e (diff)
Add a new shutdown runlevel, Gentoo #224537.
Split halt.sh into halt, killprocs, romount and savecache services. The reboot runlevel is removed but mapped to shutdown. The halt script should be moved to the sysvinit package.
Diffstat (limited to 'sh')
-rw-r--r--sh/init-common-post.sh.in12
-rw-r--r--sh/init.sh.BSD.in21
-rw-r--r--sh/init.sh.Linux.in30
3 files changed, 11 insertions, 52 deletions
diff --git a/sh/init-common-post.sh.in b/sh/init-common-post.sh.in
index 2b1641df..aa264aa3 100644
--- a/sh/init-common-post.sh.in
+++ b/sh/init-common-post.sh.in
@@ -9,17 +9,15 @@ retval=0
RC_SVCDIR=${RC_SVCDIR:-/@LIB@/rc/init.d}
if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then
rmdir "${RC_SVCDIR}/.test.$$"
- for x in ${RC_SVCDIR}/*; do
- [ -e "${x}" ] || continue
- case ${x##*/} in
- depconfig|deptree|ksoftlevel|rc.log);;
- *) rm -rf "${x}";;
- esac
- done
+ rm -rf "${RC_SVCDIR}"/*
else
mount_svcdir
retval=$?
fi
+if [ -e "${RC_LIBDIR}"/cache/deptree ]; then
+ cp -p "${RC_LIBDIR}"/cache/* "${RC_SVCDIR}" 2>/dev/null
+fi
+
echo "sysinit" > "${RC_SVCDIR}/softlevel"
exit ${retval}
diff --git a/sh/init.sh.BSD.in b/sh/init.sh.BSD.in
index dbff7368..652a3de2 100644
--- a/sh/init.sh.BSD.in
+++ b/sh/init.sh.BSD.in
@@ -10,18 +10,6 @@
# FreeBSD-7 supports tmpfs now :)
mount_svcdir()
{
- local dotmp=false release=false retval=0
- if [ -e "${RC_SVCDIR}"/deptree ]; then
- dotmp=true
- if ! mount -t tmpfs none "${RC_LIBDIR}"/tmp 2>/dev/null; then
- mdconfig -a -t malloc -s 1m -u 1
- newfs /dev/md1
- mount /dev/md1 "${RC_LIBDIR}"/tmp
- release=true
- fi
- cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
- "${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
- fi
if ! fstabinfo --mount "${RC_SVCDIR}"; then
if ! mount -t tmpfs -o rw,noexec,nosuid none "${RC_SVCDIR}" 2>/dev/null; then
mdconfig -a -t malloc -s "${rc_svcsize:-1024}"k -u 0
@@ -29,15 +17,6 @@ mount_svcdir()
mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}"
fi
fi
- retval=$?
- if ${dotmp}; then
- cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
- "${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
- umount "${RC_LIBDIR}"/tmp
- ${release} && mdconfig -d -u 1
- fi
-
- return ${retval}
}
. "${RC_LIBDIR}"/sh/functions.sh
diff --git a/sh/init.sh.Linux.in b/sh/init.sh.Linux.in
index 6d99d49e..f38fe4e0 100644
--- a/sh/init.sh.Linux.in
+++ b/sh/init.sh.Linux.in
@@ -3,14 +3,13 @@
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
-# This basically mounts $RC_SVCDIR as a ramdisk, but preserving its content
-# which allows us to store service state and generate dependencies if needed.
+# This basically mounts $RC_SVCDIR as a ramdisk.
# The tricky part is finding something our kernel supports
# tmpfs and ramfs are easy, so force one or the other.
mount_svcdir()
{
local fs= fsopts="-o rw,noexec,nodev,nosuid"
- local devdir="rc-svcdir" devtmp="none" x=
+ local devdir="rc-svcdir" x=
local svcsize=${rc_svcsize:-1024}
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
@@ -19,41 +18,24 @@ mount_svcdir()
elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
fs="ramfs"
# ramfs has no special options
- elif [ -e /dev/ram0 -a -e /dev/ram1 ] \
+ elif [ -e /dev/ram0 ] \
&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then
devdir="/dev/ram0"
- devtmp="/dev/ram1"
fs="ext2"
- for x in ${devdir} ${devtmp}; do
- dd if=/dev/zero of="${x}" bs=1k count="${svcsize}"
- mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}"
- done
+ dd if=/dev/zero of="${devdir}" bs=1k count="${svcsize}"
+ mkfs -t "${fs}" -i 1024 -vm0 "${devdir}" "${svcsize}"
else
echo
- eerror "OpenRC requires tmpfs, ramfs or 2 ramdisks + ext2"
+ eerror "OpenRC requires tmpfs, ramfs or a ramdisk + ext2"
eerror "compiled into the kernel"
echo
return 1
fi
- local dotmp=false
- if [ -e "${RC_SVCDIR}"/deptree ]; then
- dotmp=true
- mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp
- cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
- "${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
- fi
-
# If we have no entry in fstab for $RC_SVCDIR, provide our own
if ! fstabinfo --mount "${RC_SVCDIR}"; then
mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}"
fi
-
- if ${dotmp}; then
- cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
- "${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
- umount -n "${RC_LIBDIR}"/tmp
- fi
}
. /etc/init.d/functions.sh