1 #============================================================= -*-perl-*-
3 # BackupPC::CGI::StartStopBackup package
7 # This module implements the StartStopBackup action for the CGI interface.
10 # Craig Barratt <cbarratt@users.sourceforge.net>
13 # Copyright (C) 2003 Craig Barratt
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 2 of the License, or
18 # (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #========================================================================
31 # Version 2.1.0_CVS, released 3 Jul 2003.
33 # See http://backuppc.sourceforge.net.
35 #========================================================================
37 package BackupPC::CGI::StartStopBackup;
40 use BackupPC::CGI::Lib qw(:all);
46 my $start = 1 if ( $In{action} eq $Lang->{Start_Incr_Backup}
47 || $In{action} eq $Lang->{Start_Full_Backup} );
48 my $doFull = $In{action} eq $Lang->{Start_Full_Backup} ? 1 : 0;
49 my $type = $doFull ? "full" : "incremental";
51 my $Privileged = CheckPermission($host);
54 ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_stop_or_start_backups}}"));
60 if ( $Hosts->{$host}{dhcp} ) {
61 $reply = $bpc->ServerMesg("backup $In{hostIP} ${EscURI($host)}"
63 $str = eval("qq{$Lang->{Backup_requested_on_DHCP__host}}");
65 $reply = $bpc->ServerMesg("backup ${EscURI($host)}"
66 . " ${EscURI($host)} $User $doFull");
67 $str = eval("qq{$Lang->{Backup_requested_on__host_by__User}}");
70 $reply = $bpc->ServerMesg("stop ${EscURI($host)} $User $In{backoff}");
71 $str = eval("qq{$Lang->{Backup_stopped_dequeued_on__host_by__User}}");
74 Header(eval ("qq{$Lang->{BackupPC__Backup_Requested_on__host}}") );
75 print (eval ("qq{$Lang->{REPLY_FROM_SERVER}}"));
80 my $ipAddr = ConfirmIPAddress($host);
82 Header(eval("qq{$Lang->{BackupPC__Start_Backup_Confirm_on__host}}"));
83 print (eval("qq{$Lang->{Are_you_sure_start}}"));
86 GetStatusInfo("host(${EscURI($host)})");
87 if ( $StatusHost{backoffTime} > time ) {
88 $backoff = sprintf("%.1f",
89 ($StatusHost{backoffTime} - time) / 3600);
91 Header($Lang->{BackupPC__Stop_Backup_Confirm_on__host});
92 print (eval ("qq{$Lang->{Are_you_sure_stop}}"));