From ee95471d2c09f373b0b0683e40cd0e1f1a4904ac Mon Sep 17 00:00:00 2001 From: Lars Wendler Date: Thu, 10 Sep 2015 10:57:55 -0500 Subject: udev: create a function to locate the binary --- init.d/udev | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/init.d/udev b/init.d/udev index f286ad8..8106a20 100644 --- a/init.d/udev +++ b/init.d/udev @@ -14,6 +14,19 @@ depend() keyword -lxc -systemd-nspawn -vserver } +get_udevd_binary() { + bins="/sbin/udevd /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd" + for f in ${bins}; do + if [ -x "$f" -a ! -L "$f" ]; then + command="$f" + fi + done + if [ -z "$command" ]; then + eerror "Unable to find udev executable." + return 1 + fi +} + start_pre() { # make sure devtmpfs is in the kernel @@ -45,16 +58,7 @@ start_pre() fi fi - bins="/sbin/udevd /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd" - for f in ${bins}; do - if [ -x "$f" -a ! -L "$f" ]; then - command="$f" - fi - done - if [ -z "$command" ]; then - eerror "Unable to find udev executable." - return 1 - fi + get_udevd_binary || return 1 if [ -e /proc/sys/kernel/hotplug ]; then echo "" >/proc/sys/kernel/hotplug @@ -75,8 +79,9 @@ stop() rc=$? if [ $rc -ne 0 ]; then eend $rc "Failed to stop $RC_SVCNAME using udevadm" + get_udevd_binary || return 1 ebegin "Trying with start-stop-daemon" - start-stop-daemon --stop --exec /sbin/udevd + start-stop-daemon --stop --exec ${command} rc=$? fi eend $rc "Failed to stop $RC_SVCNAME" -- cgit v1.2.3-65-gdbad