pveupdate: replace cron job with systemd timer

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2018-03-12 14:14:05 +01:00 committed by Fabian Grünbichler
parent 07bbb52f76
commit 3877d4bff5
4 changed files with 24 additions and 14 deletions

View File

@ -11,6 +11,8 @@ SERVICES= \
pveproxy.service \
spiceproxy.service \
pve-storage.target \
pve-daily-update.service\
pve-daily-update.timer \
pvesr.service \
pvesr.timer

View File

@ -0,0 +1,9 @@
[Unit]
Description=Daily PVE download activities
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/pveupdate

View File

@ -0,0 +1,10 @@
[Unit]
Description=Daily PVE download activities
[Timer]
OnCalendar=*-*-* 2:00
RandomizedDelaySec=4h
Persistent=true
[Install]
WantedBy=timers.target

17
debian/postinst vendored
View File

@ -32,26 +32,15 @@ case "$1" in
mkdir /etc/pve 2>/dev/null || true
# remove old cron.daily update job to randomize it
if test -e /etc/cron.daily/pve; then
echo "Remove old update script from cron.daily"
rm /etc/cron.daily/pve
fi
if dpkg --compare-versions "$2" '<=' '5.1-47'; then
# remove cron update job, superseded by systemd timer
rm -f /etc/cron.d/pveupdate
# remove old/unused init.d files
OLD_INITD_FILES="pvebanner pvenetcommit pve-manager pvedaemon pveproxy pvestatd spiceproxy"
for f in ${OLD_INITD_FILES}; do rm -f "/etc/init.d/$f"; done
fi
# create new daily randomize update cronjob if not exist
MIN="$(shuf -i 0-59 -n 1)"
HOUR="$(shuf -i 2-5 -n 1)"
cat <<EOF >/etc/cron.d/pveupdate
# automatically generated - do not edit
${MIN} ${HOUR} * * * root /usr/bin/pveupdate
EOF
if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then
mkdir -p /var/lib/pve-manager/apl-info
cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com