blob: 99e2594a51b9c5543b4d665eb21f8643b48b7b96 [file] [log] [blame]
tom5c255702014-09-18 06:57:39 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom1a2908c2014-09-23 16:37:39 -07003# Remotely stops & uninstalls ONOS on the specified node.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tom5c255702014-09-18 06:57:39 -07005
Ayaka Koshibef17f34a2015-09-24 19:31:48 -07006function _usage () {
7cat << _EOF_
8usage:
9 $(basename $0) [node]
10
11options:
12- [node] : The remote instance to uninstall ONOS from.
13
14summary:
15 Remotely stops and uninstalls ONOS on the specified node.
16
17 If [node] isn't specified, \$OCI becomes the target.
18
19_EOF_
20}
21
22[ "$1" = "-h" ] && _usage && exit 0
23
tom5c255702014-09-18 06:57:39 -070024[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
25. $ONOS_ROOT/tools/build/envDefaults
26
27remote=$ONOS_USER@${1:-$OCI}
28
Bob Lantz7c751b52016-04-15 15:42:28 -070029ssh -tt $remote "
30 sudo service onos stop 1>/dev/null 2>/dev/null
Brian O'Connorc045c4a2015-09-17 16:09:44 -070031 # Wait for onos to stop up to 5 seconds
32 for i in \$(seq 1 5); do
Jordan Haltermanfdd04b82018-12-14 12:47:31 -080033 [ -z \"\$(ps -ef | grep org.apache.karaf.main.Main | grep -v grep)\" ] && break
Brian O'Connorc045c4a2015-09-17 16:09:44 -070034 sleep 1
35 done
Jordan Haltermanfdd04b82018-12-14 12:47:31 -080036 [ -z \"\$(ps -ef | grep org.apache.karaf.main.Main | grep -v grep)\" ] || \
Thomas Vachuska46a4fe22015-09-29 17:28:30 -070037 (echo 'ONOS failed to stop.'; status=1)
Brian O'Connorc045c4a2015-09-17 16:09:44 -070038
39 # Remove onos directory and init file
Thomas Vachuska46a4fe22015-09-29 17:28:30 -070040 [ -d $ONOS_INSTALL_DIR ] && sudo rm -fr $ONOS_INSTALL_DIR
41 [ -f /etc/init/onos.conf ] && sudo rm -f /etc/init/onos.conf
Bob Lantzd22c9912016-12-15 14:26:18 -080042 [ -f /etc/init.d/onos ] && sudo rm -f /etc/init.d/onos
43 [ -f /etc/systemd/system/onos.service ] && sudo rm -f /etc/systemd/system/onos.service
Thomas Vachuska46a4fe22015-09-29 17:28:30 -070044
45 exit \${status:-0};
tom5c255702014-09-18 06:57:39 -070046"