runit/runit.svdown

25 lines
502 B
Bash

#!/bin/sh
[ -z $SV_TIMEOUT ] && export SV_TIMEOUT=300
# Check if this service is already down; avoids useless recursion
svisdown $1 && exit 0
if [ -d $1/downdeps ]; then
# We have dependencies to check
for DEPENDENCY in $1/downdeps/*; do
# start svdown in background so they will run in parallel
svdown $DEPENDENCY &
done
# Wait for all services to be down
svwaitdown -n -t $SV_TIMEOUT $1/downdeps/* || exit 111
fi
# actually stop the service
svc -d $1 || exit 111
exit 0