#!/bin/sh # postrm script for dolibarr # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `remove' # * `purge' # * `upgrade' # * `failed-upgrade' # * `abort-install' # * `abort-install' # * `abort-upgrade' # * `disappear' overwrit>r> # for details, see /usr/share/doc/packaging-manual/ . /usr/share/debconf/confmodule db_version 2.0 echo Run the postrm script #echo "postrm db_get dolibarr/webserver" # We disable set -e to avoid premature end of script if error set +e #db_get "dolibarr/webserver" || true set -e export webserver="$RET" # Allows us to loop and substitute in one pass case $webserver in Apache) webservers="apache2" ;; Apache-SSL) webservers="apache2-ssl" ;; Both) webservers="apache2 apache2-ssl" ;; *) webservers="apache2 apache2-ssl" ;; esac export includefile=/etc/dolibarr/apache.conf case "$1" in purge) echo "postrm purge webservers=$webservers includefile=$includefile" # Ask if we must delete database echo "postrm db_input dolibarr/postrm" db_input critical "dolibarr/postrm" || true db_go || true echo "postrm db_get dolibarr/postrm" # We disable set -e to avoid premature end of script if error set +e db_get "dolibarr/postrm" set -e if [ "$RET" = "true" ] ; then echo postrm Mysql database deletion # Get database configuration dbserver="localhost" dbname="dolibarr" #db_get "dolibarr/db/name" #dbname="$RET" superuserlogin='' superuserpassword='' if [ -f /etc/mysql/debian.cnf ] ; then # Load superuser login and pass superuserlogin=$(/bin/grep --max-count=1 "user" /etc/mysql/debian.cnf | /bin/sed -e 's/^user[ =]*//g') superuserpassword=$(/bin/grep --max-count=1 "password" /etc/mysql/debian.cnf | /bin/sed -e 's/^password[ =]*//g') fi echo postrm Mysql superuser found to use is $superuserlogin dbadmin="$superuserlogin" dbadmpass="$superuserpassword" #db_get "dolibarr/db/admin/name" #dbadmin="$RET" #db_get "dolibarr/db/admin/password" #dbadmpass="$RET" dbtype="mysql" # To delete a mysql user (disabled) # Needs: $dbuser - the user name to create (or replace). # $dballow - what hosts to allow (defaults to %). # $dbname - the database that user should have access to. # $dbpass - the password to use. # $dbserver - the server to connect to. # $dbadmin - the administrator name. # $dbadmpass - the administrator password. # which # mysql # /usr/share/wwwconfig-coomon/mysql.get #. /usr/share/wwwconfig-common/${dbtype}-dropuser.sh # To delete database # Needs: $dbname - the database that user should have access to. # $dbserver - the server to connect to. # $dbadmin - the administrator name. # $dbadmpass - the administrator password. # which # mysql # /usr/share/wwwconfig-common/mysql.get echo "postrm Delete database $dbname on server $dbserver using account $dbadmin" . /usr/share/wwwconfig-common/${dbtype}-dropdb.sh else echo "postrm Delete of dolibarr database not wanted" fi # Remove include files for server in $webservers ; do export error="" export conffile="/etc/$server/httpd.conf" echo "postrm conffile=$conffile" if [ -f $conffile ] ; then if [ -s $conffile ] ; then # We disable set -e to avoid premature end of script if error echo postrm remove dolibarr include from /etc/dolibarr/apache.conf set +e . /usr/share/wwwconfig-common/apache-uninclude.sh set -e fi fi if [ "$status" = "purge" ] ; then restart="$restart $server" fi done rm -rf /etc/dolibarr # Restart servers servers="apache2-ssl apache2 mysql" if [ -f /usr/share/wwwconfig-common/restart.sh ] ; then . /usr/share/wwwconfig-common/restart.sh else # Another way to restart for server in $servers ; do if [ -x /usr/sbin/invoke-rc.d ]; then invoke-rc.d $server reload || true else /etc/init.d/$server reload || true fi done fi # Remove file and conf file for dir in /usr/share/dolibarr ; do if [ -d ${dir} ] ; then rm -rf ${dir} ; fi done db_reset "dolibarr/postrm" db_purge ;; remove) echo "postrm Force remove of /usr/share/dolibarr/htdocs/install" rm -fr /usr/share/dolibarr/htdocs/install echo "postrm Remove menu entry and image" fileorig="/usr/share/applications/dolibarr.desktop" rm -f $fileorig fileorig="/usr/share/pixmaps/dolibarr.xpm" rm -f $fileorig # Not sure this is usefull if test -x /usr/bin/update-menus; then update-menus; fi ;; upgrade) ;; failed-upgrade|abort-install|abort-upgrade|disappear) ;; *) echo "postrm called with unknown argument \`$1'" >&2 exit 0 ;; esac db_stop #DEBHELPER# exit 0