File: //var/lib/dpkg/info/ctrlsh-core.prerm
#!/bin/sh
# prerm script for ctrlsh-core
#
# 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
case "$1" in
purge|remove|deconfigure)
PG_VERSION=`psql --version | awk 'NR==1{split ($3,a,"."); print a[1]"."a[2]}'`
echo "Stopping postgresql cluster..."
pg_ctlcluster ${PG_VERSION} ctrlsh stop || true
rm -rf "/etc/postgresql/${PG_VERSION}/ctrlsh" "/var/lib/ctrlsh/pg_data"
find /opt/ctrlsh/files/.tmp -mindepth 1 -delete
for dir in "" "/linux" "/windows"; do
rm -f -- "/opt/ctrlsh/etc${dir}/ctrlsh.ini"
done
;;
upgrade|failed-upgrade)
PG_VERSION=`psql --version | awk 'NR==1{split ($3,a,"."); print a[1]"."a[2]}'`
# fix version for pg 10+
if dpkg --compare-versions "${PG_VERSION}" ge 10; then
PG_VERSION="${PG_VERSION%.*}"
fi
( service postgresql status ${PG_VERSION} | grep ctrlsh ) || \
echo "postgresql service not running. Something wrong happend. Aborted;"
;;
*)
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.
exit 0