#!/bin/sh
#
# @package      hubzero-hubgraph
# @file         postrm
# @author       Nicholas J. Kisseberth <nkissebe@purdue.edu>
# @copyright    Copyright (c) 2010-2014 HUBzero Foundation, LLC.
# @license      http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
#
# Copyright (c) 2010-2014 HUBzero Foundation, LLC.
#
# This file is part of: The HUBzero(R) Platform for Scientific Collaboration
#
# The HUBzero(R) Platform for Scientific Collaboration (HUBzero) is free
# software: you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# HUBzero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# HUBzero is a registered trademark of HUBzero Foundation, LLC.
#

# postrm script for hubzero-hubgraph
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <overwriter>
#          <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    purge|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;

    remove)
	for f in /var/lib/hubgraph/lib/views/*
	do
		if [ -h $f ]; then
			rm -f $f
		fi
	done

	for f in /var/lib/hubgraph/lib/resources/*
	do
		if [ -h $f ]; then
			rm -f $f
		fi
	done

	if [ -d /var/lib/hubgraph/lib/views ]; then rmdir --ignore-fail-on-non-empty /var/lib/hubgraph/lib/views || true; fi
	if [ -d /var/lib/hubgraph/lib/resources ]; then rmdir --ignore-fail-on-non-empty /var/lib/hubgraph/lib/resources || true; fi
	if [ -d /var/lib/hubgraph/lib ]; then rmdir --ignore-fail-on-non-empty /var/lib/hubgraph/lib || true; fi

    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
