Statistics
| Branch: | Tag: | Revision:

root / debian / snf-ganeti.postinst.in @ c7b1d61e

History | View | Annotate | Download (3.1 kB)

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
	update_symlinks=0
24
	# Handle symlinks...
25
	# ... if we are upgrading from pre-2.10 versions
26
	if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.10.0; then
27
		update_symlinks=1
28

    
29
	# ... or if we are not part of a cluster
30
	elif ! /usr/lib/ganeti/@VER@/usr/lib/ganeti/daemon-util check-config 2>/dev/null; then
31
		update_symlinks=1
32

    
33
	# ... or if something is broken
34
	elif [ ! -e /etc/ganeti/lib -o ! -e /etc/ganeti/share ]; then
35
		update_symlinks=1
36
	fi
37

    
38
	if [ "$update_symlinks" = 1 ]; then
39
		for target in lib share; do
40
			if [ "$(readlink /etc/ganeti/${target})" != "/usr/${target}/ganeti/@VER@" ]; then
41
				echo "Linking /etc/ganeti/${target} to /usr/${target}/ganeti/@VER@"
42
				ln -snf /usr/${target}/ganeti/@VER@ /etc/ganeti/${target}
43
			fi
44
		done
45
	fi
46

    
47
	# Restart the service if we have either updated the symlinks, or
48
	# shipped the same minor version. We only stop the service here and
49
	# let the debhelper snippet below start it again.
50
	if [ "$update_symlinks" = 1 -o "${2%.*}" = "@VER@" ]; then
51
		if [ -x "/etc/init.d/ganeti" ]; then
52
			invoke-rc.d ganeti stop || true
53
		fi
54
	fi
55

    
56
	# Work around bugs of older (pre 2.9) versions. In this case all
57
	# daemons have already been stopped by the old package's prerm.
58
	if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.9.0; then
59
		# Since 2.9.0, mond runs as root, so remove the old gnt-mond user (that
60
		# was also created during 2.9.0~rcX.
61
		if getent passwd gnt-mond >/dev/null; then
62
			find /var/log/ganeti -user gnt-mond -exec chown root:root {} \;
63
			deluser --system gnt-mond || true
64
		fi
65

    
66
		# Remove stale PID files
67
		# Ganeti versions prior to 2.8.0~rc4 leave Haskell daemon pidfiles
68
		# behind. If these are root-owned, starting the daemons as unprivileged
69
		# users will fail.
70

    
71
		# All daemons have been stopped, so it's safe to remove
72
		# their PID files.
73
		for daemon in confd mond luxid; do
74
			rm -f /var/run/ganeti/ganeti-${daemon}.pid
75
		done
76

    
77
		# Also remove luxid's socket
78
		rm -f /var/run/ganeti/socket/ganeti-query
79
	fi
80

    
81
    ;;
82

    
83
    abort-upgrade|abort-remove|abort-deconfigure)
84
    ;;
85

    
86
    *)
87
        echo "postinst called with unknown argument \`$1'" >&2
88
        exit 1
89
    ;;
90
esac
91

    
92
# dh_installdeb will replace this with shell code automatically
93
# generated by other debhelper scripts.
94

    
95
#DEBHELPER#
96

    
97
# Fix jobqueue archive permissions
98
# This may take a while, so we only do this if necessary
99
find /var/lib/ganeti/queue/archive -mindepth 1 -maxdepth 1 \
100
		-type d -not -user "@GNTMASTERUSER@" 2>/dev/null | while read dirname; do
101
	/usr/lib/ganeti/ensure-dirs --full-run
102
	break
103
done
104

    
105
exit 0