#!/bin/bash

function cyan() { echo -en "\033[1;36m"; }
function red() { echo -en "\033[1;31m"; }
function normal() { echo -en "\033[m\017"; }
function green() { echo -en "\033[1;32m"; }

echo "autopackage unsetup script"
cyan; echo "- (c) 2003 Mike Hearn"; normal;
echo
echo "This script will:"
echo " * Remove directory for packages as /var/packages"
echo " * Remove symlinks from /usr/local/bin to the executables in autopackage/main"
echo " * Remove symlink from /usr/local/share/autopackage to autopackage/main/share"
echo " * Remove configuration file as /etc/autopackage"
echo
echo "If you don't want to do any of these things, just press Ctrl-C now."
echo "You can easily edit the script to take out the actions you don't want."
echo
echo "To continue, just press enter";
read

if [[ `id -u` != "0" ]]; then
    red; echo "You must run this script as root"; normal;
    exit 1
fi

echo -n "Removing packages directory ... "
rm -rf /var/packages
green; echo "done"; normal;

echo -n "Removing symlinks from /usr/local/bin to the executables in autopackage/main ... "
rm /usr/local/bin/makeinstaller
rm /usr/local/bin/package
green; echo "done"; normal;

echo -n "Removing symlink from /usr/local/share/autopackage to autopackage/main/share ... "
rm /usr/local/share/autopackage
green; echo "done"; normal;

echo -n "Removing configuration file as /etc/autopackage ... "
rm /etc/autopackage
green; echo "done"; normal;

## DONE
echo
