| 1 | #!/bin/sh -e |
| 2 | # Horde postrm script using debconf |
| 3 | # Originally written for horde by Ola Lundqvist <opal@debian.org> |
| 4 | # Adapted for horde2 by Nils Rennebarth <nils@debian.org> |
| 5 | # Adapted for Diogenes by Jeremy Lainé <jeremy.laine@m4x.org> |
| 6 | |
| 7 | remove_from_webconfig () { |
| 8 | webservers="$RET" |
| 9 | |
| 10 | # Remove symlink to our apache.conf |
| 11 | for server in $webservers ; do |
| 12 | server=$(echo $server | sed 's/,$//') |
| 13 | servers="$server $servers" |
| 14 | if [ -s /etc/$server/conf.d/diogenes ] ; then |
| 15 | rm -f /etc/$server/conf.d/diogenes |
| 16 | restart="$server $restart" |
| 17 | fi |
| 18 | done |
| 19 | |
| 20 | # Restart servers |
| 21 | if [ -e /usr/share/wwwconfig-common/restart.sh ] ; then |
| 22 | . /usr/share/wwwconfig-common/restart.sh |
| 23 | fi |
| 24 | } |
| 25 | |
| 26 | ACTION=$1 |
| 27 | case "$ACTION" in |
| 28 | remove) |
| 29 | # |
| 30 | # Remove Diogenes from the webserver configuration |
| 31 | # |
| 32 | . /usr/share/debconf/confmodule |
| 33 | db_version 2.0 |
| 34 | |
| 35 | # |
| 36 | # Only try to remove Diogenes from the webserver configs if the db key |
| 37 | # diogenes/webservers exists. If not, Diogenes had not been installed |
| 38 | # correctly so we just skip the webserver part |
| 39 | # |
| 40 | if db_get "diogenes/webservers"; then |
| 41 | remove_from_webconfig |
| 42 | fi |
| 43 | ;; |
| 44 | |
| 45 | purge) |
| 46 | . /usr/share/debconf/confmodule |
| 47 | db_version 2.0 |
| 48 | |
| 49 | # |
| 50 | # Remove ucf-managed files |
| 51 | # |
| 52 | for myfile in /etc/diogenes/apache.conf /etc/diogenes/diogenes.debian.inc.php; do |
| 53 | ucf --purge $myfile |
| 54 | rm -f $myfile $myfile.dpkg-dist $myfile.dpkg-new $myfile.dpkg-old |
| 55 | done |
| 56 | |
| 57 | # |
| 58 | # If we were asked to, purge Diogenes data |
| 59 | # |
| 60 | db_get "diogenes/purge_removes_data" |
| 61 | if [ "$RET" = "true" ]; then |
| 62 | # remove files |
| 63 | rm -rf /var/spool/diogenes /var/lib/diogenes |
| 64 | |
| 65 | # drop the database if we are Automatic mode |
| 66 | db_get "diogenes/databasemgr_type" |
| 67 | if [ "$RET" = "Automatic" ] ; then |
| 68 | db_get "diogenes/databasemgr_server" |
| 69 | dbserver="$RET" |
| 70 | db_get "diogenes/database_name" |
| 71 | dbname="$RET" |
| 72 | # we use the Diogenes user as the "admin", as he is authorized to do a drop |
| 73 | db_get "diogenes/database_user" |
| 74 | dbadmin="$RET" |
| 75 | db_get "diogenes/database_pass" |
| 76 | dbadmpass="$RET" |
| 77 | if [ -f /usr/share/wwwconfig-common/mysql.get ] && [ -x $(which mysql) ] ; then |
| 78 | . /usr/share/wwwconfig-common/mysql.get |
| 79 | if eval $mysqlcmd -f -e "\"DROP DATABASE $dbname;\"" ; then |
| 80 | status=dropped |
| 81 | fi |
| 82 | fi |
| 83 | fi |
| 84 | fi |
| 85 | ;; |
| 86 | |
| 87 | *) |
| 88 | ;; |
| 89 | esac |
| 90 | |
| 91 | |
| 92 | #DEBHELPER# |
| 93 | |
| 94 | exit 0 |