diff core/busybox/busybox.mdev @ 554:e135d70987c1

core/busybox: add some services, closes #1663
author David Demelier <markand@malikania.fr>
date Thu, 04 Jul 2019 20:17:00 +0200
parents
children 657ee4987f4d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/busybox/busybox.mdev	Thu Jul 04 20:17:00 2019 +0200
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# /etc/rc.d/busybox.mdev: run control script for busybox.mdev
+#
+# This service is started at early boot stage if the script is marked as
+# executable. There is no need to specify it in SERVICES through the rc.conf
+# file.
+#
+
+if [ -f /etc/rc.conf ]; then
+	. /etc/rc.conf
+fi
+
+: ${BUSYBOX_MDEV_CMD:=/bin/busybox}
+: ${BUSYBOX_MDEV_ARGS:=-s}
+
+busybox_mdev_start()
+{
+	echo "Starting busybox mdev: $BUSYBOX_MDEV_CMD mdev $BUSYBOX_MDEV_ARGS"
+	echo "busybox mdev" > /proc/sys/kernel/hotplug
+	$BUSYBOX_MDEV_CMD mdev $BUSYBOX_MDEV_ARGS
+}
+
+busybox_mdev_status()
+{
+	if grep -q mdev /proc/sys/kernel/hotplug > /dev/null 2>&1; then
+		echo "busybox mdev is enabled"
+	else
+		echo "busybox mdev is not running"
+	fi
+}
+
+busybox_mdev_stop()
+{
+	echo "Stopping busybox mdev."
+	echo "" > /proc/sys/kernel/hotplug
+}
+
+busybox_mdev_restart()
+{
+	busybox_mdev_stop
+	sleep 3
+	busybox_mdev_start
+}
+
+case $1 in
+start)
+	busybox_mdev_start
+	;;
+status)
+	busybox_mdev_status
+	;;
+stop)
+	busybox_mdev_stop
+	;;
+restart)
+	busybox_mdev_restart
+	;;
+*)
+	echo "usage: $(basename $0) restart|start|status|stop"
+	;;
+esac