From: Jeff H. <jha...@gm...> - 2011-02-11 01:32:44
|
On Thu, Feb 10, 2011 at 4:19 PM, Bowie Bailey <Bow...@bu...> wrote: > > #!/usr/bin/perl > $status = `/usr/local/BackupPC/bin/BackupPC_serverMesg status jobs`; > ($data) = $status =~ /Got reply: (\%Jobs = \(.*\);)/; > eval $data; > delete $Jobs{' trashClean '}; > if (not %Jobs) { > print "Shutting down now\n"; > # exec('shutdown -h now'); > } > > Not fully tested, but I think it'll work. You can run it as-is to test > things. Once you are sure it is working right, uncomment the shutdown line. > That seemed to work but would require some changes to sudoers so that the backuppc account could perform the halt. Easy to do but I came up with a simple solution based on my previous attempt that seems to work. DumpPreUserCmd: touch /var/lib/backuppc/dump-start.flg DumpPostUserCmd: mv /var/lib/backuppc/dump-start.flg /var/lib/backuppc/dump-end.flg /etc/cron.d/backuppc-halt: */5 * * * * root [ -f /var/lib/backuppc/dump-end.flg ] && sleep 3m && [ ! -f /var/lib/backuppc/dump-start.flg ] && rm /var/lib/backuppc/dump-end.flg && [ "$(/usr/bin/who)" = "" ] && /sbin/halt Description: Check every 5min for the dump end flag file. If found, wait 3min then check for the dump start flag file. If it is not found then all jobs have finished so remove the end flag file, check for active users, if none then halt system. The only issue is the length of the time window between the end of one dump and the start of the next. The 3 minute delay seems to be enough for my system. |