This brings the script in line with current init script standards, and fixes all make check-package warnings. Other notable changes: * Use start-stop-daemon to create a PID file, so we can monitor shutdown. * Use "udevadm control --exit" to implement stop, instead of "killall". * Do not require /etc/udev/udev.conf to exist, the default contains only comments and udevd works without. * Do not parse /etc/udev/udev.conf, the udev_root configuration option it was used for has been removed in version 1.5.1 [1]. * Implement reload using udevadm. [1] https://github.com/eudev-project/eudev/commit/6ada823a9a0979ea145fd70add1007c21caa45c0 Signed-off-by: Fiona Klute <fiona.klute@gmx.de> Signed-off-by: Julien Olivain <ju.o@free.fr>
97 lines
2.2 KiB
Bash
97 lines
2.2 KiB
Bash
#!/bin/sh
|
|
#
|
|
# udev This is a minimal non-LSB version of a UDEV startup script. It
|
|
# was derived by stripping down the udev-058 LSB version for use
|
|
# with buildroot on embedded hardware using Linux 2.6.34+ kernels.
|
|
#
|
|
# You may need to customize this for your system's resource limits
|
|
# (including startup time!) and administration. For example, if
|
|
# your early userspace has a custom initramfs or initrd you might
|
|
# need /dev much earlier; or without hotpluggable busses (like USB,
|
|
# PCMCIA, MMC/SD, and so on) your /dev might be static after boot.
|
|
#
|
|
# This script assumes your system boots right into the eventual root
|
|
# filesystem, and that init runs this udev script before any programs
|
|
# needing more device nodes than the bare-bones set -- /dev/console,
|
|
# /dev/zero, /dev/null -- that's needed to boot and run this script.
|
|
#
|
|
|
|
DAEMON="udevd"
|
|
PIDFILE="/var/run/$DAEMON.pid"
|
|
|
|
SETTLE_TIMEOUT=30
|
|
UDEVD_ARGS=""
|
|
|
|
# shellcheck source=/dev/null
|
|
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
|
|
|
start() {
|
|
printf "Starting %s: " "$DAEMON"
|
|
[ -e /proc/sys/kernel/hotplug ] && printf '\000\000\000\000' > /proc/sys/kernel/hotplug
|
|
# shellcheck disable=SC2086 # we need the word splitting
|
|
start-stop-daemon --start --background --make-pidfile \
|
|
--pidfile "$PIDFILE" --exec "/sbin/$DAEMON" \
|
|
-- $UDEVD_ARGS
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
udevadm trigger --type=subsystems --action=add
|
|
udevadm trigger --type=devices --action=add
|
|
udevadm settle --timeout=$SETTLE_TIMEOUT || echo "udevadm settle failed"
|
|
return "$status"
|
|
}
|
|
|
|
stop() {
|
|
printf "Stopping %s: " "$DAEMON"
|
|
udevadm control --exit
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
return "$status"
|
|
fi
|
|
while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \
|
|
--exec "/sbin/$DAEMON"; do
|
|
sleep 0.1
|
|
done
|
|
rm -f "$PIDFILE"
|
|
return "$status"
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
reload() {
|
|
printf "Reloading %s config: " "$DAEMON"
|
|
udevadm control --reload
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start;;
|
|
stop)
|
|
stop;;
|
|
restart)
|
|
restart;;
|
|
reload)
|
|
reload;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|reload}"
|
|
exit 1
|
|
esac
|
|
|
|
exit $?
|