summaryrefslogtreecommitdiffstats
path: root/src.etc/init.d
diff options
context:
space:
mode:
Diffstat (limited to 'src.etc/init.d')
-rwxr-xr-xsrc.etc/init.d/hostname27
-rwxr-xr-xsrc.etc/init.d/httpd33
-rwxr-xr-xsrc.etc/init.d/klogd32
-rwxr-xr-xsrc.etc/init.d/mdev61
-rwxr-xr-xsrc.etc/init.d/mountall21
-rwxr-xr-xsrc.etc/init.d/mountdevsubfs36
-rwxr-xr-xsrc.etc/init.d/mountkernfs39
-rwxr-xr-xsrc.etc/init.d/mounttmpfs33
-rwxr-xr-xsrc.etc/init.d/networking27
-rwxr-xr-xsrc.etc/init.d/rc39
-rwxr-xr-xsrc.etc/init.d/rc.local10
-rwxr-xr-xsrc.etc/init.d/syslog32
-rwxr-xr-xsrc.etc/init.d/telnetd33
13 files changed, 148 insertions, 275 deletions
diff --git a/src.etc/init.d/hostname b/src.etc/init.d/hostname
index f64407d..2a6ffac 100755
--- a/src.etc/init.d/hostname
+++ b/src.etc/init.d/hostname
@@ -1,24 +1,13 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
start()
{
- [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)"
- [ -z "${HOSTNAME}" ] && HOSTNAME="$(hostname)"
- [ -z "${HOSTNAME}" ] && HOSTNAME='localhost'
+ local hostname=
- printf 'Setting hostname to %s... ' "${HOSTNAME}"
- hostname "${HOSTNAME}"
- printf 'done.\n'
-}
+ [ -f /etc/hostname ] && hostname="$(cat /etc/hostname)"
+ [ -z "${hostname}" ] && hostname="$(hostname)"
+ [ -z "${hostname}" ] && hostname='localhost'
-case "${1}" in
- start)
- start
- ;;
- stop)
- ;;
- *)
- printf 'Usage: %s {start|stop}\n' "${0}" >&2
- exit 1
- ;;
-esac
+ log 'Setting hostname to %s' "${hostname}"
+ hostname "${hostname}"
+}
diff --git a/src.etc/init.d/httpd b/src.etc/init.d/httpd
index 1dc0d28..c26e151 100755
--- a/src.etc/init.d/httpd
+++ b/src.etc/init.d/httpd
@@ -1,32 +1,17 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
+
+START='50'
+STOP='60'
start()
{
- printf 'Starting httpd... '
- start-stop-daemon -S -q -n httpd -x /usr/sbin/httpd -- -h /var/www
- printf 'done.\n'
+ log 'Starting httpd'
+ start-stop-daemon -S -q -p /var/run/httpd.pid -m \
+ -x /usr/sbin/httpd -b -- -f -h /var/www
}
stop()
{
- printf 'Stopping httpd... '
- start-stop-daemon -K -q -n httpd
- printf 'done.\n'
+ log 'Stopping httpd'
+ start-stop-daemon -K -q -p /var/run/httpd.pid
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- printf 'Usage: %s {start|stop|restart}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/klogd b/src.etc/init.d/klogd
index 5a00ab9..20b7ac3 100755
--- a/src.etc/init.d/klogd
+++ b/src.etc/init.d/klogd
@@ -1,32 +1,16 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
+
+START='40'
+STOP='70'
start()
{
- printf 'Starting klogd... '
- start-stop-daemon -S -q -n klogd -x /sbin/klogd
- printf 'done.\n'
+ log 'Starting klogd'
+ start-stop-daemon -S -q -x /sbin/klogd
}
stop()
{
- printf 'Stopping klogd... '
- start-stop-daemon -K -q -n klogd
- printf 'done.\n'
+ log 'Stopping klogd'
+ start-stop-daemon -K -q -p /var/run/klogd.pid
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- printf 'Usage: %s {start|stop|restart}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/mdev b/src.etc/init.d/mdev
index 8052c3b..81d004a 100755
--- a/src.etc/init.d/mdev
+++ b/src.etc/init.d/mdev
@@ -1,53 +1,38 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
start()
{
- printf 'Enabling device hotplugging... '
-
- if ! mount | grep -Fq ' /dev '; then
- mount -t tmpfs -o noexec,nosuid,mode=0755 tmpfs /dev
+ log 'Enabling device hotplugging'
+ if ! [ -e /dev/null ]; then
+ mount -t tmpfs -o noexec,nosuid,mode=0755 tmpfs /dev || \
+ return ${?}
+ if [ -e /proc/sys/kernel/hotplug ]; then
+ printf '/sbin/mdev\n' >/proc/sys/kernel/hotplug
+ fi
+ mdev -s
fi
-
- printf '/sbin/mdev\n' >/proc/sys/kernel/hotplug
- mdev -s
-
- printf 'done.\n'
}
stop()
{
- printf 'Disabling device hotplugging... '
-
- printf '\n' >/proc/sys/kernel/hotplug
-
- if mount | grep -Fq ' /dev '; then
- umount /dev
+ log 'Disabling device hotplugging'
+ if [ -e /proc/sys/kernel/hotplug ]; then
+ printf '\n' >/proc/sys/kernel/hotplug
+ fi
+ if [ -e /dev/null ]; then
+ umount /dev || return ${?}
fi
-
- printf 'done.\n'
}
restart()
{
- printf 'Recanning devices... '
-
+ log 'Recanning devices'
+ if ! [ -e /dev/null ]; then
+ mount -t tmpfs -o noexec,nosuid,mode=0755 tmpfs /dev || \
+ return ${?}
+ if [ -e /proc/sys/kernel/hotplug ]; then
+ printf '/sbin/mdev\n' >/proc/sys/kernel/hotplug
+ fi
+ fi
mdev -s
-
- printf 'done.\n'
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- *)
- printf 'Usage: %s {start|stop|restart}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/mountall b/src.etc/init.d/mountall
index 4882427..8515157 100755
--- a/src.etc/init.d/mountall
+++ b/src.etc/init.d/mountall
@@ -1,20 +1,9 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
start()
{
- printf 'Mounting file systems... '
- [ -r /etc/fstab ] && mount -a
- printf 'done.\n'
+ log 'Mounting file systems'
+ if [ -r /etc/fstab ]; then
+ mount -a
+ fi
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- ;;
- *)
- printf 'Usage: %s {start|stop}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/mountdevsubfs b/src.etc/init.d/mountdevsubfs
index 5ef7235..03c13e0 100755
--- a/src.etc/init.d/mountdevsubfs
+++ b/src.etc/init.d/mountdevsubfs
@@ -1,41 +1,21 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
start()
{
- printf 'Mounting device file systems... '
-
+ log 'Mounting device file systems'
[ -d /dev/pts ] || mkdir -m 0755 /dev/pts
- if ! mount | grep -Fq ' /dev/pts '; then
- mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts
+ if ! [ -e /dev/pts/ptmx ]; then
+ mount -t devpts -o noexec,nosuid,gid=5,mode=0620 \
+ devpts /dev/pts || return ${?}
fi
-
ln -sf /run/shm /dev/shm
-
- printf 'done.\n'
}
stop()
{
- printf 'Unmounting device file systems... '
-
- if mount | grep -Fq ' /dev/pts '; then
- umount /dev/pts
+ log 'Unmounting device file systems'
+ if [ -e /dev/pts/ptmx ]; then
+ umount /dev/pts || return ${?}
fi
-
rm -f /dev/shm
-
- printf 'done.\n'
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- *)
- printf 'Usage: %s {start|stop}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/mountkernfs b/src.etc/init.d/mountkernfs
index 8a701a8..83d5179 100755
--- a/src.etc/init.d/mountkernfs
+++ b/src.etc/init.d/mountkernfs
@@ -1,30 +1,25 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
start()
{
- printf 'Mounting kernel virtual file systems... '
- [ ! -e /proc/mounts ] && mount -t proc -o nodev,noexec,nosuid proc /proc
- [ ! -e /sys/kernel ] && mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
- printf 'done.\n'
+ log 'Mounting kernel virtual file systems'
+ if ! [ -e /proc/mounts ]; then
+ mount -t proc -o nodev,noexec,nosuid proc /proc || \
+ return ${?}
+ fi
+ if ! [ -e /sys/kernel ]; then
+ mount -t sysfs -o nodev,noexec,nosuid sysfs /sys || \
+ return ${?}
+ fi
}
stop()
{
- printf 'Unmounting kernel virtual file systems... '
- [ -e /proc/mounts ] && umount /proc
- [ -e /sys/kernel ] && umount /sys
- printf 'done.\n'
+ log 'Unmounting kernel virtual file systems'
+ if [ -e /proc/mounts ]; then
+ umount /proc || return ${?}
+ fi
+ if [ -e /sys/kernel ]; then
+ umount /sys || return ${?}
+ fi
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- *)
- printf 'Usage: %s {start|stop}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/mounttmpfs b/src.etc/init.d/mounttmpfs
index 96b398e..269ba74 100755
--- a/src.etc/init.d/mounttmpfs
+++ b/src.etc/init.d/mounttmpfs
@@ -1,47 +1,26 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
start()
{
- printf 'Mounting temporary file systems... '
-
+ log 'Mounting temporary file systems'
if ! mount | grep -Fq ' /run '; then
- mount -t tmpfs -o nodev,noexec,nosuid,mode=0755 tmpfs /run
+ mount -t tmpfs -o nodev,noexec,nosuid,mode=0755 \
+ tmpfs /run
fi
-
[ -d /run/lock ] || mkdir -m 1777 /run/lock
[ -d /run/shm ] || mkdir -m 1777 /run/shm
-
if ! mount | grep -Fq ' /tmp '; then
mount -t tmpfs -o nodev,nosuid,mode=1777 tmpfs /tmp
fi
-
- printf 'done.\n'
}
stop()
{
- printf 'Unmounting temporary file systems... '
-
+ log 'Unmounting temporary file systems'
if mount | grep -Fq ' /run '; then
umount /run
fi
-
if mount | grep -Fq ' /tmp '; then
- umount /run
+ umount /tmp
fi
-
- printf 'done.\n'
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- *)
- printf 'Usage: %s {start|stop}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/networking b/src.etc/init.d/networking
index 66967f9..f53899f 100755
--- a/src.etc/init.d/networking
+++ b/src.etc/init.d/networking
@@ -1,40 +1,21 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
start()
{
- printf 'Configuring network interfaces... '
+ log 'Configuring network interfaces'
ifdown -a >/dev/null 2>&1
ifup -a
- printf 'done.\n'
}
stop()
{
- printf 'Deconfiguring network interfaces... '
+ log 'Deconfiguring network interfaces'
ifdown -a
- printf 'done.\n'
}
restart()
{
- printf 'Reconfiguring network interfaces... '
+ log 'Reconfiguring network interfaces'
ifdown -a
ifup -a
- printf 'done.\n'
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- *)
- printf 'Usage: %s {start|stop|restart}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/rc b/src.etc/init.d/rc
index 0db7c8d..e6985dd 100755
--- a/src.etc/init.d/rc
+++ b/src.etc/init.d/rc
@@ -3,11 +3,33 @@
# /etc/init.d/rc
# Executes init scripts on init and shutdown.
#
-# Copyright (C) 2012 Patrick "P. J." McDermott
+# Copyright (C) 2012, 2014 Patrick "P. J." McDermott
+#
# This file may be reproduced, distributed, modified, and otherwise dealt in
-# under the terms of the Expat/MIT License.
+# under the terms of the Expat License.
+
+LF='
+'
+
+[ -x /usr/bin/logger ] && logger='logger -p 6 -t sysinit' || logger=cat
+
+# Buffer log lines until syslogd is running.
+log()
+{
+ local line=
+ local buf=
-[ -x /usr/bin/logger ] && logger='logger -s -p 6 -t sysinit' || logger=cat
+ while read -r line; do
+ buf="${buf}${line}${LF}"
+ if [ -f /var/run/syslogd.pid ]; then
+ printf '%s' "${buf}" | ${logger}
+ exec ${logger}
+ fi
+ done
+ if [ -f /var/run/syslogd.pid ]; then
+ printf '%s' "${buf}" | ${logger}
+ fi
+}
level=${0#*/rc}
case ${level} in
@@ -22,6 +44,11 @@ case ${level} in
;;
esac
-for i in /etc/rc.d/${level}*; do
- [ -x "${i}" ] && "${i}" ${action} 2>&1
-done | ${logger}
+{
+ for i in /etc/rc.d/${level}[0-1]*; do
+ [ -x "${i}" ] && "${i}" ${action} 2>&1
+ done
+ for i in /etc/rc.d/${level}[2-9]*; do
+ [ -x "${i}" ] && "${i}" ${action} 2>&1
+ done
+} | log
diff --git a/src.etc/init.d/rc.local b/src.etc/init.d/rc.local
new file mode 100755
index 0000000..167ebdc
--- /dev/null
+++ b/src.etc/init.d/rc.local
@@ -0,0 +1,10 @@
+#!/bin/sh /etc/rc.common
+
+START='90'
+
+start()
+{
+ [ -x /etc/rc.local ] || return 0
+ log 'Running local boot scripts'
+ /etc/rc.local
+}
diff --git a/src.etc/init.d/syslog b/src.etc/init.d/syslog
index 7d274ce..32e4bd6 100755
--- a/src.etc/init.d/syslog
+++ b/src.etc/init.d/syslog
@@ -1,35 +1,19 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
SYSLOG_ROTATE_SIZE=65536
+START='40'
+STOP='70'
+
start()
{
- printf 'Starting syslog... '
- start-stop-daemon -S -q -n syslogd -x /sbin/syslogd -- \
+ log 'Starting syslog'
+ start-stop-daemon -S -q -x /sbin/syslogd -- \
-s "${SYSLOG_ROTATE_SIZE}"
- printf 'done.\n'
}
stop()
{
- printf 'Stopping syslog... '
- start-stop-daemon -K -q -n syslogd
- printf 'done.\n'
+ log 'Stopping syslog'
+ start-stop-daemon -K -q -p /var/run/syslogd.pid
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- printf 'Usage: %s {start|stop|restart}\n' "${0}" >&2
- exit 1
- ;;
-esac
diff --git a/src.etc/init.d/telnetd b/src.etc/init.d/telnetd
index 0f51046..98f668d 100755
--- a/src.etc/init.d/telnetd
+++ b/src.etc/init.d/telnetd
@@ -1,32 +1,17 @@
-#!/bin/sh
+#!/bin/sh /etc/rc.common
+
+START='50'
+STOP='60'
start()
{
- printf 'Starting telnetd... '
- start-stop-daemon -S -q -n telnetd -x /usr/sbin/telnetd
- printf 'done.\n'
+ log 'Starting telnetd'
+ start-stop-daemon -S -q -p /var/run/telnetd.pid -m \
+ -x /usr/sbin/telnetd -b -- -F
}
stop()
{
- printf 'Stopping telnetd... '
- start-stop-daemon -K -q -n telnetd
- printf 'done.\n'
+ log 'Stopping telnetd'
+ start-stop-daemon -K -q -p /var/run/telnetd.pid
}
-
-case "${1}" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- printf 'Usage: %s {start|stop|restart}\n' "${0}" >&2
- exit 1
- ;;
-esac