File obs-server-rc-compat of Package obs-server
if [ -f /etc/rc.status ]; then
. /etc/rc.status
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
_rc_status=0
_rc_status_all=0
if [ "`type -t rc_check`" != function ]; then
rc_check () {
_rc_status_ret=$?
test $_rc_status_ret -eq 0 || _rc_status=$_rc_status_ret
test $_rc_status -eq 0 || _rc_status_all=$_rc_status
return $_rc_status_ret
}
fi
if [ "`type -t rc_reset`" != function ]; then
rc_reset () {
_rc_status=0
_rc_status_all=0
rc_check
return 0
}
fi
if [ "`type -t rc_status`" != function ]; then
if [ "`type -t success`" != function ]; then
success () {
echo OK
}
fi
if [ "`type -t failure`" != function ]; then
failure () {
echo FAIL
}
fi
rc_status () {
rc_check
case "$1" in
-v*)
if [ "$_rc_status" -eq 0 ]; then
success
else
failure
fi
;;
*)
;;
esac
}
fi
if [ "`type -t rc_failed`" != function ]; then
rc_failed () {
rc_reset
case "$1" in
[0-7]) _rc_status=$1 ;;
"") _rc_status=1
esac
rc_check
return $_rc_status
}
fi
if [ "`type -t rc_exit`" != function ]; then
rc_exit () {
exit $_rc_status_all
}
fi
if [ -z "`type -t startproc`" ]; then
startproc () {
OPTIND=1
local opt log=/dev/null user gopt async="&"
while getopts u:g:l:wf opt; do
case "$opt" in
u)
user="$OPTARG"
;;
g)
gopt="-g $OPTARG"
;;
l)
log="$OPTARG"
;;
w)
async=
;;
f)
;;
esac
done
shift $(( OPTIND - 1 ))
if [ -n "$user" ]; then
runuser $gopt -s /bin/sh "$user" -c "$* >>$log 2>&1$async"
else
/bin/sh -c "$* >>$log 2>&1$async"
fi
}
fi
if [ -z "`type -t checkproc`" ]; then
checkproc () {
pgrep -f "$1" >/dev/null
}
fi