From c93559150bb4a1f30ad3e7022804f62eeea59abd Mon Sep 17 00:00:00 2001 From: Wolfgang Link Date: Tue, 1 Sep 2015 12:47:34 +0200 Subject: [PATCH] improve pveupdate with random start time this is important to avoid that all PVE nodes start the update procedure at the same time --- bin/Makefile | 1 + bin/cron/Makefile | 6 ------ bin/cron/daily/Makefile | 15 --------------- bin/{cron/daily/pve => pveupdate} | 2 +- debian/conffiles | 1 - debian/postinst | 15 +++++++++++++++ 6 files changed, 17 insertions(+), 23 deletions(-) delete mode 100644 bin/cron/Makefile delete mode 100644 bin/cron/daily/Makefile rename bin/{cron/daily/pve => pveupdate} (98%) diff --git a/bin/Makefile b/bin/Makefile index 2db11579..70d3521d 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -17,6 +17,7 @@ SCRIPTS = \ pveversion \ pvemailforward.pl \ pveupgrade \ + pveupdate \ pveperf SERVICE_MANS = $(addsuffix .8, ${SERVICES}) diff --git a/bin/cron/Makefile b/bin/cron/Makefile deleted file mode 100644 index 937df58a..00000000 --- a/bin/cron/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -SUBDIRS = daily - -all: ${SUBDIRS} - -%: - set -e && for i in ${SUBDIRS}; do ${MAKE} -C $$i $@; done diff --git a/bin/cron/daily/Makefile b/bin/cron/daily/Makefile deleted file mode 100644 index f4bfb409..00000000 --- a/bin/cron/daily/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -include ../../../defines.mk - -all: - -.PHONY: install -install: pve - install -d ${CRONDAILYDIR} - install -m 0755 pve ${CRONDAILYDIR} - -.PHONY: distclean -distclean: clean - -.PHONY: clean -clean: - rm -rf *~ diff --git a/bin/cron/daily/pve b/bin/pveupdate similarity index 98% rename from bin/cron/daily/pve rename to bin/pveupdate index 47f15a20..e9a23050 100644 --- a/bin/cron/daily/pve +++ b/bin/pveupdate @@ -25,7 +25,7 @@ my $rpcenv = PVE::RPCEnvironment->init('cli'); $rpcenv->init_request(); $rpcenv->set_language($ENV{LANG}); -$rpcenv->set_user('root@pam'); +$rpcenv->set_user('root@pam'); my $nodename = PVE::INotify::nodename(); diff --git a/debian/conffiles b/debian/conffiles index 2bb00273..0acb6aac 100644 --- a/debian/conffiles +++ b/debian/conffiles @@ -3,7 +3,6 @@ /etc/init.d/pveproxy /etc/init.d/spiceproxy /etc/init.d/pvestatd -/etc/cron.daily/pve /etc/vz/vznet.conf /etc/vzdump.conf /etc/logrotate.d/pve diff --git a/debian/postinst b/debian/postinst index bd17b0f0..9498fab9 100755 --- a/debian/postinst +++ b/debian/postinst @@ -43,6 +43,21 @@ case "$1" in # remove old APL dir rm -rf /var/lib/pve-manager/apl-available + # 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 + + # create new daily randomize update cronjob if not exist + if !(test -e /etc/cron.d/pveupdate); then + MIN="$(shuf -i 0-59 -n 1)" + + HOUR="$(shuf -i 6-10 -n 1)" + echo "Create cron job for daily update" + printf " ${MIN} ${HOUR} * * * root /usr/bin/pveupdate\n\n" > /etc/cron.d/pveupdate + fi + 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