22 lines
488 B
Plaintext
22 lines
488 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
abort() {
|
||
|
echo -e "$1"
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
[ $# -gt 0 ] || abort "no service specified"
|
||
|
|
||
|
service=$(echo "$1" | sed -E 's#/?service/##' )
|
||
|
|
||
|
matches=$(ls /service/ | grep "$service")
|
||
|
n_matches=$(ls /service/ | grep "$service" | wc -l)
|
||
|
|
||
|
[ "$n_matches" -gt 0 ] || abort "no service matching $service"
|
||
|
[ "$n_matches" -lt 2 ] || abort "multiple services matching $service\n$matches"
|
||
|
|
||
|
echo "restarting $matches"
|
||
|
|
||
|
/usr/bin/svc -d "/service/$matches"
|
||
|
/usr/bin/svc -u "/service/$matches"
|