From 4027c59b6f16e30b459daae6610c5ea9e178d613 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 23 Mar 2012 06:48:33 +0100 Subject: [PATCH] update subscription info with cron job Note: This code only run when when there is subscription key uploaded. --- bin/cron/daily/pve | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/bin/cron/daily/pve b/bin/cron/daily/pve index d083082a..d8d7a7ca 100644 --- a/bin/cron/daily/pve +++ b/bin/cron/daily/pve @@ -1,15 +1,37 @@ #!/usr/bin/perl -w use strict; -use PVE::Cluster; -use PVE::APLInfo; -use PVE::SafeSyslog; use IO::File; use File::Find; use File::stat; +use PVE::Cluster; +use PVE::APLInfo; +use PVE::SafeSyslog; +use PVE::RPCEnvironment; +use PVE::API2::Subscription; + initlog ('pvedailycron', 'daemon'); +die "please run as root\n" if $> != 0; + +$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; + +PVE::INotify::inotify_init(); + +my $rpcenv = PVE::RPCEnvironment->init('cli'); + +$rpcenv->init_request(); +$rpcenv->set_language($ENV{LANG}); +$rpcenv->set_user('root@pam'); + +my $nodename = PVE::INotify::nodename(); + +eval { PVE::API2::Subscription->update({ node => $nodename }); }; +if (my $err = $@) { + syslog ('err', "update subscription info failed: $err"); +} + my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg'); eval { PVE::APLInfo::update($dccfg->{http_proxy}); }; if (my $err = $@) {