--- /dev/null
+#============================================================= -*-perl-*-
+#
+# BackupPC::CGI::StartStopBackup package
+#
+# DESCRIPTION
+#
+# This module implements the StartStopBackup action for the CGI interface.
+#
+# AUTHOR
+# Craig Barratt <cbarratt@users.sourceforge.net>
+#
+# COPYRIGHT
+# Copyright (C) 2003 Craig Barratt
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+#========================================================================
+#
+# Version 2.1.0_CVS, released 3 Jul 2003.
+#
+# See http://backuppc.sourceforge.net.
+#
+#========================================================================
+
+package BackupPC::CGI::StartStopBackup;
+
+use strict;
+use BackupPC::CGI::Lib qw(:all);
+
+sub action
+{
+ my($str, $reply);
+
+ my $start = 1 if ( $In{action} eq $Lang->{Start_Incr_Backup}
+ || $In{action} eq $Lang->{Start_Full_Backup} );
+ my $doFull = $In{action} eq $Lang->{Start_Full_Backup} ? 1 : 0;
+ my $type = $doFull ? "full" : "incremental";
+ my $host = $In{host};
+ my $Privileged = CheckPermission($host);
+
+ if ( !$Privileged ) {
+ ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_stop_or_start_backups}}"));
+ }
+ ServerConnect();
+
+ if ( $In{doit} ) {
+ if ( $start ) {
+ if ( $Hosts->{$host}{dhcp} ) {
+ $reply = $bpc->ServerMesg("backup $In{hostIP} ${EscURI($host)}"
+ . " $User $doFull");
+ $str = eval("qq{$Lang->{Backup_requested_on_DHCP__host}}");
+ } else {
+ $reply = $bpc->ServerMesg("backup ${EscURI($host)}"
+ . " ${EscURI($host)} $User $doFull");
+ $str = eval("qq{$Lang->{Backup_requested_on__host_by__User}}");
+ }
+ } else {
+ $reply = $bpc->ServerMesg("stop ${EscURI($host)} $User $In{backoff}");
+ $str = eval("qq{$Lang->{Backup_stopped_dequeued_on__host_by__User}}");
+ }
+
+ Header(eval ("qq{$Lang->{BackupPC__Backup_Requested_on__host}}") );
+ print (eval ("qq{$Lang->{REPLY_FROM_SERVER}}"));
+
+ Trailer();
+ } else {
+ if ( $start ) {
+ my $ipAddr = ConfirmIPAddress($host);
+
+ Header(eval("qq{$Lang->{BackupPC__Start_Backup_Confirm_on__host}}"));
+ print (eval("qq{$Lang->{Are_you_sure_start}}"));
+ } else {
+ my $backoff = "";
+ GetStatusInfo("host(${EscURI($host)})");
+ if ( $StatusHost{backoffTime} > time ) {
+ $backoff = sprintf("%.1f",
+ ($StatusHost{backoffTime} - time) / 3600);
+ }
+ Header($Lang->{BackupPC__Stop_Backup_Confirm_on__host});
+ print (eval ("qq{$Lang->{Are_you_sure_stop}}"));
+ }
+ Trailer();
+ }
+}
+
+1;