X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fpostrm;h=c63c1f1f98c5000f93cbee75ffca71cefd73dbef;hb=HEAD;hp=6681ea5b5801fdcf0e5dbf56c860cc5d9eb9c259;hpb=eb37ec66b33ffb28c3a28fae57326403db609a25;p=apache2-cn.git diff --git a/debian/postrm b/debian/postrm index 6681ea5..c63c1f1 100755 --- a/debian/postrm +++ b/debian/postrm @@ -5,83 +5,72 @@ set -e # Debconf . /usr/share/debconf/confmodule -# Include CARNet functions. -. /usr/share/carnet-tools/functions.sh - +case "$1" in + purge) + # continue below + ;; + *) + exit 0 + ;; +esac +CONFDIR="/etc/apache2" HOST=$(hostname -f) DOMAIN=$(hostname -d) -sitefiles="000-$HOST www.$DOMAIN 001-ssl" -sitesdir=/etc/apache2/sites-available +# purge_conf() +# +# Purge Apache2 configuration files located in specified directory. +# +purge_conf () { + local ctype dir file -case "$1" in - purge) - # Get CARNet config files in /etc/apache2/sites-available directory. - if [ -d "${sitesdir}" ] && [ -n "$(ls ${sitesdir}/)" ]; then + ctype="$1" + dir="$2" - sitefiles="" - for file in ${sitesdir}/*; do - if [ -f "$file" ]; then - if egrep -q "^## Begin - Generated by CARNet package apache2-cn$" $file; then - site=`echo "$file" | sed 's/^\/.*\///'` - sitefiles="$sitefiles $site" - fi - fi - done - fi - - # Remove our vhosts. - for site in $sitefiles; do - - if [ -e "$sitesdir/$site" ]; then + case "$ctype" in + site|conf) + # continue below + ;; + *) + return 1 + ;; + esac - cp_echo "CN: Removing $site site configuration file." - rm -f $sitesdir/$site - fi - done - - # Remove default DocumentRoot if there's only a one line index.html there - docroots="/var/www/$HOST.$DOMAIN /var/www/www.$DOMAIN" - - if [ -d "/var/www" ]; then - - for docroot in $docroots; do + if [ -d "${dir}" ] && [ -n "$(ls -A ${dir}/)" ]; then + for file in ${dir}/*.conf; do + if [ -f "$file" ]; then + if egrep -q "^## Begin - Generated by CARNET package apache2-cn$" "$file"; then + a2dis$ctype -p -f -q "`basename "$file" .conf`" || exit $? + rm -f "$file" + fi + fi + done + fi +} - if [ -d $docroot ]; then - if [ "x$(echo ${docroot}/*)" = "x${docroot}/index.html" ]; then - if [ "$(wc -l ${docroot}/index.html | awk '{print $1}')" -eq 1 ]; then - - cp_echo "CN: Removing document root directory ${docroot}." - rm -f $docroot/index.html - rmdir $docroot || true - fi - fi - fi - done - fi - - # Remove CARNet specific configuration. - if [ -d "$CONFDIR/conf.d" ] && [ -n "$(ls ${CONFDIR}/conf.d/)" ]; then - cp_echo "CN: Disabling CARNet specific configuration." - for file in /etc/apache2/conf.d/*; do - if egrep -q "^## Begin - Generated by CARNet package apache2-cn$" $file; then - rm -f $file - fi - done - fi +# Configuration generated by this CARNET package. +echo "CN: Purging $PKG configuration for Apache2." +purge_conf site ${CONFDIR}/sites-available +purge_conf conf ${CONFDIR}/conf-available - # Debconf purge - db_purge - - # Mail root - cp_mail "apache2-cn" - ;; - *) - ;; -esac +# Remove default DocumentRoot if there's only a one line index.html there +docroots="/var/www/$HOST /var/www/www.$DOMAIN" +if [ -d "/var/www" ]; then + for docroot in $docroots; do + if [ -d $docroot ]; then + if [ "x$(echo ${docroot}/*)" = "x${docroot}/index.html" ]; then + if [ "$(wc -l ${docroot}/index.html | awk '{print $1}')" -eq 1 ]; then + echo "CN: Removing document root directory ${docroot}." + rm -f $docroot/index.html + rmdir $docroot || true + fi + fi + fi + done +fi -db_stop +#DEBHELPER# exit 0