]> git.proxmox.com Git - pve-manager.git/blob - debian/postinst
avoid trigger errors if daemons are stopped
[pve-manager.git] / debian / postinst
1 #!/bin/bash
2
3 # Abort if any command returns an error value
4 set -e
5
6 # This script is called as the last step of the installation of the
7 # package. All the package's files are in place, dpkg has already
8 # done its automatic conffile handling, and all the packages we depend
9 # of are already fully installed and configured.
10
11 # The following idempotent stuff doesn't generally need protecting
12 # against being run in the abort-* cases.
13
14 # Use debconf. (installs templates)
15 . /usr/share/debconf/confmodule
16 # all done with debconf here.
17 db_stop
18
19 case "$1" in
20 triggered)
21 # We don't print a status message here, as dpkg already said
22 # "Processing triggers for ...".
23
24 # test if /etc/pve is mounted; else simple exit to avoid
25 # error during updates
26 test -f /etc/pve/local/pve-ssl.pem || exit 0;
27 test -e /proxmox_install_mode && exit 0;
28
29 # Note: reload-or-try-restart fails if service is not active
30 systemctl --quiet is-active pvedaemon.service && deb-systemd-invoke reload-or-try-restart pvedaemon.service
31 systemctl --quiet is-active pvestatd.service && deb-systemd-invoke reload-or-try-restart pvestatd.service
32 systemctl --quiet is-active pveproxy.service && deb-systemd-invoke reload-or-try-restart pveproxy.service
33 systemctl --quiet is-active spiceproxy.service && deb-systemd-invoke reload-or-try-restart spiceproxy.service
34
35 exit 0;;
36
37 configure)
38 # Configure this package. If the package must prompt the user for
39 # information, do it here.
40
41 mkdir /etc/pve 2>/dev/null || true
42
43 # remove old APL dir
44 rm -rf /var/lib/pve-manager/apl-available
45
46 if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then
47 mkdir -p /var/lib/pve-manager/apl-info
48 cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com
49 pveam update || true
50 fi
51
52 if test -f /root/.forward; then
53 if ! grep -q '|/usr/bin/pvemailforward' /root/.forward; then
54 echo -e "|/usr/bin/pvemailforward\n$(cat /root/.forward)" >/root/.forward.tmp
55 mv /root/.forward.tmp /root/.forward
56 fi
57 else
58 echo '|/usr/bin/pvemailforward' >/root/.forward
59 fi
60
61 # disable fancy init messages (bad with bootlogd)
62 test -f /etc/lsb-base-logging.sh || echo "FANCYTTY=0" >/etc/lsb-base-logging.sh
63
64
65 systemctl --system daemon-reload >/dev/null || true
66
67 # same as dh_systemd_enable (code copied)
68
69 for service in pvedaemon pveproxy spiceproxy pvestatd pvebanner pvenetcommit pve-manager; do
70 deb-systemd-helper unmask $service.service >/dev/null || true
71
72 # was-enabled defaults to true, so new installations run enable.
73 if deb-systemd-helper --quiet was-enabled $service.service; then
74 # Enables the unit on first installation, creates new
75 # symlinks on upgrades if the unit file has changed.
76 deb-systemd-helper enable $service.service >/dev/null || true
77 else
78 # Update the statefile to add new symlinks (if any), which need to be
79 # cleaned up on purge. Also remove old symlinks.
80 deb-systemd-helper update-state $service.service >/dev/null || true
81 fi
82 done
83
84 if test ! -e /proxmox_install_mode; then
85
86 for service in pvedaemon pveproxy spiceproxy pvestatd; do
87 deb-systemd-invoke reload-or-restart $service
88 done
89 fi
90
91 # rewrite banner
92 test -e /proxmox_install_mode || pvebanner || true
93
94 #a2ensite pve.conf >/dev/null 2>&1
95
96 # There are three sub-cases:
97 if test "${2+set}" != set; then
98 # We're being installed by an ancient dpkg which doesn't remember
99 # which version was most recently configured, or even whether
100 # there is a most recently configured version.
101 :
102
103 elif test -z "$2" -o "$2" = "<unknown>"; then
104 # The package has not ever been configured on this system, or was
105 # purged since it was last configured.
106 :
107
108 else
109 # Version $2 is the most recently configured version of this
110 # package.
111 :
112
113 fi ;;
114 abort-upgrade)
115 # Back out of an attempt to upgrade this package FROM THIS VERSION
116 # to version $2. Undo the effects of "prerm upgrade $2".
117 :
118
119 ;;
120 abort-remove)
121 if test "$2" != in-favour; then
122 echo "$0: undocumented call to \`postinst $*'" 1>&2
123 exit 0
124 fi
125 # Back out of an attempt to remove this package, which was due to
126 # a conflict with package $3 (version $4). Undo the effects of
127 # "prerm remove in-favour $3 $4".
128 :
129
130 ;;
131 abort-deconfigure)
132 if test "$2" != in-favour -o "$5" != removing; then
133 echo "$0: undocumented call to \`postinst $*'" 1>&2
134 exit 0
135 fi
136 # Back out of an attempt to deconfigure this package, which was
137 # due to package $6 (version $7) which we depend on being removed
138 # to make way for package $3 (version $4). Undo the effects of
139 # "prerm deconfigure in-favour $3 $4 removing $6 $7".
140 :
141
142 ;;
143 *) echo "$0: didn't understand being called with \`$1'" 1>&2
144 exit 0;;
145 esac
146
147 exit 0