summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-07-23 12:33:45 +0200
committerHarald Hoyer <harald@redhat.com>2013-07-23 12:56:20 +0200
commit45ef8eb7234dbad60e39ce1e7791c8e9ad7d920b (patch)
tree57e1614510194b06ea7dd47204a4aad9ea0c2c7e
parentbc6eae15abe6e5e7b7b48b5b0bda2c30e8614ab9 (diff)
downloaddracut-45ef8eb7234dbad60e39ce1e7791c8e9ad7d920b.tar.gz
dracut-45ef8eb7234dbad60e39ce1e7791c8e9ad7d920b.tar.bz2
dracut-45ef8eb7234dbad60e39ce1e7791c8e9ad7d920b.zip
base: provide pidof() shell function
-rwxr-xr-xmodules.d/99base/dracut-lib.sh25
-rwxr-xr-xmodules.d/99base/module-setup.sh2
2 files changed, 26 insertions, 1 deletions
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 8eeebf33..2361ee3c 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -927,6 +927,31 @@ wait_for_loginit()
rm -f -- /run/initramfs/loginit.pipe /run/initramfs/loginit.pid
}
+# pidof version for root
+if ! command -v pidof >/dev/null 2>/dev/null; then
+ pidof() {
+ local _cmd
+ local _exe
+ local _rl
+ local i
+ _cmd="$1"
+ [ -z "$_cmd" ] && return 1
+ _exe=$(type -P "$1")
+ for i in /proc/*/exe; do
+ [ -e "$i" ] || return 1
+ if [ -n "$_exe" ]; then
+ [ "$i" -ef "$_cmd" ] || continue
+ else
+ _rl=$(readlink -f "$i");
+ [ "${_rl%/$_cmd}" != "$_rl" ] || continue
+ fi
+ i=${i%/exe}
+ echo ${i##/proc/}
+ done
+ return 0
+ }
+fi
+
_emergency_shell()
{
local _name="$1"
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
index 86bf3b43..b8f1ef36 100755
--- a/modules.d/99base/module-setup.sh
+++ b/modules.d/99base/module-setup.sh
@@ -13,7 +13,7 @@ depends() {
install() {
local _d
- dracut_install mount mknod mkdir pidof sleep chroot \
+ dracut_install mount mknod mkdir sleep chroot \
sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink setsid
inst $(command -v modprobe) /sbin/modprobe