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 3.0.0alpha, released 23 Jan 2006.
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 ? $Lang->{Type_full} : $Lang->{Type_incr};
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}}");
73 my $content = eval ("qq{$Lang->{REPLY_FROM_SERVER}}");
74 Header(eval ("qq{$Lang->{BackupPC__Backup_Requested_on__host}}"),$content);
79 $bpc->ConfigRead($host);
82 my $checkHost = $host;
83 $checkHost = $Conf{ClientNameAlias}
84 if ( $Conf{ClientNameAlias} ne "" );
85 my $ipAddr = ConfirmIPAddress($checkHost);
86 my $content = eval("qq{$Lang->{Are_you_sure_start}}");
87 Header(eval("qq{$Lang->{BackupPC__Start_Backup_Confirm_on__host}}"),$content);
90 GetStatusInfo("host(${EscURI($host)})");
91 if ( $StatusHost{backoffTime} > time ) {
92 $backoff = sprintf("%.1f",
93 ($StatusHost{backoffTime} - time) / 3600);
95 my $content = eval ("qq{$Lang->{Are_you_sure_stop}}");
96 Header(eval("qq{$Lang->{BackupPC__Stop_Backup_Confirm_on__host}}"),