]> git.proxmox.com Git - pve-manager.git/blame - debian/postinst
bump version to 8.1.2
[pve-manager.git] / debian / postinst
CommitLineData
28e6daaa 1#!/bin/sh
aff192e6 2
60b5e2d8 3# Abort if any command returns an error value
aff192e6
DM
4set -e
5
60b5e2d8
TL
6# This script is called as the last step of the installation of the package.
7# All the package's files are in place, dpkg has already done its automatic
8# conffile handling, and all the packages we depend of are already fully
9# installed and configured.
aff192e6 10
c6908859
FG
11set_lvm_conf() {
12 LVM_CONF_MARKER="# added by pve-manager to avoid scanning"
13
c6908859 14 # keep user changes afterwards provided marker is still there..
2833e1e1
TL
15 if grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf; then
16 return 0 # only do these changes once
17 fi
60b5e2d8 18
2833e1e1
TL
19 OLD_VALUE="$(lvmconfig --typeconfig full devices/global_filter)"
20 NEW_VALUE='global_filter=["r|/dev/zd.*|"]'
60b5e2d8 21
2833e1e1
TL
22 export LVM_SUPPRESS_FD_WARNINGS=1
23
24 # check global_filter
25 # keep previous setting from our custom packaging if it is still there
26 if echo "$OLD_VALUE" | grep -qvF 'r|/dev/zd.*|'; then
27 SET_FILTER=1
28 BACKUP=1
29 fi
30 # should be the default since bullseye
31 if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then
32 SET_SCAN_LVS=1
33 BACKUP=1
34 fi
35 if test -n "$BACKUP"; then
36 echo "Backing up lvm.conf before setting pve-manager specific settings.."
37 cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak
38 fi
39 if test -n "$SET_FILTER"; then
40 echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols from being scanned:"
41 echo "$OLD_VALUE => $NEW_VALUE"
42 # comment out existing setting
43 sed -i -e 's/^\([[:space:]]*global_filter[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
44 # add new section with our setting
45 cat >> /etc/lvm/lvm.conf <<EOF
c6908859 46devices {
60b5e2d8
TL
47 $LVM_CONF_MARKER ZFS zvols
48 $NEW_VALUE
49 }
c6908859 50EOF
2833e1e1
TL
51 fi
52 if test -n "$SET_SCAN_LVS"; then
53 echo "Adding scan_lvs=0 setting to /etc/lvm/lvm.conf to prevent LVs from being scanned."
54 # comment out existing setting
55 sed -i -e 's/^\([[:space:]]*scan_lvs[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
56 # add new section with our setting
57 cat >> /etc/lvm/lvm.conf <<EOF
c6908859 58devices {
60b5e2d8
TL
59 $LVM_CONF_MARKER LVM volumes
60 scan_lvs=0
61 }
c6908859 62EOF
c6908859
FG
63 fi
64}
65
bf09acfe
FG
66migrate_apt_auth_conf() {
67 output=""
68 removed=""
69 match=0
70
71 while read -r l; do
60b5e2d8
TL
72 if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pve"; then
73 match=1
74 elif echo "$l" | grep -q "machine"; then
75 match=0
76 fi
77
78 if test "$match" = "1"; then
79 removed="$removed\n$l"
80 else
81 output="$output\n$l"
82 fi
bf09acfe
FG
83 done < /etc/apt/auth.conf
84
85 if test -n "$removed"; then
60b5e2d8
TL
86 if test ! -e /etc/apt/auth.conf.d/pve.conf; then
87 echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pve.conf .."
88 echo "$removed" > /etc/apt/auth.conf.d/pve.conf
89 else
90 echo "Removing stale APT auth config from /etc/apt/auth.conf"
91 fi
92 echo "$output" > /etc/apt/auth.conf
bf09acfe
FG
93 fi
94}
95
aff192e6
DM
96case "$1" in
97 triggered)
98 # We don't print a status message here, as dpkg already said
99 # "Processing triggers for ...".
100
099e5477
DM
101 # test if /etc/pve is mounted; else simple exit to avoid
102 # error during updates
103 test -f /etc/pve/local/pve-ssl.pem || exit 0;
6675a064 104 test -e /proxmox_install_mode && exit 0;
81019d9d 105
ea067f42 106 # the ExecStartPre doesn't triggers on service reload, so just in case
9efc89f6 107 pvecm updatecerts --silent || true
ea067f42 108
15c72102
FG
109 deb-systemd-invoke reload-or-try-restart pvedaemon.service
110 deb-systemd-invoke reload-or-try-restart pvestatd.service
111 deb-systemd-invoke reload-or-try-restart pveproxy.service
112 deb-systemd-invoke reload-or-try-restart spiceproxy.service
6385fb81 113 deb-systemd-invoke reload-or-try-restart pvescheduler.service
aff192e6
DM
114
115 exit 0;;
116
117 configure)
118 # Configure this package. If the package must prompt the user for
119 # information, do it here.
120
121 mkdir /etc/pve 2>/dev/null || true
122
75a6a7f5 123 if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then
60b5e2d8
TL
124 mkdir -p /var/lib/pve-manager/apl-info
125 cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com
126 pveam update || true
75a6a7f5
DM
127 fi
128
b632562c
FE
129 # Always try to clean old entry, even when proxmox-mail-forward entry is already present.
130 # This ensures it will still be cleaned after an upgrade following a downgrade.
131 if test -f /root/.forward; then
132 sed -i '\!|/usr/bin/pvemailforward!d' /root/.forward
133 fi
134
135 if ! test -f /root/.forward || ! grep -q '|/usr/bin/proxmox-mail-forward' /root/.forward; then
136 echo '|/usr/bin/proxmox-mail-forward' >>/root/.forward
782bc232 137 fi
d0e55a85 138
6675a064
DM
139 systemctl --system daemon-reload >/dev/null || true
140
141 # same as dh_systemd_enable (code copied)
142
6385fb81 143 UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvescheduler.service pve-daily-update.timer"
aad80361 144 NO_RESTART_UNITS="pvenetcommit.service pve-guests.service"
0dfd4a94 145
aad80361 146 for unit in ${UNITS} ${NO_RESTART_UNITS}; do
60b5e2d8
TL
147 deb-systemd-helper unmask "$unit" >/dev/null || true
148
149 # was-enabled defaults to true, so new installations run enable.
150 if deb-systemd-helper --quiet was-enabled "$unit"; then
151 # Enables the unit on first installation, creates new
152 # symlinks on upgrades if the unit file has changed.
153 deb-systemd-helper enable "$unit" >/dev/null || true
154 else
155 # Update the statefile to add new symlinks (if any), which need to be
156 # cleaned up on purge. Also remove old symlinks.
157 deb-systemd-helper update-state "$unit" >/dev/null || true
158 fi
6675a064
DM
159 done
160
6e3ca3d3
TL
161 # FIXME: remove after beta is over and add hunk to actively remove the repo
162 BETA_SOURCES="/etc/apt/sources.list.d/pvetest-for-beta.list"
2f11eee5 163 if test -f "$BETA_SOURCES" && dpkg --compare-versions "$2" 'lt' '8.0.2' && dpkg --compare-versions "$2" 'gt' '8.0~'; then
575a0e8a
DC
164 echo "Removing the during beta added pvetest repository file again"
165 rm -v "$BETA_SOURCES" || true
6e3ca3d3
TL
166 fi
167
c6908859
FG
168 set_lvm_conf
169
6675a064 170 if test ! -e /proxmox_install_mode; then
60b5e2d8
TL
171 # modeled after code generated by dh_start
172 for unit in ${UNITS}; do
173 if test -n "$2"; then
174 dh_action="reload-or-restart";
175 else
176 dh_action="start"
177 fi
178 if systemctl -q is-enabled "$unit"; then
179 deb-systemd-invoke $dh_action "$unit"
180 fi
181 done
6675a064 182 fi
bf09acfe 183
4209cc3a 184 if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.2-11~'; then
60b5e2d8
TL
185 if test -e /etc/apt/auth.conf ; then
186 migrate_apt_auth_conf
187 fi
bf09acfe 188 fi
01fe34e0 189 ;;
aff192e6 190
e3ffd2c0 191 abort-upgrade|abort-remove|abort-deconfigure)
aff192e6 192 ;;
aff192e6 193
aff192e6
DM
194 *) echo "$0: didn't understand being called with \`$1'" 1>&2
195 exit 0;;
196esac
197
198exit 0