1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/zsh die() { echo "$@" exit 1 } D=${1:a} shift [[ -d $D ]] || die "Not a directory: $1" PID=$D/runsvdir.pid [[ -f $PID ]] && kill -0 $(<$PID) &>/dev/null && die "runsvdir already running in $SVCDIR" echo $$ >$PID exec runsvdir $D "$@"