141 lines
4.9 KiB
Bash
141 lines
4.9 KiB
Bash
#! /bin/sh
|
|
# postrm script for campcaster
|
|
#
|
|
# 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' <r>overwrit>r> <new-version>
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
# the debian-policy package
|
|
|
|
installdir=/opt/campcaster
|
|
apache_docroot=/var/www
|
|
|
|
postgres_user=postgres
|
|
postgresql_dir=/etc/postgresql/8.1/main
|
|
postgresql_init_script=/etc/init.d/postgresql-8.1
|
|
|
|
ls_dbserver=localhost
|
|
ls_database=Campcaster
|
|
ls_dbuser=campcaster
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Function to check for the existence of an executable on the PATH
|
|
#
|
|
# @param $1 the name of the exectuable
|
|
# @return 0 if the executable exists on the PATH, non-0 otherwise
|
|
#-------------------------------------------------------------------------------
|
|
check_exe() {
|
|
if [ -x "`which $1 2> /dev/null`" ]; then
|
|
echo "Exectuable $1 found...";
|
|
return 0;
|
|
else
|
|
echo "Exectuable $1 not found...";
|
|
return 1;
|
|
fi
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
remove|upgrade|failed-upgrade|abort-install|abort-upgrade)
|
|
# remove the init script
|
|
rm -f /etc/init.d/campcaster-scheduler
|
|
update-rc.d campcaster-scheduler remove
|
|
|
|
# remove the symlink to the campcaster web pages
|
|
rm -f $apache_docroot/campcaster
|
|
|
|
# restore the old pg_hba.conf file
|
|
if [ -f $postgresql_dir/pg_hba.conf ] \
|
|
&& [ -f $postgresql_dir/pg_hba.conf.before-campcaster ] ; then
|
|
mv -f $postgresql_dir/pg_hba.conf \
|
|
$postgresql_dir/pg_hba.conf.campcaster ;
|
|
mv -f $postgresql_dir/pg_hba.conf.before-campcaster \
|
|
$postgresql_dir/pg_hba.conf ;
|
|
fi
|
|
;;
|
|
|
|
purge|disappear)
|
|
echo "Checking for required tools..."
|
|
|
|
check_exe "psql" || exit 1;
|
|
check_exe "odbcinst" || exit 1;
|
|
|
|
|
|
echo "Deleting data files...";
|
|
|
|
rm -rf $installdir/etc/campcaster-scheduler.xml
|
|
rm -rf $installdir/etc/gst-registry.xml
|
|
rm -rf $installdir/etc/pear.conf
|
|
rm -rf $installdir/var/Campcaster/htmlUI/var/html/img/*
|
|
rm -rf $installdir/var/Campcaster/htmlUI/var/templates_c/*
|
|
rm -rf $installdir/var/Campcaster/storageServer/var/stor/*
|
|
rm -rf $installdir/var/Campcaster/storageServer/var/access/*
|
|
rm -rf $installdir/var/Campcaster/storageServer/var/trans/*
|
|
rm -rf $installdir/var/Campcaster/archiveServer/var/stor/*
|
|
rm -rf $installdir/var/Campcaster/archiveServer/var/access/*
|
|
rm -rf $installdir/var/Campcaster/archiveServer/var/trans/*
|
|
|
|
|
|
echo "Removing ODBC data source and driver...";
|
|
|
|
# kill active connections to database
|
|
$postgresql_init_script stop
|
|
$postgresql_init_script start
|
|
|
|
echo "Removing Campcaster ODBC data source...";
|
|
odbcinst -u -s -l -n $ls_database || exit 1;
|
|
|
|
echo "De-registering ODBC PostgreSQL driver...";
|
|
odbcinst -u -d -n PostgreSQL_Campcaster || exit 1;
|
|
|
|
|
|
echo "Removing database and database user...";
|
|
|
|
if [ "x$ls_dbserver" == "xlocalhost" ]; then
|
|
su - $postgres_user -c \
|
|
"echo \"DROP DATABASE \\\"$ls_database\\\" \"\
|
|
| psql template1" \
|
|
|| echo "Couldn't drop database $ls_database.";
|
|
|
|
su - $postgres_user -c "echo \"DROP USER $ls_dbuser \"\
|
|
| psql template1" \
|
|
|| echo "Couldn't drop database user $ls_dbuser.";
|
|
|
|
else
|
|
echo "Unable to automatically drop database user and table for";
|
|
echo "remote database $ls_dbserver.";
|
|
echo "Make sure to drop database user $ls_dbuser on database";
|
|
echo "server at $ls_dbserver.";
|
|
echo "Also drop the database called $ld_database.";
|
|
echo "";
|
|
echo "The easiest way to achieve this is by issuing the";
|
|
echo "following SQL commands to PostgreSQL:";
|
|
echo "DROP DATABASE \"$ls_database\";";
|
|
echo "DROP USER $ls_dbuser;";
|
|
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
|