commit:     ee95471d2c09f373b0b0683e40cd0e1f1a4904ac
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 10 15:57:55 2015 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Sep 10 15:57:55 2015 +0000
URL:        
https://gitweb.gentoo.org/proj/udev-gentoo-scripts.git/commit/?id=ee95471d

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"

Reply via email to