sh/rc-functions.sh.in: add get_bootparam_value function

This commit is contained in:
William Hubbs 2017-02-23 12:50:33 -06:00
parent 4207e46622
commit 1cb44092fc

View File

@ -85,6 +85,40 @@ get_bootparam()
return 1
}
get_bootparam_value()
{
local match="$1" which_value="$2" sep="$3" result value
if [ -n "$match" -a -r /proc/cmdline ]; then
set -- $(cat /proc/cmdline)
while [ -n "$1" ]; do
case "$1" in
$match=*)
value="${1##*=}"
case "$which_value" in
all)
[ -z "$sep" ] && sep=' '
if [ -z "$result" ]; then
result="$value"
else
result="${result}${sep}${value}"
fi
;;
last)
result="$value"
;;
*)
result="$value"
break
;;
esac
;;
esac
shift
done
fi
echo $result
}
# Called from openrc-run.sh or gendepends.sh
_get_containers() {
local c