Merge "Move openflowplugin Sonar scan to Sonarcloud"
[releng/builder.git] / jjb / packaging / stop-odl.sh
1 #!/bin/bash
2
3 # Options:
4 #   -x: Echo commands
5 #   -e: Fail on errors
6 #   -o pipefail: Fail on errors in scripts this calls, give stacktrace
7 set -ex -o pipefail
8
9 # Stop OpenDaylight
10 sudo systemctl stop opendaylight
11
12 # Check systemd status of OpenDaylight
13 # NB: Exit code 3 means service isn't running, including after clean exit
14 set +e
15 sudo systemctl status opendaylight
16 if [ $? -ne 3 ]; then
17   echo "OpenDaylight systemd service unexpectedly not stopped"
18   exit 1
19 else
20   echo "OpenDaylight systemd service stopped, as expected"
21 fi
22 set -e
23
24 # Verify Java process is not running
25 # shellcheck disable=SC2009
26 if ps aux | grep "[o]pendaylight"; then
27   # Fail if exit code 0, ie Java process is running
28   echo "OpenDaylight process unexpectedly still running"
29   exit 1
30 else
31   echo "OpenDaylight process not running, as expected"
32 fi