Innovenergy_trunk/firmware/opt/innovenergy/scripts/restart

22 lines
488 B
Plaintext
Raw Normal View History

2023-02-16 12:57:06 +00:00
#!/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"