autogen.sh before configure
[ganeti-local] / debian / ganeti.postinst.in
1 #!/bin/sh
2 # postinst script for ganeti
3
4 set -e
5
6 # summary of how this script can be called:
7 #        * <postinst> `configure' <most-recently-configured-version>
8 #        * <old-postinst> `abort-upgrade' <new version>
9 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
10 #          <new-version>
11 #        * <postinst> `abort-remove'
12 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
13 #          <failed-install-package> <version> `removing'
14 #          <conflicting-package> <version>
15 # for details, see http://www.debian.org/doc/debian-policy/ or
16 # the debian-policy package
17
18
19 case "$1" in
20     configure)
21 #GANETI_USERS#
22
23         # Remove stale PID files
24         # Ganeti versions prior to 2.8.0~rc4 leave Haskell daemon pidfiles
25         # behind. If these are root-owned, starting the daemons as unprivileged
26         # users will fail.
27
28         # All daemons have been stopped during prerm, so it's safe to remove
29         # their PID files.
30         for daemon in confd mond luxid; do
31                 rm -f /var/run/ganeti/ganeti-${daemon}.pid
32         done
33
34         # Also remove luxid's socket
35         rm -f /var/run/ganeti/socket/ganeti-query
36     ;;
37
38     abort-upgrade|abort-remove|abort-deconfigure)
39     ;;
40
41     *)
42         echo "postinst called with unknown argument \`$1'" >&2
43         exit 1
44     ;;
45 esac
46
47 # dh_installdeb will replace this with shell code automatically
48 # generated by other debhelper scripts.
49
50 #DEBHELPER#
51
52 # Fix jobqueue archive permissions
53 # This may take a while, so we only do this if necessary
54 find /var/lib/ganeti/queue/archive -mindepth 1 -maxdepth 1 \
55                 -type d -not -user "@GNTMASTERUSER@" | while read dirname; do
56         /usr/lib/ganeti/ensure-dirs --full-run
57         break
58 done
59
60 exit 0