2009-05-01 19:41:40 +05:30
|
|
|
# Copyright (c) 2007 Gentoo Foundation
|
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2011-06-30 05:16:31 +05:30
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2013-01-17 08:47:08 +05:30
|
|
|
net_fs_list="afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre
|
2011-07-06 01:03:21 +05:30
|
|
|
ncpfs nfs nfs4 ocfs2 shfs smbfs"
|
2008-01-11 17:43:46 +05:30
|
|
|
is_net_fs()
|
|
|
|
{
|
2007-04-05 16:48:42 +05:30
|
|
|
[ -z "$1" ] && return 1
|
|
|
|
|
2007-10-09 21:03:05 +05:30
|
|
|
# Check OS specific flags to see if we're local or net mounted
|
|
|
|
mountinfo --quiet --netdev "$1" && return 0
|
|
|
|
mountinfo --quiet --nonetdev "$1" && return 1
|
|
|
|
|
|
|
|
# Fall back on fs types
|
2007-07-16 22:37:15 +05:30
|
|
|
local t=$(mountinfo --fstype "$1")
|
2011-07-06 20:23:05 +05:30
|
|
|
for x in $net_fs_list $extra_net_fs_list; do
|
2009-04-27 02:43:26 +05:30
|
|
|
[ "$x" = "$t" ] && return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
is_union_fs()
|
|
|
|
{
|
2007-04-05 16:48:42 +05:30
|
|
|
[ ! -x /sbin/unionctl ] && return 1
|
2007-11-28 21:15:03 +05:30
|
|
|
unionctl "$1" --list >/dev/null 2>&1
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
get_bootparam()
|
|
|
|
{
|
2007-04-05 16:48:42 +05:30
|
|
|
local match="$1"
|
2009-04-27 02:43:26 +05:30
|
|
|
[ -z "$match" -o ! -r /proc/cmdline ] && return 1
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
set -- $(cat /proc/cmdline)
|
2007-09-19 19:23:40 +05:30
|
|
|
while [ -n "$1" ]; do
|
2009-04-27 02:43:26 +05:30
|
|
|
[ "$1" = "$match" ] && return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
case "$1" in
|
|
|
|
gentoo=*)
|
|
|
|
local params="${1##*=}"
|
|
|
|
local IFS=, x=
|
2009-04-27 02:43:26 +05:30
|
|
|
for x in $params; do
|
|
|
|
[ "$x" = "$match" ] && return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2017-02-24 00:20:33 +05:30
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-09-23 03:52:50 +05:30
|
|
|
need_if_exists()
|
|
|
|
{
|
|
|
|
for x; do
|
|
|
|
rc-service --exists "${x}" && need "${x}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2015-04-27 00:01:49 +05:30
|
|
|
# Called from openrc-run.sh or gendepends.sh
|
2015-12-04 01:39:38 +05:30
|
|
|
_get_containers() {
|
|
|
|
local c
|
|
|
|
case "${RC_UNAME}" in
|
|
|
|
FreeBSD)
|
|
|
|
c="-jail"
|
|
|
|
;;
|
|
|
|
Linux)
|
|
|
|
c="-docker -lxc -openvz -rkt -systemd-nspawn -uml -vserver"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo $c
|
|
|
|
}
|
|
|
|
|
|
|
|
_get_containers_remove() {
|
|
|
|
local c
|
|
|
|
for x in $(_get_containers); do
|
|
|
|
c="${c}!${x} "
|
|
|
|
done
|
|
|
|
echo $c
|
|
|
|
}
|
|
|
|
|
2010-02-21 03:18:06 +05:30
|
|
|
_depend() {
|
|
|
|
depend
|
|
|
|
local _rc_svcname=$(shell_var "$RC_SVCNAME") _deptype= _depends=
|
|
|
|
|
|
|
|
# Add any user defined depends
|
2015-12-02 00:01:28 +05:30
|
|
|
for _deptype in config:CONFIG need:NEED use:USE want:WANT \
|
2010-02-21 03:18:06 +05:30
|
|
|
after:AFTER before:BEFORE \
|
|
|
|
provide:PROVIDE keyword:KEYWORD; do
|
|
|
|
IFS=:
|
|
|
|
set -- $_deptype
|
|
|
|
unset IFS
|
|
|
|
eval _depends=\$rc_${_rc_svcname}_$1
|
|
|
|
[ -z "$_depends" ] && eval _depends=\$rc_$1
|
|
|
|
[ -z "$_depends" ] && eval _depends=\$RC_${_rc_svcname}_$2
|
|
|
|
[ -z "$_depends" ] && eval _depends=\$RC_$2
|
|
|
|
|
|
|
|
$1 $_depends
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2007-09-24 17:39:43 +05:30
|
|
|
# Add our sbin to $PATH
|
2009-04-27 02:43:26 +05:30
|
|
|
case "$PATH" in
|
2009-05-24 01:08:12 +05:30
|
|
|
"$RC_LIBEXECDIR"/sbin|"$RC_LIBEXECDIR"/sbin:*);;
|
2012-11-07 05:52:33 +05:30
|
|
|
*) PATH="$RC_LIBEXECDIR/sbin:$PATH" ; export PATH ;;
|
2007-09-24 17:39:43 +05:30
|
|
|
esac
|