| # ----------------------------------------------------------------------------- |
| # Remotely stops & uninstalls ONOS on the specified node. |
| # ----------------------------------------------------------------------------- |
| - [node] : The remote instance to uninstall ONOS from. |
| Remotely stops and uninstalls ONOS on the specified node. |
| If [node] isn't specified, \$OCI becomes the target. |
| [ "$1" = "-h" ] && _usage && exit 0 |
| [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| . $ONOS_ROOT/tools/build/envDefaults |
| remote=$ONOS_USER@${1:-$OCI} |
| sudo service onos stop 1>/dev/null 2>/dev/null |
| # Wait for onos to stop up to 5 seconds |
| [ -z \"\$(ps -ef | grep org.apache.karaf.main.Main | grep -v grep)\" ] && break |
| [ -z \"\$(ps -ef | grep org.apache.karaf.main.Main | grep -v grep)\" ] || \ |
| (echo 'ONOS failed to stop.'; status=1) |
| # Remove onos directory and init file |
| [ -d $ONOS_INSTALL_DIR ] && sudo rm -fr $ONOS_INSTALL_DIR |
| [ -f /etc/init/onos.conf ] && sudo rm -f /etc/init/onos.conf |
| [ -f /etc/init.d/onos ] && sudo rm -f /etc/init.d/onos |
| [ -f /etc/systemd/system/onos.service ] && sudo rm -f /etc/systemd/system/onos.service |