| 1 |
misha680-guest |
5316 |
#!/bin/sh |
| 2 |
|
|
# postrm script for openmrs |
| 3 |
|
|
|
| 4 |
|
|
set -e |
| 5 |
|
|
|
| 6 |
|
|
case "$1" in |
| 7 |
|
|
purge) |
| 8 |
misha680-guest |
5326 |
# are we using the default openmrs-runtime.properties location? |
| 9 |
|
|
if [ -f /etc/openmrs/openmrs-runtime.properties ]; then |
| 10 |
|
|
# attempt to remove database if mysql and local |
| 11 |
|
|
CONNECTION_URL=$(cat /etc/openmrs/openmrs-runtime.properties | grep connection.url) |
| 12 |
misha680-guest |
5328 |
CONNECTION_URL_MYSQL=$(echo $CONNECTION_URL | grep mysql) |
| 13 |
|
|
CONNECTION_URL_LOCALHOST3306=$(echo $CONNECTION_URL | grep localhost:3306) |
| 14 |
|
|
if ! [ "$CONNECTION_URL_MYSQL" = "" ] && ! [ "$CONNECTION_URL_LOCALHOST3306" = "" ]; then |
| 15 |
misha680-guest |
5326 |
DATABASE_NAME=$(echo $CONNECTION_URL | sed 's@.*localhost:3306/\([^?]*\).*@\1@') |
| 16 |
|
|
CONNECTION_USERNAME=$(cat /etc/openmrs/openmrs-runtime.properties | grep connection.username | sed 's/connection.username=//') |
| 17 |
|
|
CONNECTION_PASSWORD=$(cat /etc/openmrs/openmrs-runtime.properties | grep connection.password | sed 's/connection.password=//') |
| 18 |
|
|
# we only drop the database, we cannot drop the user as the openmrs default user |
| 19 |
|
|
# does not have permissions to drop users |
| 20 |
|
|
echo "drop database $DATABASE_NAME" | mysql --user=$CONNECTION_USERNAME --password=$CONNECTION_PASSWORD $DATABASE_NAME > /dev/null 2>&1 |
| 21 |
|
|
fi |
| 22 |
|
|
fi |
| 23 |
|
|
|
| 24 |
misha680-guest |
5316 |
rm -rf /etc/openmrs |
| 25 |
|
|
;; |
| 26 |
|
|
|
| 27 |
|
|
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) |
| 28 |
|
|
;; |
| 29 |
|
|
|
| 30 |
|
|
*) |
| 31 |
|
|
echo "postrm called with unknown argument \`$1'" >&2 |
| 32 |
|
|
exit 1 |
| 33 |
|
|
;; |
| 34 |
|
|
esac |
| 35 |
|
|
|
| 36 |
|
|
#DEBHELPER# |
| 37 |
|
|
|
| 38 |
|
|
exit 0 |