~percona-dev/percona-server/release-5.5.11-20.2-fix-bug-764138

« back to all changes in this revision

Viewing changes to build/debian/percona-server-server-5.5.postrm

  • Committer: Ignacio Nin
  • Date: 2011-03-13 17:18:23 UTC
  • mfrom: (33.3.17 release-5.5.8-20)
  • Revision ID: ignacio.nin@percona.com-20110313171823-m06xs104nekulywb
Merge changes from release-5.5.8-20 to 5.5.9

Merge changes from the release branch of 5.5.8 to 5.5.9. These include
the HandlerSocket and UDF directories and the building scripts.

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