From 45ef8eb7234dbad60e39ce1e7791c8e9ad7d920b Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 23 Jul 2013 12:33:45 +0200 Subject: base: provide pidof() shell function --- modules.d/99base/dracut-lib.sh | 25 +++++++++++++++++++++++++ modules.d/99base/module-setup.sh | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3