~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/dist/Debian/mariadb-server-5.5.postrm

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2013-12-22 10:27:05 UTC
  • Revision ID: package-import@ubuntu.com-20131222102705-mndw7s12mz0szrcn
Tags: upstream-5.5.32
Import upstream version 5.5.32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash -e
 
2
 
 
3
# It is possible that Debconf has already been removed, too.
 
4
if [ -f /usr/share/debconf/confmodule ]; then
 
5
  . /usr/share/debconf/confmodule
 
6
fi
 
7
 
 
8
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
 
9
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
 
10
 
 
11
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
 
12
 
 
13
# Try to stop the server in a sane way. If it does not success let the admin
 
14
# do it himself. No database directories should be removed while the server
 
15
# is running!
 
16
stop_server() {
 
17
  set +e
 
18
  if [ -x /usr/sbin/invoke-rc.d ]; then
 
19
    invoke-rc.d mysql stop
 
20
  else
 
21
    /etc/init.d/mysql stop
 
22
  fi
 
23
  errno=$?
 
24
  set -e
 
25
 
 
26
  if [ "$?" != 0 ]; then
 
27
    echo "Trying to stop the MySQL server resulted in exitcode $?." 1>&2
 
28
    echo "Stop it yourself and try again!" 1>&2
 
29
    exit 1
 
30
  fi
 
31
}
 
32
 
 
33
case "$1" in
 
34
  purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
 
35
    if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then
 
36
      stop_server
 
37
      sleep 2
 
38
    fi
 
39
  ;;
 
40
  *)
 
41
    echo "postrm called with unknown argument '$1'" 1>&2
 
42
    exit 1
 
43
  ;;
 
44
esac
 
45
 
 
46
#
 
47
# - Do NOT purge logs or data if another mysql-sever* package is installed (#307473)
 
48
# - Remove the mysql user only after all his owned files are purged.
 
49
#   
 
50
if [ "$1" = "purge" -a ! \( -x /usr/sbin/mysqld -o -L /usr/sbin/mysqld \) ]; then
 
51
  # we remove the mysql user only after all his owned files are purged
 
52
  rm -f /var/log/mysql.{log,err}{,.0,.[1234567].gz}
 
53
  rm -rf /var/log/mysql
 
54
 
 
55
  db_input high mysql-server-5.1/postrm_remove_databases || true
 
56
  db_go || true
 
57
  db_get mysql-server-5.1/postrm_remove_databases || true
 
58
  if [ "$RET" = "true" ]; then
 
59
    # never remove the debian.cnf when the databases are still existing
 
60
    # else we ran into big trouble on the next install!
 
61
    rm -f /etc/mysql/debian.cnf
 
62
    rm -rf /var/lib/mysql
 
63
    rm -rf /var/run/mysqld
 
64
    userdel mysql || true
 
65
  fi
 
66
 
 
67
  # (normally) Automatically added by dh_installinit
 
68
  if [ "$1" = "purge" ] ; then
 
69
        update-rc.d mysql remove >/dev/null || exit 0
 
70
  fi
 
71
  # (normally) End automatically added section
 
72
fi
 
73
 
 
74
# (normally) Automatically added by dh_installdebconf
 
75
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
 
76
        . /usr/share/debconf/confmodule
 
77
        db_purge
 
78
fi
 
79
# (normally) End automatically added section
 
80
 
 
81
# no DEBHELPER here, "update-rc.d remove" fails if mysql-server-5.1 is installed
 
82
 
 
83
exit 0