source: lliurex-analytics-server/trunk/fuentes/debian/postrm @ 3369

Last change on this file since 3369 was 3369, checked in by mabarracus, 3 years ago

Fix config files permission

File size: 2.1 KB
Line 
1#!/bin/sh
2# postrm script
3#
4# see: dh_installdeb(1)
5
6#set -e
7
8# summary of how this script can be called:
9#        * <postrm> `remove'
10#        * <postrm> `purge'
11#        * <old-postrm> `upgrade' <new-version>
12#        * <new-postrm> `failed-upgrade' <old-version>
13#        * <new-postrm> `abort-install'
14#        * <new-postrm> `abort-install' <old-version>
15#        * <new-postrm> `abort-upgrade' <old-version>
16#        * <disappearer's-postrm> `disappear' <overwriter>
17#          <overwriter-version>
18# for details, see http://www.debian.org/doc/debian-policy/ or
19# the debian-policy package
20
21do_dialog(){
22    input=$(dialog      \
23    --title "$1"        \
24    --inputbox "$2"     0 0     \
25    3>&1 1>&2 2>&3 3>&-)
26    clear
27}
28ask_question(){
29    dialog --yesno "$1" 0 0
30    if [ $? -eq 0 ]; then
31        input=yes
32    else
33        input=no
34    fi
35    clear
36}
37
38case "$1" in
39    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
40    ;;
41    purge)
42        mysql_cmd="mysql -s -u root"
43        RET=$(echo "show databases;" |${mysql_cmd} 2>/dev/null)
44        if [ -z "${RET}" ]; then
45            ask_question 'Mysql root password?'
46            rootpass=${input}
47            mysql_cmd="mysql -s -uroot -p${input}"
48            RET=$(echo "show databases;" |${mysql_cmd} 2>/dev/null)
49            if [ -z "${RET}" ]; then
50                echo "Error removing database"
51                exit 0
52            fi
53        fi
54        echo "Removing database.."
55        USER=$(echo "select user from mysql.db where db like 'analytics';"| ${mysql_cmd} 2>/dev/null)
56        if [ -z "${USER}" ]; then
57            echo "Error removing database"
58            exit 0
59        fi
60        echo "drop database analytics;" | ${mysql_cmd} 2>/dev/null
61        echo "drop user ${USER};"| ${mysql_cmd} 2>/dev/null
62        echo "flush privileges;"| ${mysql_cmd} 2>/dev/null
63        echo "Database analytics & user ${USER} removed from mysql"
64        if [ -f "/etc/lliurex-analytics-server/config_db" ]; then
65            rm -f /etc/lliurex-analytics-server/config_db
66            rmdir /etc/lliurex-analytics-server
67        else
68            echo "Warning: config_db file not found! "
69        fi
70        exit 0
71    ;;
72
73    *)
74        echo "postrm called with unknown argument \`$1'" >&2
75        exit 1
76    ;;
77esac
78
79# dh_installdeb will replace this with shell code automatically
80# generated by other debhelper scripts.
81
82#DEBHELPER#
83
84exit 0
Note: See TracBrowser for help on using the repository browser.