summaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-10-10 08:37:21 +0000
committerRoy Marples <roy@marples.name>2008-10-10 08:37:21 +0000
commitd6da8e8c48feb8faf9287fc86fbbf0890c37a87c (patch)
treee6cdf21f0f3a3270b705fe14b876f92b14b38dbf /init.d
parent247766695cd7c5e8d83dff72f7eb7e6578bf57b8 (diff)
downloadopenrc-d6da8e8c48feb8faf9287fc86fbbf0890c37a87c.tar.gz
openrc-d6da8e8c48feb8faf9287fc86fbbf0890c37a87c.tar.bz2
openrc-d6da8e8c48feb8faf9287fc86fbbf0890c37a87c.tar.xz
sysinit is now a real runlevel that handles things like udev, dmesg and
mounting various bits in /dev and /sys. init.sh JUST mounts /lib/rc/init.d (and /proc for Linux systems) To make development of this easier we now return an empty RC_STRINGLIST instead of a NULL for empty things. If you don't have a udev init script installed, don't reboot your box OR roll back to an older OpenRC version.
Diffstat (limited to 'init.d')
-rw-r--r--init.d/Makefile.Linux4
-rw-r--r--init.d/devfs.in36
-rw-r--r--init.d/dmesg.in17
-rw-r--r--init.d/fsck.in2
-rw-r--r--init.d/procfs.in23
-rw-r--r--init.d/sysfs.in63
6 files changed, 121 insertions, 24 deletions
diff --git a/init.d/Makefile.Linux b/init.d/Makefile.Linux
index ae9e6ba..be519c8 100644
--- a/init.d/Makefile.Linux
+++ b/init.d/Makefile.Linux
@@ -1,7 +1,7 @@
NET_LO= net.lo
-SRCS+= hwclock.in consolefont.in keymaps.in modules.in mtab.in numlock.in \
- procfs.in termencoding.in
+SRCS+= devfs.in dmesg.in hwclock.in consolefont.in keymaps.in modules.in \
+ mtab.in numlock.in procfs.in sysfs.in termencoding.in
.SUFFIXES: .Linux.in
.Linux.in:
diff --git a/init.d/devfs.in b/init.d/devfs.in
new file mode 100644
index 0000000..2e140f0
--- /dev/null
+++ b/init.d/devfs.in
@@ -0,0 +1,36 @@
+#!@PREFIX@/sbin/runscript
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+description="Mount system critical filesystems in /dev."
+
+depend() {
+ use dev
+ keyword noprefix
+}
+
+start() {
+ # Mount required stuff as user may not have then in /etc/fstab
+ for x in \
+ "devpts /dev/pts 0755 ,gid=5,mode=0620 devpts" \
+ "tmpfs /dev/shm 1777 ,nodev shm" \
+ ; do
+ set -- ${x}
+ grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue
+ mountinfo -q "$2" && continue
+
+ if [ ! -d "$2" ]; then
+ mkdir -m "$3" -p "$2" >/dev/null 2>&1 || \
+ ewarn "Could not create $2!"
+ fi
+
+ if [ -d "$2" ]; then
+ ebegin "Mounting $2"
+ if ! fstabinfo --mount "$2"; then
+ mount -n -t "$1" -o noexec,nosuid"$4" "$5" "$2"
+ fi
+ eend $?
+ fi
+ done
+ return 0
+}
diff --git a/init.d/dmesg.in b/init.d/dmesg.in
new file mode 100644
index 0000000..6aad0e2
--- /dev/null
+++ b/init.d/dmesg.in
@@ -0,0 +1,17 @@
+#!@PREFIX@/sbin/runscript
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+description="Set the dmesg level for a cleaner boot"
+
+depend()
+{
+ before dev modules
+}
+
+start()
+{
+ if [ -n "${dmesg_level}" ]; then
+ dmesg -n"${dmesg_level}"
+ fi
+}
diff --git a/init.d/fsck.in b/init.d/fsck.in
index ee2acdc..5f7099a 100644
--- a/init.d/fsck.in
+++ b/init.d/fsck.in
@@ -8,7 +8,7 @@ _IFS="
depend()
{
- after clock modules
+ use dev clock modules
keyword nojail noopenvz noprefix notimeout novserver
}
diff --git a/init.d/procfs.in b/init.d/procfs.in
index 410a6e3..b6dfbb6 100644
--- a/init.d/procfs.in
+++ b/init.d/procfs.in
@@ -6,6 +6,7 @@ description="Mounts misc filesystems in /proc."
depend()
{
+ use devfs
need localmount
keyword noopenvz noprefix novserver
}
@@ -39,7 +40,7 @@ start()
# 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"
+ ebegin "Mounting NFS filesystem"
mount -t nfsd -o nodev,noexec,nosuid \
nfsd /proc/fs/nfsd
eend $?
@@ -56,26 +57,6 @@ start()
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 -o nodev,noexec,nosuid \
- securityfs /sys/kernel/security
- 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 -o nodev,noexec,nosuid \
- debugfs /sys/kernel/debug
- eend $?
- fi
- fi
-
# Setup Kernel Support for SELinux
if [ -d /selinux ] && ! mountinfo -q /selinux; then
if grep -qs selinuxfs /proc/filesystems; then
diff --git a/init.d/sysfs.in b/init.d/sysfs.in
new file mode 100644
index 0000000..e711aee
--- /dev/null
+++ b/init.d/sysfs.in
@@ -0,0 +1,63 @@
+#!@PREFIX@/sbin/runscript
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+description="Mount the sys filesystem."
+
+depend()
+{
+ keyword noprefix
+}
+
+mount_sys()
+{
+ grep -Eq "[[:space:]]+sysfs$" /proc/filesystems || return 1
+ mountinfo -q /sys && return 0
+
+ if [ ! -d /sys ]; then
+ if ! mkdir -m 0755 /sys; then
+ ewarn "Could not create /sys!"
+ return 1
+ fi
+ fi
+
+ ebegin "Mounting /sys"
+ if ! fstabinfo --mount /sys; then
+ mount -n -t sysfs -o noexec,nosuid,nodev sysfs /sys
+ fi
+ eend $?
+}
+
+mount_misc()
+{
+ # 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 -o nodev,noexec,nosuid \
+ securityfs /sys/kernel/security
+ 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 -o nodev,noexec,nosuid \
+ debugfs /sys/kernel/debug
+ eend $?
+ fi
+ fi
+}
+
+start()
+{
+ local retval
+ mount_sys
+ retval=$?
+ if [ ${retval} -eq 0 ]; then
+ mount_misc
+ fi
+ return ${retval}
+}