You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
939 B
35 lines
939 B
12 years ago
|
#!/usr/bin/perl -w
|
||
|
|
||
|
use lib "/usr/share/BackupPC/lib";
|
||
|
use BackupPC::Lib;
|
||
|
use BackupPC::CGI::Lib;
|
||
|
use POSIX;
|
||
|
use JSON;
|
||
|
|
||
|
# We need to switch to backuppc UID/GID
|
||
|
my $uid = getuid();
|
||
|
my $gid = getgid();
|
||
|
my (undef,undef,$bkpuid,$bkpgid) = getpwnam('backuppc');
|
||
|
setuid($bkpuid) if ($uid ne $bkpuid);
|
||
|
setgid($bkpgid) if ($gid ne $bkpgid);
|
||
|
|
||
|
my $bpc = BackupPC::Lib->new();
|
||
|
my $hosts = $bpc->HostInfoRead();
|
||
|
my $mainConf = $bpc->ConfigDataRead();
|
||
|
|
||
12 years ago
|
my $json;
|
||
12 years ago
|
foreach my $host (keys %$hosts){
|
||
|
my $hostConf = $bpc->ConfigDataRead($host);
|
||
|
my $conf = { %$mainConf, %$hostConf };
|
||
|
my $period = ($conf->{FullPeriod} >= $conf->{IncrPeriod}) ? $conf->{IncrPeriod} : $conf->{FullPeriod};
|
||
|
my $status = ($conf->{BackupsDisable} eq 1) ? 'disabled':'enabled';
|
||
12 years ago
|
push @{$json->{data}},
|
||
12 years ago
|
{
|
||
|
"{#BPCHOST}" => $host,
|
||
|
"{#BPCPERIOD}" => $period,
|
||
|
"{#BPCSTATUS}" => $status,
|
||
|
};
|
||
|
}
|
||
12 years ago
|
print to_json($json);
|
||
12 years ago
|
exit(0);
|