summaryrefslogtreecommitdiff
path: root/package/initscripts
diff options
context:
space:
mode:
authorMaxime Hadjinlian <maxime.hadjinlian@gmail.com>2015-07-13 23:00:08 +0200
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2015-07-14 01:51:52 +0200
commit89d39fc7a392530be043bac541ade0bef746edb6 (patch)
tree7ca4a2f38d7153867b049ffaec4c34a03461cdfb /package/initscripts
parent4d1a9d8cd8f4722ecb059552ebb837eef53f7a95 (diff)
initscripts: new package
The folder init.d is currently installed by default since it's part of our skeleton. This patch creates a package out of it and make busybox/sysvinit depends on it. This way, if you chose another init, you don't end up with a useless init.d folder. [Thomas: - make the initscripts package selectable via a hidden bool - remove some unneeded changes in sysvinit.mk.] Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'package/initscripts')
-rw-r--r--package/initscripts/Config.in4
-rwxr-xr-xpackage/initscripts/init.d/S20urandom51
-rwxr-xr-xpackage/initscripts/init.d/S40network28
-rwxr-xr-xpackage/initscripts/init.d/rcK27
-rwxr-xr-xpackage/initscripts/init.d/rcS27
-rw-r--r--package/initscripts/initscripts.mk15
6 files changed, 152 insertions, 0 deletions
diff --git a/package/initscripts/Config.in b/package/initscripts/Config.in
new file mode 100644
index 000000000..82cbd5c67
--- /dev/null
+++ b/package/initscripts/Config.in
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_INITSCRIPTS
+ bool
+ help
+ The basics startup scripts for both SysV and Busybox
diff --git a/package/initscripts/init.d/S20urandom b/package/initscripts/init.d/S20urandom
new file mode 100755
index 000000000..36277ba61
--- /dev/null
+++ b/package/initscripts/init.d/S20urandom
@@ -0,0 +1,51 @@
+#! /bin/sh
+#
+# urandom This script saves the random seed between reboots.
+# It is called from the boot, halt and reboot scripts.
+#
+# Version: @(#)urandom 1.33 22-Jun-1998 miquels@cistron.nl
+#
+
+[ -c /dev/urandom ] || exit 0
+#. /etc/default/rcS
+
+case "$1" in
+ start|"")
+ # check for read only file system
+ if ! touch /etc/random-seed 2>/dev/null
+ then
+ echo "read-only file system detected...done"
+ exit
+ fi
+ if [ "$VERBOSE" != no ]
+ then
+ echo -n "Initializing random number generator... "
+ fi
+ # Load and then save 512 bytes,
+ # which is the size of the entropy pool
+ cat /etc/random-seed >/dev/urandom
+ rm -f /etc/random-seed
+ umask 077
+ dd if=/dev/urandom of=/etc/random-seed count=1 \
+ >/dev/null 2>&1 || echo "urandom start: failed."
+ umask 022
+ [ "$VERBOSE" != no ] && echo "done."
+ ;;
+ stop)
+ if ! touch /etc/random-seed 2>/dev/null
+ then
+ exit
+ fi
+ # Carry a random seed from shut-down to start-up;
+ # see documentation in linux/drivers/char/random.c
+ [ "$VERBOSE" != no ] && echo -n "Saving random seed... "
+ umask 077
+ dd if=/dev/urandom of=/etc/random-seed count=1 \
+ >/dev/null 2>&1 || echo "urandom stop: failed."
+ [ "$VERBOSE" != no ] && echo "done."
+ ;;
+ *)
+ echo "Usage: urandom {start|stop}" >&2
+ exit 1
+ ;;
+esac
diff --git a/package/initscripts/init.d/S40network b/package/initscripts/init.d/S40network
new file mode 100755
index 000000000..bfdd491e9
--- /dev/null
+++ b/package/initscripts/init.d/S40network
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# Start the network....
+#
+
+# Debian ifupdown needs the /run/network lock directory
+mkdir -p /run/network
+
+case "$1" in
+ start)
+ echo "Starting network..."
+ /sbin/ifup -a
+ ;;
+ stop)
+ echo -n "Stopping network..."
+ /sbin/ifdown -a
+ ;;
+ restart|reload)
+ "$0" stop
+ "$0" start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit $?
+
diff --git a/package/initscripts/init.d/rcK b/package/initscripts/init.d/rcK
new file mode 100755
index 000000000..59e9c54ff
--- /dev/null
+++ b/package/initscripts/init.d/rcK
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+
+# Stop all init scripts in /etc/init.d
+# executing them in reversed numerical order.
+#
+for i in $(ls -r /etc/init.d/S??*) ;do
+
+ # Ignore dangling symlinks (if any).
+ [ ! -f "$i" ] && continue
+
+ case "$i" in
+ *.sh)
+ # Source shell script for speed.
+ (
+ trap - INT QUIT TSTP
+ set stop
+ . $i
+ )
+ ;;
+ *)
+ # No sh extension, so fork subprocess.
+ $i stop
+ ;;
+ esac
+done
+
diff --git a/package/initscripts/init.d/rcS b/package/initscripts/init.d/rcS
new file mode 100755
index 000000000..de411534d
--- /dev/null
+++ b/package/initscripts/init.d/rcS
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+
+# Start all init scripts in /etc/init.d
+# executing them in numerical order.
+#
+for i in /etc/init.d/S??* ;do
+
+ # Ignore dangling symlinks (if any).
+ [ ! -f "$i" ] && continue
+
+ case "$i" in
+ *.sh)
+ # Source shell script for speed.
+ (
+ trap - INT QUIT TSTP
+ set start
+ . $i
+ )
+ ;;
+ *)
+ # No sh extension, so fork subprocess.
+ $i start
+ ;;
+ esac
+done
+
diff --git a/package/initscripts/initscripts.mk b/package/initscripts/initscripts.mk
new file mode 100644
index 000000000..a5d8db7e9
--- /dev/null
+++ b/package/initscripts/initscripts.mk
@@ -0,0 +1,15 @@
+################################################################################
+#
+# initscripts
+#
+################################################################################
+
+# source included in buildroot
+INITSCRIPTS_SOURCE =
+
+define INITSCRIPTS_INSTALL_TARGET_CMDS
+ mkdir -p $(TARGET_DIR)/etc/init.d
+ $(INSTALL) -D -m 0755 package/initscripts/init.d/* $(TARGET_DIR)/etc/init.d/
+endef
+
+$(eval $(generic-package))