]> git.proxmox.com Git - pve-manager.git/blame - debian/postinst
ceph: move bullseye repos over to official ones
[pve-manager.git] / debian / postinst
CommitLineData
28e6daaa 1#!/bin/sh
aff192e6
DM
2
3# Abort if any command returns an error value
4set -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
c6908859
FG
11set_lvm_conf() {
12 LVM_CONF_MARKER="# added by pve-manager to avoid scanning"
13
14 # only do these changes once
15 # keep user changes afterwards provided marker is still there..
16 if ! grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf; then
17 OLD_VALUE="$(lvmconfig --typeconfig full devices/global_filter)"
18 NEW_VALUE='global_filter=["r|/dev/zd.*|"]'
19
20 export LVM_SUPPRESS_FD_WARNINGS=1
21
22 # check global_filter
23 # keep previous setting from our custom packaging if it is still there
24 if echo "$OLD_VALUE" | grep -qvF 'r|/dev/zd.*|'; then
25 SET_FILTER=1
26 BACKUP=1
27 fi
28 # should be the default since bullseye
29 if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then
30 SET_SCAN_LVS=1
31 BACKUP=1
32 fi
33 if test -n "$BACKUP"; then
34 echo "Backing up lvm.conf before setting pve-manager specific settings.."
35 cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak
36 fi
37 if test -n "$SET_FILTER"; then
38 echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols from being scanned:"
39 echo "$OLD_VALUE => $NEW_VALUE"
40 # comment out existing setting
41 sed -i -e 's/^\([[:space:]]*global_filter[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
42 # add new section with our setting
43 cat >> /etc/lvm/lvm.conf <<EOF
44devices {
45 $LVM_CONF_MARKER ZFS zvols
46 $NEW_VALUE
47}
48EOF
49 fi
50 if test -n "$SET_SCAN_LVS"; then
51 echo "Adding scan_lvs=0 setting to /etc/lvm/lvm.conf to prevent LVs from being scanned."
52 # comment out existing setting
53 sed -i -e 's/^\([[:space:]]*scan_lvs[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
54 # add new section with our setting
55 cat >> /etc/lvm/lvm.conf <<EOF
56devices {
57 $LVM_CONF_MARKER LVM volumes
58 scan_lvs=0
59}
60EOF
61 fi
62 fi
63}
64
aff192e6
DM
65case "$1" in
66 triggered)
67 # We don't print a status message here, as dpkg already said
68 # "Processing triggers for ...".
69
099e5477
DM
70 # test if /etc/pve is mounted; else simple exit to avoid
71 # error during updates
72 test -f /etc/pve/local/pve-ssl.pem || exit 0;
6675a064 73 test -e /proxmox_install_mode && exit 0;
81019d9d 74
ea067f42
TL
75 # the ExecStartPre doesn't triggers on service reload, so just in case
76 /usr/bin/pvecm updatecerts --silent || true
77
15c72102
FG
78 deb-systemd-invoke reload-or-try-restart pvedaemon.service
79 deb-systemd-invoke reload-or-try-restart pvestatd.service
80 deb-systemd-invoke reload-or-try-restart pveproxy.service
81 deb-systemd-invoke reload-or-try-restart spiceproxy.service
aff192e6
DM
82
83 exit 0;;
84
85 configure)
86 # Configure this package. If the package must prompt the user for
87 # information, do it here.
88
89 mkdir /etc/pve 2>/dev/null || true
90
75a6a7f5
DM
91 if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then
92 mkdir -p /var/lib/pve-manager/apl-info
93 cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com
94 pveam update || true
95 fi
96
544221fa
TL
97 if ! test -f /root/.forward || ! grep -q '|/usr/bin/pvemailforward' /root/.forward; then
98 echo '|/usr/bin/pvemailforward' >>/root/.forward
782bc232 99 fi
d0e55a85 100
6675a064
DM
101 systemctl --system daemon-reload >/dev/null || true
102
103 # same as dh_systemd_enable (code copied)
104
aad80361
FG
105 UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvesr.timer pve-daily-update.timer"
106 NO_RESTART_UNITS="pvenetcommit.service pve-guests.service"
0dfd4a94 107
aad80361
FG
108 for unit in ${UNITS} ${NO_RESTART_UNITS}; do
109 deb-systemd-helper unmask "$unit" >/dev/null || true
6675a064
DM
110
111 # was-enabled defaults to true, so new installations run enable.
aad80361 112 if deb-systemd-helper --quiet was-enabled "$unit"; then
6675a064
DM
113 # Enables the unit on first installation, creates new
114 # symlinks on upgrades if the unit file has changed.
aad80361 115 deb-systemd-helper enable "$unit" >/dev/null || true
6675a064
DM
116 else
117 # Update the statefile to add new symlinks (if any), which need to be
118 # cleaned up on purge. Also remove old symlinks.
aad80361 119 deb-systemd-helper update-state "$unit" >/dev/null || true
6675a064
DM
120 fi
121 done
122
891ea8e8 123 # FIXME: remove in PVE 8.0
5fb7a28a
TL
124 if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7~'; then
125 # PVE 4.0 beta to 5.4 ISO had a bug and did not generated a unique machine-id. below is a
126 # very relaxed machine-id list from all ISOs (released, tests & internal) possibly affected
127 if grep -q \
128 -e 2ec24eda629a4c8d8c1f8dac50a9ee5f \
129 -e bd94244c0da6419a82a383e62dc03b51 \
130 -e 45d4e7046c3d4c26af8acd589f358ac6 \
131 -e 8c445f96b3064ff79f825ea78a3eefde \
132 -e 6f9fae0f0a794fd4b89b3abecfd7f182 \
133 -e 6f9fae0f0a794fd4b89b3abecfd7f182 \
134 -e 285de85759894b3f9ad9844a89045af6 \
135 -e 89971dede7b04c98b2b0bc8845f53320 \
136 -e 4e3b6e9550f24d638bc26211a7b37df5 \
137 -e bc2f684e31ee4daf95e45c62410a95b1 \
138 -e 8cc7bc883fd048b78a4af7433c48e341 \
139 -e 9b46d99712854566bb02a656a3ff9191 \
140 -e e7fc055af47048ee884dcb88a7474336 \
141 -e 13d879f75e6447a69ed85179bd93759a \
142 -e 5b59e448c3e74029af2ac91f572d68a7 \
143 -e 5a2bd0d11a6c41f9a33fd527751224ea \
144 -e 516afc72013c4b9da85b309aad987df2 \
145 -e b0ce8d24684845e8ac337c588a7715cb \
146 -e e0af064c16e9463e9fa980eac66427c1 \
147 -e 6e925d11b497446e8e7f2ff38e7cf891 \
148 -e eec280213051474d8bfe7e089a86744a \
149 -e 708ded6ee82a46c08b77fecda2284c6c \
150 -e 615cb2b78b2240289fef74da610c146f \
151 -e b965b329a7e246d5be66a8d367f5760d \
152 -e 5472a49c6436426fbebd7881f7b7f13b \
153 /etc/machine-id
154 then
155 echo "found static machine-id bug from Proxmox VE ISO installer <= 5.4, regenerating machine-id"
156 systemd-id128 new | tee /etc/machine-id.new /var/lib/dbus/machine-id.new
157 # atomically replace
158 mv /etc/machine-id.new /etc/machine-id
159 mv /var/lib/dbus/machine-id.new /var/lib/dbus/machine-id
160 echo "new machine-id generated, a reboot is recommended"
161 else
162 echo "machine-id check OK"
163 fi
164 fi
165
c6908859
FG
166 set_lvm_conf
167
6675a064 168 if test ! -e /proxmox_install_mode; then
de01cff0 169 # modeled after code generated by dh_start
aad80361 170 for unit in ${UNITS}; do
de01cff0
FG
171 if test -n "$2"; then
172 dh_action="reload-or-try-restart";
173 else
174 dh_action="start"
175 fi
aee71a6c
TL
176 if systemctl -q is-enabled "$unit"; then
177 deb-systemd-invoke $dh_action "$unit"
178 fi
6675a064
DM
179 done
180 fi
01fe34e0 181 ;;
aff192e6 182
e3ffd2c0 183 abort-upgrade|abort-remove|abort-deconfigure)
aff192e6 184 ;;
aff192e6 185
aff192e6
DM
186 *) echo "$0: didn't understand being called with \`$1'" 1>&2
187 exit 0;;
188esac
189
190exit 0