1 |
#============================================================= -*-perl-*- |
2 |
# |
3 |
# BackupPC::CGI::StartServer package |
4 |
# |
5 |
# DESCRIPTION |
6 |
# |
7 |
# This module implements the StartServer action for the CGI interface. |
8 |
# |
9 |
# AUTHOR |
10 |
# Craig Barratt <cbarratt@users.sourceforge.net> |
11 |
# |
12 |
# COPYRIGHT |
13 |
# Copyright (C) 2003 Craig Barratt |
14 |
# |
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. |
19 |
# |
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. |
24 |
# |
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 |
28 |
# |
29 |
#======================================================================== |
30 |
# |
31 |
# Version 2.1.2, released 5 Sep 2005. |
32 |
# |
33 |
# See http://backuppc.sourceforge.net. |
34 |
# |
35 |
#======================================================================== |
36 |
|
37 |
package BackupPC::CGI::StartServer; |
38 |
|
39 |
use strict; |
40 |
use BackupPC::CGI::Lib qw(:all); |
41 |
|
42 |
sub action |
43 |
{ |
44 |
if ( -f $Conf{ServerInitdPath} |
45 |
&& $bpc->{Conf}{ServerInitdStartCmd} ne "" |
46 |
&& !$bpc->ServerOK() ) { |
47 |
my $args = { |
48 |
serverInitdPath => $bpc->{Conf}{ServerInitdPath}, |
49 |
sshPath => $bpc->{Conf}{SshPath}, |
50 |
serverHost => $bpc->{Conf}{ServerHost}, |
51 |
}; |
52 |
my $serverInitdStartCmd = $bpc->cmdVarSubstitute($bpc->{Conf}{ServerInitdStartCmd}, $args); |
53 |
$bpc->cmdSystemOrEval($serverInitdStartCmd, undef, $args); |
54 |
for ( my $i = 0; $i < 10; $i++ ) { |
55 |
last unless ( $bpc->ServerConnect($Conf{ServerHost}, $Conf{ServerPort}) ); |
56 |
sleep(1); |
57 |
} |
58 |
$bpc->ServerDisconnect(); |
59 |
} |
60 |
print $Cgi->redirect($MyURL); |
61 |
} |
62 |
|
63 |
1; |