changeset 566:ddb052f876cd

core/rc: move etc services to rc, closes #1666
author David Demelier <markand@malikania.fr>
date Fri, 05 Jul 2019 20:58:54 +0200
parents 15992f10ced3
children 70e87450d08f
files core/etc/etc.sh core/etc/rc.conf core/etc/rc.init core/etc/rc.shutdown core/etc/rc.start core/rc/rc.conf core/rc/rc.init core/rc/rc.sh core/rc/rc.shutdown core/rc/rc.start
diffstat 10 files changed, 276 insertions(+), 252 deletions(-) [+]
line wrap: on
line diff
--- a/core/etc/etc.sh	Fri Jul 05 19:32:51 2019 +0200
+++ b/core/etc/etc.sh	Fri Jul 05 20:58:54 2019 +0200
@@ -25,29 +25,19 @@
             etc/group
             etc/passwd
             etc/profile
-            etc/rc.conf
-            etc/rc.init
-            etc/rc.shutdown
-            etc/rc.start
             etc/securetty
             etc/shadow
             etc/shells"
 
 build()
 {
-	install -d $DESTDIR/etc
-	install -d $DESTDIR/etc/rc.d
-	install -m0755 rc.conf $DESTDIR/etc/rc.conf
-	install -m0755 rc.init $DESTDIR/etc/rc.init
-	install -m0755 rc.shutdown $DESTDIR/etc/rc.shutdown
-	install -m0755 rc.start $DESTDIR/etc/rc.start
-	install -m0600 shadow $DESTDIR/etc
-	install -m0644 fstab $DESTDIR/etc
-	install -m0644 group $DESTDIR/etc
-	install -m0644 issue $DESTDIR/etc
-	install -m0644 passwd $DESTDIR/etc
-	install -m0644 profile $DESTDIR/etc
-	install -m0644 securetty $DESTDIR/etc
-	install -m0644 shells $DESTDIR/etc
+	install -Dm0600 shadow $DESTDIR/etc/shadow
+	install -Dm0644 fstab $DESTDIR/etc/fstab
+	install -Dm0644 group $DESTDIR/etc/group
+	install -Dm0644 issue $DESTDIR/etc/issue
+	install -Dm0644 passwd $DESTDIR/etc/passwd
+	install -Dm0644 profile $DESTDIR/etc/profile
+	install -Dm0644 securetty $DESTDIR/etc/securetty
+	install -Dm0644 shells $DESTDIR/etc/shells
 	ln -sf /proc/self/mounts $DESTDIR/etc/mtab
 }
--- a/core/etc/rc.conf	Fri Jul 05 19:32:51 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#
-# /etc/rc.conf: system configuration
-#
-
-# System hostname.
-HOSTNAME="localhost"
-
-# System timezone.
-TIMEZONE="UTC"
-
-# Services to start at boot.
-SERVICES=""
-
-# Console font and keymap
-FONT=""
-KEYMAP=""
--- a/core/etc/rc.init	Fri Jul 05 19:32:51 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-#!/bin/sh
-#
-# /etc/rc.init: system initialization script
-#
-# Copyright (c) 2019 David Demelier <markand@malikania.fr>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-if [ -f /etc/rc.conf ]; then
-	. /etc/rc.conf
-fi
-
-if [ "${BANNER:-yes}" = "yes" ]; then
-	printf "\nWelcome to \033[33;1mVanilla Linux\033[0m\n\n"
-fi
-
-if [ -n "$HOSTNAME" ] && [ -x /bin/hostname ]; then
-	echo "Setting hostname: $HOSTNAME"
-	/bin/hostname "$HOSTNAME"
-fi
-
-if [ -x /bin/sysctl ]; then
-	echo "Setting kernel parameters."
-	/bin/sysctl -p >/dev/null 2>&1
-fi
-
-if [ -x /bin/mountpoint ]; then
-	echo -n "Mounting filesystems: "
-
-	if ! /bin/mountpoint /dev >/dev/null 2>&1; then
-		/bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1
-		echo -n "/dev "
-	fi
-
-	if ! /bin/mountpoint /proc >/dev/null 2>&1; then
-		/bin/mount -t proc proc /proc >/dev/null 2>&1
-		echo -n "/proc "
-	fi
-
-	if ! /bin/mountpoint /sys >/dev/null 2>&1; then
-		/bin/mount -t sysfs sysfs /sys >/dev/null 2>&1
-		echo -n "/sys "
-	fi
-
-	if ! /bin/mountpoint /run >/dev/null 2>&1; then
-		/bin/mount -t tmpfs tmpfs /run >/dev/null 2>&1
-		echo -n "/run "
-	fi
-
-	echo "done."
-fi
-
-# Clean pid files before starting any services.
-find /var/run -type f -name "*.pid" -delete
-
-#
-# Start a device service. Both eudev and busybox's mdev are supported but only
-# one at a time must be enabled.
-#
-if [ -x /etc/rc.d/udevd ] && [ -x /etc/rc.d/busybox.mdev ]; then
-	echo "Warning: both /etc/rc.d/udevd and /etc/rc.d/busybox.mdev are enabled" 1>&2
-	echo "Warning: using udevd instead" 1>&2
-fi
-
-if [ -x /etc/rc.d/udevd ]; then
-	/etc/rc.d/udevd start
-elif [ -x /etc/rc.d/busybox.mdev ]; then
-	/etc/rc.d/busybox.mdev start
-fi
-
-if [ -x /bin/fsck ]; then
-	# Make sure / is ro in case of initrd.
-	/bin/mount -o remount,ro /
-
-	# If /etc/forcefsck is there, force check.
-	if [ -f /etc/forcefsck ]; then
-		force="-f"
-	fi
-
-	/bin/fsck $force -A -T -C -a >/dev/null 2>&1
-
-	if [ "$?" -gt 1 ]; then
-		echo "* Filesystem check failed"
-		/bin/sulogin -p
-	fi
-fi
-
-# Remount / and enable swap as the system is ready.
-/bin/mount -o remount,rw /
-/bin/swapon -a
-
-# Update shared library caches.
-if [ -x /bin/ldconfig ]; then
-	/bin/ldconfig
-fi
-
-if [ -n "$TIMEZONE" ]; then
-	echo -n "Setting timezone: "
-
-	if [ -f /share/zoneinfo/$TIMEZONE ]; then
-		/bin/ln -sf /share/zoneinfo/$TIMEZONE /etc/localtime
-		echo "$TIMEZONE."
-	else
-		echo "$TIMEZONE not found."
-	fi
-fi
-
-# Console font and keymap.
-if [ -n "$FONT" ] && [ -x /bin/setfont ]; then
-	echo "Setting font: $FONT"
-	/bin/setfont $FONT
-fi
-
-if [ -n "$KEYMAP" ] && [ -x /bin/loadkeys ]; then
-	echo "Setting keymap: $KEYMAP"
-	/bin/loadkeys $KEYMAP
-fi
-
-# Cleanup some files.
-rm -f /etc/forcefsck
--- a/core/etc/rc.shutdown	Fri Jul 05 19:32:51 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-#!/bin/sh
-#
-# /etc/rc.shutdown: reboot and halt script
-#
-# Copyright (c) 2019 David Demelier <markand@malikania.fr>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-if [ -f /etc/rc.conf ]; then
-	source /etc/rc.conf
-fi
-
-echo "Terminating all processes."
-/bin/killall5 -15
-
-echo "Unmounting all filesystems."
-/bin/halt -w
-/bin/swapoff -a
-
-echo "Remounting / read-only"
-/bin/umount -a -d -r -t nosysfs,noproc,nodevtmpfs
-/bin/umount -a -r
-/bin/mount -o remount,ro /
-
-if [ "$1" = "0" ]; then
-	/bin/poweroff -d -f -i
-else
-	/bin/reboot -d -f -i
-fi
--- a/core/etc/rc.start	Fri Jul 05 19:32:51 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#!/bin/sh
-#
-# /etc/rc.start: runlevel control script
-#
-# Copyright (c) 2019 David Demelier <markand@malikania.fr>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-if [ "$#" -ne 1 ]; then
-	echo "usage: $0 runlevel" 1>&2
-	exit 1
-fi
-
-if [ -f /etc/rc.conf ]; then
-	source /etc/rc.conf
-fi
-
-# Start user services requested in rc.conf(5).
-for s in $SERVICES; do
-	#
-	# Services are requested in the form name[:runlevel], if runlevel is
-	# specified the service is started only if the system runlevel is
-	# greater or equal to the request.
-	#
-	name="${s%%:*}"
-	level="${s##*:}"
-
-	# No minimum level, set to requested.
-	if [ "$level" = "$name" ]; then
-		level="$1"
-	fi
-
-	if [ -x /etc/rc.d/$name ] && [ "$level" -le "$1" ]; then
-		/etc/rc.d/$name start
-	fi
-done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/rc/rc.conf	Fri Jul 05 20:58:54 2019 +0200
@@ -0,0 +1,16 @@
+#
+# /etc/rc.conf: system configuration
+#
+
+# System hostname.
+HOSTNAME="localhost"
+
+# System timezone.
+TIMEZONE="UTC"
+
+# Services to start at boot.
+SERVICES=""
+
+# Console font and keymap
+FONT=""
+KEYMAP=""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/rc/rc.init	Fri Jul 05 20:58:54 2019 +0200
@@ -0,0 +1,131 @@
+#!/bin/sh
+#
+# /etc/rc.init: system initialization script
+#
+# Copyright (c) 2019 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+if [ -f /etc/rc.conf ]; then
+	. /etc/rc.conf
+fi
+
+if [ "${BANNER:-yes}" = "yes" ]; then
+	printf "\nWelcome to \033[33;1mVanilla Linux\033[0m\n\n"
+fi
+
+if [ -n "$HOSTNAME" ] && [ -x /bin/hostname ]; then
+	echo "Setting hostname: $HOSTNAME"
+	/bin/hostname "$HOSTNAME"
+fi
+
+if [ -x /bin/sysctl ]; then
+	echo "Setting kernel parameters."
+	/bin/sysctl -p >/dev/null 2>&1
+fi
+
+if [ -x /bin/mountpoint ]; then
+	echo -n "Mounting filesystems: "
+
+	if ! /bin/mountpoint /dev >/dev/null 2>&1; then
+		/bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1
+		echo -n "/dev "
+	fi
+
+	if ! /bin/mountpoint /proc >/dev/null 2>&1; then
+		/bin/mount -t proc proc /proc >/dev/null 2>&1
+		echo -n "/proc "
+	fi
+
+	if ! /bin/mountpoint /sys >/dev/null 2>&1; then
+		/bin/mount -t sysfs sysfs /sys >/dev/null 2>&1
+		echo -n "/sys "
+	fi
+
+	if ! /bin/mountpoint /run >/dev/null 2>&1; then
+		/bin/mount -t tmpfs tmpfs /run >/dev/null 2>&1
+		echo -n "/run "
+	fi
+
+	echo "done."
+fi
+
+# Clean pid files before starting any services.
+find /var/run -type f -name "*.pid" -delete
+
+#
+# Start a device service. Both eudev and busybox's mdev are supported but only
+# one at a time must be enabled.
+#
+if [ -x /etc/rc.d/udevd ] && [ -x /etc/rc.d/busybox.mdev ]; then
+	echo "Warning: both /etc/rc.d/udevd and /etc/rc.d/busybox.mdev are enabled" 1>&2
+	echo "Warning: using udevd instead" 1>&2
+fi
+
+if [ -x /etc/rc.d/udevd ]; then
+	/etc/rc.d/udevd start
+elif [ -x /etc/rc.d/busybox.mdev ]; then
+	/etc/rc.d/busybox.mdev start
+fi
+
+if [ -x /bin/fsck ]; then
+	# Make sure / is ro in case of initrd.
+	/bin/mount -o remount,ro /
+
+	# If /etc/forcefsck is there, force check.
+	if [ -f /etc/forcefsck ]; then
+		force="-f"
+	fi
+
+	/bin/fsck $force -A -T -C -a >/dev/null 2>&1
+
+	if [ "$?" -gt 1 ]; then
+		echo "* Filesystem check failed"
+		/bin/sulogin -p
+	fi
+fi
+
+# Remount / and enable swap as the system is ready.
+/bin/mount -o remount,rw /
+/bin/swapon -a
+
+# Update shared library caches.
+if [ -x /bin/ldconfig ]; then
+	/bin/ldconfig
+fi
+
+if [ -n "$TIMEZONE" ]; then
+	echo -n "Setting timezone: "
+
+	if [ -f /share/zoneinfo/$TIMEZONE ]; then
+		/bin/ln -sf /share/zoneinfo/$TIMEZONE /etc/localtime
+		echo "$TIMEZONE."
+	else
+		echo "$TIMEZONE not found."
+	fi
+fi
+
+# Console font and keymap.
+if [ -n "$FONT" ] && [ -x /bin/setfont ]; then
+	echo "Setting font: $FONT"
+	/bin/setfont $FONT
+fi
+
+if [ -n "$KEYMAP" ] && [ -x /bin/loadkeys ]; then
+	echo "Setting keymap: $KEYMAP"
+	/bin/loadkeys $KEYMAP
+fi
+
+# Cleanup some files.
+rm -f /etc/forcefsck
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/rc/rc.sh	Fri Jul 05 20:58:54 2019 +0200
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# Copyright (c) 2019 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+PKGNAME=rc
+PKGVERSION=0.1
+PKGREVISION=1
+PKGLICENSE="ISC"
+PKGSUMMARY="vanilla init scripts"
+PKGPROTECT="etc/rc.conf
+            etc/rc.init
+            etc/rc.shutdown
+            etc/rc.start"
+
+build()
+{
+	install -Dm0755 rc.conf $DESTDIR/etc/rc.conf
+	install -Dm0755 rc.init $DESTDIR/etc/rc.init
+	install -Dm0755 rc.shutdown $DESTDIR/etc/rc.shutdown
+	install -Dm0755 rc.start $DESTDIR/etc/rc.start
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/rc/rc.shutdown	Fri Jul 05 20:58:54 2019 +0200
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# /etc/rc.shutdown: reboot and halt script
+#
+# Copyright (c) 2019 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+if [ -f /etc/rc.conf ]; then
+	source /etc/rc.conf
+fi
+
+echo "Terminating all processes."
+/bin/killall5 -15
+
+echo "Unmounting all filesystems."
+/bin/halt -w
+/bin/swapoff -a
+
+echo "Remounting / read-only"
+/bin/umount -a -d -r -t nosysfs,noproc,nodevtmpfs
+/bin/umount -a -r
+/bin/mount -o remount,ro /
+
+if [ "$1" = "0" ]; then
+	/bin/poweroff -d -f -i
+else
+	/bin/reboot -d -f -i
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/rc/rc.start	Fri Jul 05 20:58:54 2019 +0200
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# /etc/rc.start: runlevel control script
+#
+# Copyright (c) 2019 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+if [ "$#" -ne 1 ]; then
+	echo "usage: $0 runlevel" 1>&2
+	exit 1
+fi
+
+if [ -f /etc/rc.conf ]; then
+	source /etc/rc.conf
+fi
+
+# Start user services requested in rc.conf(5).
+for s in $SERVICES; do
+	#
+	# Services are requested in the form name[:runlevel], if runlevel is
+	# specified the service is started only if the system runlevel is
+	# greater or equal to the request.
+	#
+	name="${s%%:*}"
+	level="${s##*:}"
+
+	# No minimum level, set to requested.
+	if [ "$level" = "$name" ]; then
+		level="$1"
+	fi
+
+	if [ -x /etc/rc.d/$name ] && [ "$level" -le "$1" ]; then
+		/etc/rc.d/$name start
+	fi
+done