#!/bin/sh

# copyright 2004 vagrant@freegeek.org, distributed under the terms of the
# GNU General Public License version 2 or any later version.

if [ -r /etc/lessdisks-install.conf ]; then
  . /etc/lessdisks-install.conf
fi

if [ -r /etc/lessdisks/server.config ]; then
  . /etc/lessdisks/server.config
fi

if [ -z "$lessdisks_path" ]; then
  lessdisks_path="$1"
fi

if [ -z "$lessdisks_path" ]; then
  echo "no lessdisks_path variable set... i'm getting the heck out of here!"
  exit 1
fi

if [ "/var/lib/lessdisks" = "$lessdisks_path" ] || [ "/var/lib/lessdisks/" = "$lessdisks_path" ]; then
  umount /var/lib/lessdisks/proc
  rm -rf /var/lib/lessdisks
else
  echo "gosh.  you must be an advanced user:"
  echo "you probably want to:"
  echo "rm -rf $lessdisks_path"
  echo "apt-get --purge remove lessdisks"
  echo "rm -f /etc/lessdisks-install.conf* /etc/lessdisks"
  echo "but i'm scared to do it myself."
  exit 2
fi

apt-get --purge remove lessdisks

rm -f /etc/lessdisks-install.conf* /etc/lessdisks
