view core/busybox/busybox.mdev @ 1221:a47aaf9743a0

misc: backed out changeset 4ccc42bf0284 We will keep .sh for now.
author David Demelier <markand@malikania.fr>
date Fri, 15 Oct 2021 16:07:30 +0200
parents 3dfef64b81c1
children
line wrap: on
line source

#!/bin/busybox sh
#
# /etc/rc.d/busybox.mdev -- run control script for busybox mdev
#
# 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.
#

#
# 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 enabled"
	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