changeset 405:01b5d3175215

vanilla: add proper support for udev and boot scripts
author David Demelier <markand@malikania.fr>
date Wed, 03 Apr 2019 20:14:00 +0200
parents aa4ce5296a8f
children 0d51fe2867b5
files core/eudev/eudev.sh core/eudev/udevd core/sysvinit/rc.init core/sysvinit/rc.shutdown core/sysvinit/rc.start core/sysvinit/sysvinit.sh
diffstat 6 files changed, 138 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/core/eudev/eudev.sh	Wed Apr 03 20:11:00 2019 +0200
+++ b/core/eudev/eudev.sh	Wed Apr 03 20:14:00 2019 +0200
@@ -52,6 +52,7 @@
 	make
 	make install DESTDIR=$DESTDIR
 	rm -f $DESTDIR/usr/lib/libudev.la
+	install -Dm0755 ../udevd $DESTDIR/etc/rc.d/udevd
 
 	popd
 	rm -rf $PKGNAME-$PKGVERSION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/eudev/udevd	Wed Apr 03 20:14:00 2019 +0200
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# /etc/rc.d/udevd: run control script for eudev
+
+if [ -f /etc/rc.conf ]; then
+	. /etc/rc.conf
+fi
+
+: ${UDEVD_CMD:=/usr/sbin/udevd}
+: ${UDEVD_ARGS:=--daemon}
+
+udevd_start()
+{
+	echo "Starting udevd: $UDEVD_CMD $UDEVD_ARGS"
+	$UDEVD_CMD $UDEVD_ARGS
+
+	/usr/sbin/udevadm trigger --type=subsystems --action=add
+	/usr/sbin/udevadm trigger --type=devices --action=add
+}
+
+udevd_status()
+{
+	pid=$(/usr/bin/pidof udevd)
+
+	if [ -n "$pid" ]; then
+		echo "udevd is running with pid: $pid"
+	else
+		echo "udevd is not running"
+	fi
+}
+
+udevd_stop()
+{
+	pid=$(/usr/bin/pidof udevd)
+
+	if [ -n "$pid" ]; then
+		echo "Stopping udevd."
+		/usr/sbin/udevadm control --exit
+	fi
+}
+
+udevd_reload()
+{
+	/usr/sbin/udevadm control --reload
+}
+
+udevd_restart()
+{
+	udevd_stop
+	sleep 3
+	udevd_start
+}
+
+case $1 in
+start)
+	udevd_start
+	;;
+status)
+	udevd_status
+	;;
+stop)
+	udevd_stop
+	;;
+reload)
+	udevd_reload
+	;;
+restart)
+	udevd_restart
+	;;
+*)
+	echo "usage: $(basename $0) reload|restart|start|status|stop"
+	;;
+esac
--- a/core/sysvinit/rc.init	Wed Apr 03 20:11:00 2019 +0200
+++ b/core/sysvinit/rc.init	Wed Apr 03 20:14:00 2019 +0200
@@ -1,9 +1,23 @@
 #
 # /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
-	source /etc/rc.conf
+	. /etc/rc.conf
 fi
 
 if [ -n "$HOSTNAME" ] && [ -x /usr/bin/hostname ]; then
@@ -19,19 +33,33 @@
 if [ -x /usr/bin/mountpoint ]; then
 	echo -n "Mounting filesystems: "
 
+	if ! /usr/bin/mountpoint /dev >/dev/null 2>&1; then
+		/usr/bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1
+		echo -n "/dev "
+	fi
+
 	if ! /usr/bin/mountpoint /proc >/dev/null 2>&1; then
-		/usr/bin/mount -t proc none /proc >/dev/null 2>&1
+		/usr/bin/mount -t proc proc /proc >/dev/null 2>&1
 		echo -n "/proc "
 	fi
 
 	if ! /usr/bin/mountpoint /sys >/dev/null 2>&1; then
-		/usr/bin/mount -t sysfs none /sys >/dev/null 2>&1
+		/usr/bin/mount -t sysfs sysfs /sys >/dev/null 2>&1
 		echo -n "/sys "
 	fi
 
+	if ! /usr/bin/mountpoint /run >/dev/null 2>&1; then
+		/usr/bin/mount -t tmpfs tmpfs /run >/dev/null 2>&1
+		echo -n "/run "
+	fi
+
 	echo "done."
 fi
 
+if [ -x /etc/rc.d/udevd ]; then
+	/etc/rc.d/udevd start
+fi
+
 if [ -x /usr/sbin/fsck ]; then
 	# Make sure / is ro in case of initrd.
 	/usr/bin/mount -o remount,ro /
--- a/core/sysvinit/rc.shutdown	Wed Apr 03 20:11:00 2019 +0200
+++ b/core/sysvinit/rc.shutdown	Wed Apr 03 20:14:00 2019 +0200
@@ -1,6 +1,20 @@
 #
 # /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
--- a/core/sysvinit/rc.start	Wed Apr 03 20:11:00 2019 +0200
+++ b/core/sysvinit/rc.start	Wed Apr 03 20:14:00 2019 +0200
@@ -1,6 +1,20 @@
 #
 # /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
@@ -22,7 +36,7 @@
 	level="${s##*:}"
 
 	# No minimum level, set to requested.
-	if [ -z "$level" ]; then
+	if [ "$level" = "name" ]; then
 		level="$1"
 	fi
 
--- a/core/sysvinit/sysvinit.sh	Wed Apr 03 20:11:00 2019 +0200
+++ b/core/sysvinit/sysvinit.sh	Wed Apr 03 20:14:00 2019 +0200
@@ -43,6 +43,10 @@
 	make CC="$CC" CFLAGS="$CFLAGS"
 	make install ROOT=$DESTDIR
 	install -Dm0644 ../inittab $DESTDIR/etc/inittab
+	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
 
 	popd
 	rm -rf $PKGNAME-$PKGVERSION