#!/usr/bin/env bash
<%
# NOTE for cookbook developer: If you edit this script, you must update opt/dcos-grid/cloud-config.yaml
-%>

PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`

user=`whoami`
sudo='sudo'
if [ $user = 'root' ]; then
  sudo=''
fi

pkgpanda=/opt/mesosphere/bin/pkgpanda
if [ -e "$pkgpanda" ]; then
  echo 'Uninstalling DC/OS packages...'
  $sudo -i $pkgpanda uninstall
fi

if [ -e /opt/mesosphere ]; then
  echo 'Remove /opt/mesosphere and /etc/mesosphere ...'
  $sudo rm -rf /opt/mesosphere /etc/mesosphere
fi

if [ -e /tmp/dcos ]; then
  echo 'Remove /tmp/dcos ...'
  $sudo rm -rf /tmp/dcos
fi
