changeset 629:dbd752e285f6

core/rc: stay POSIX and support busybox
author David Demelier <markand@malikania.fr>
date Tue, 23 Jul 2019 22:56:00 +0200
parents 9a02e6680708
children 58211c615a8c
files core/rc/rc.init core/rc/rc.shutdown core/rc/rc.start
diffstat 3 files changed, 32 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/core/rc/rc.init	Tue Jul 23 22:35:00 2019 +0200
+++ b/core/rc/rc.init	Tue Jul 23 22:56:00 2019 +0200
@@ -27,31 +27,31 @@
 
 if [ -n "$HOSTNAME" ]; then
 	echo "Setting hostname: $HOSTNAME"
-	/bin/hostname "$HOSTNAME"
+	hostname "$HOSTNAME"
 fi
 
 echo "Setting kernel parameters"
-/bin/sysctl -p >/dev/null 2>&1
+sysctl -p >/dev/null 2>&1
 
 echo -n "Mounting filesystems: "
 
-if ! /bin/mountpoint /dev >/dev/null 2>&1; then
-	/bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1
+if ! mountpoint /dev >/dev/null 2>&1; then
+	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
+if ! mountpoint /proc >/dev/null 2>&1; then
+	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
+if ! mountpoint /sys >/dev/null 2>&1; then
+	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
+if ! mountpoint /run >/dev/null 2>&1; then
+	mount -t tmpfs tmpfs /run >/dev/null 2>&1
 	echo -n "/run "
 fi
 
@@ -76,33 +76,33 @@
 fi
 
 # Make sure / is ro in case of initrd.
-/bin/mount -o remount,ro /
+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
+fsck $force -A -T >/dev/null 2>&1
 
 if [ "$?" -gt 1 ]; then
 	echo "* Filesystem check failed"
-	/bin/sulogin -p
-	/bin/reboot
+	sulogin
+	reboot
 fi
 
 # Remount / and enable swap as the system is ready.
-/bin/mount -o remount,rw /
-/bin/swapon -a
+mount -o remount,rw /
+swapon -a
 
 # Update shared library caches.
-/bin/ldconfig
+ldconfig
 
 if [ -n "$TIMEZONE" ] && [ "$TIMEZONE" != "UTC" ]; then
 	echo -n "Setting timezone: "
 
 	if [ -f /share/zoneinfo/$TIMEZONE ]; then
-		/bin/ln -sf /share/zoneinfo/$TIMEZONE /etc/localtime
+		ln -sf /share/zoneinfo/$TIMEZONE /etc/localtime
 		echo "$TIMEZONE."
 	else
 		echo "$TIMEZONE not found"
@@ -112,31 +112,13 @@
 # Console font and keymap.
 if [ -n "$FONT" ]; then
 	echo "Setting font: $FONT"
-	/bin/setfont $FONT
+	setfont $FONT
 fi
 
 if [ -n "$KEYMAP" ]; then
 	echo "Setting keymap: $KEYMAP"
-	/bin/loadkeys $KEYMAP
+	loadkeys $KEYMAP
 fi
 
 # Cleanup some files.
 rm -f /etc/forcefsck
-
-#
-# When running Vanilla busybox's init which has no inittab support, run
-# /etc/rc.start to bring up user defined services. Since runlevels are also
-# unsupported, we specify the maximum number which is 5.
-#
-# sysvinit defines INIT_VERSION environment variable which is not present in
-# busybox init.
-#
-if [ -z "$INIT_VERSION" ]; then
-	if [ -x /etc/rc.start ]; then
-		/etc/rc.start 5
-	fi
-
-	if [ -x /etc/rc.local ]; then
-		/etc/rc.local
-	fi
-fi
--- a/core/rc/rc.shutdown	Tue Jul 23 22:35:00 2019 +0200
+++ b/core/rc/rc.shutdown	Tue Jul 23 22:56:00 2019 +0200
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# /etc/rc.shutdown: reboot and halt script
+# /etc/rc.shutdown - reboot and halt script
 #
 # Copyright (c) 2019 David Demelier <markand@malikania.fr>
 #
@@ -18,23 +18,23 @@
 #
 
 if [ -f /etc/rc.conf ]; then
-	source /etc/rc.conf
+	. /etc/rc.conf
 fi
 
 echo "Terminating all processes."
-/bin/killall5 -15
+killall5 -15
 
 echo "Unmounting all filesystems."
-/bin/halt -w
-/bin/swapoff -a
+halt -w
+swapoff -a
 
 echo "Remounting / read-only"
-/bin/umount -a -d -r -t nosysfs,noproc,nodevtmpfs
-/bin/umount -a -r
-/bin/mount -o remount,ro /
+umount -a -d -r -t nosysfs,noproc,nodevtmpfs
+umount -a -r
+mount -o remount,ro /
 
 if [ "$1" = "0" ]; then
-	/bin/poweroff -d -f -i
+	poweroff -d -f
 else
-	/bin/reboot -d -f -i
+	reboot -d -f
 fi
--- a/core/rc/rc.start	Tue Jul 23 22:35:00 2019 +0200
+++ b/core/rc/rc.start	Tue Jul 23 22:56:00 2019 +0200
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# /etc/rc.start: runlevel control script
+# /etc/rc.start -- runlevel control script
 #
 # Copyright (c) 2019 David Demelier <markand@malikania.fr>
 #
@@ -23,7 +23,7 @@
 fi
 
 if [ -f /etc/rc.conf ]; then
-	source /etc/rc.conf
+	. /etc/rc.conf
 fi
 
 # Start user services requested in rc.conf(5).