21 lines
450 B
Plaintext
21 lines
450 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 "stopping $matches"
|
||
|
|
||
|
/usr/bin/svc -d "/service/$matches"
|