119 lines
3.7 KiB
Bash
119 lines
3.7 KiB
Bash
#! /bin/sh
|
|
# prerm script for livesupport
|
|
#
|
|
# see: dh_installdeb(1)
|
|
|
|
set -e
|
|
|
|
# summary of how this script can be called:
|
|
# * <prerm> `remove'
|
|
# * <old-prerm> `upgrade' <new-version>
|
|
# * <new-prerm> `failed-upgrade' <old-version>
|
|
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
|
|
# * <deconfigured's-prerm> `deconfigure' `in-favour'
|
|
# <package-being-installed> <version> `removing'
|
|
# <conflicting-package> <version>
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
# the debian-policy package
|
|
|
|
installdir=/opt/campcaster
|
|
apache_docroot=/var/www
|
|
apache_group=www-data
|
|
|
|
if [ -d /etc/postgresql/8.1 ]; then
|
|
postgresql_dir=/etc/postgresql/8.1/main
|
|
postgresql_init_script=/etc/init.d/postgresql-8.1
|
|
elif [ -d /etc/postgresql/8.2 ]; then
|
|
postgresql_dir=/etc/postgresql/8.2/main
|
|
postgresql_init_script=/etc/init.d/postgresql-8.2
|
|
elif [ -d /etc/postgresql/8.3 ]; then
|
|
postgresql_dir=/etc/postgresql/8.3/main
|
|
postgresql_init_script=/etc/init.d/postgresql-8.3
|
|
else
|
|
echo "no postgresql 8.1, 8.2 or 8.3 found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
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
|
|
return 0;
|
|
else
|
|
return 1;
|
|
fi
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
remove|upgrade|deconfigure)
|
|
# unmount the NFS share, if we have a 2-computer setup
|
|
storagedir=$installdir/var/Campcaster/storageServer
|
|
if [ "`mount | grep -o \"on $storagedir \"`" = "on $storagedir " ]; then
|
|
echo "Unmounting the remote storage..."
|
|
umount $storagedir
|
|
touch $installdir/storageServer.wasMounted
|
|
fi
|
|
|
|
# stop the livesupport scheduler daemon
|
|
/etc/init.d/campcaster-scheduler stop || true
|
|
/etc/init.d/campcaster-scheduler kill || true
|
|
|
|
# remove the init script
|
|
rm -f /etc/init.d/campcaster-scheduler
|
|
update-rc.d campcaster-scheduler remove || true
|
|
|
|
# remove the ODBC data source and driver
|
|
check_exe "odbcinst" || odbcinst_found=no
|
|
|
|
if [ "x$odbcinst_found" != "xno" ] ; then
|
|
odbcinst -u -s -l -n $ls_database
|
|
odbcinst -u -d -n PostgreSQL_Campcaster
|
|
fi
|
|
|
|
# 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.before-campcaster \
|
|
$postgresql_dir/pg_hba.conf ;
|
|
fi
|
|
|
|
# remove generated files
|
|
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/archiveServer/var/access/*
|
|
rm -rf $installdir/var/Campcaster/archiveServer/var/trans/*
|
|
rm -rf $installdir/var/Campcaster/storageServer/var/access/*
|
|
rm -rf $installdir/var/Campcaster/storageServer/var/trans/*
|
|
;;
|
|
|
|
failed-upgrade)
|
|
;;
|
|
|
|
*)
|
|
echo "prerm 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
|
|
|
|
|