2 #============================================================= -*-perl-*-w
4 # BackupPC_Admin: Apache/CGI interface for BackupPC.
7 # BackupPC_Admin provides a flexible web interface for BackupPC.
8 # It is a CGI script that runs under Apache.
10 # It requires that Apache pass in $ENV{SCRIPT_NAME} and
11 # $ENV{REMOTE_USER}. The latter requires .ht_access style
12 # authentication. Replace the code below if you are using some other
13 # type of authentication, and have a different way of getting the
16 # Also, this script needs to run as the BackupPC user. To accomplish
17 # this the script is typically installed as setuid to the BackupPC user,
18 # or it can run under mod_perl with httpd running as the BackupPC user.
21 # Craig Barratt <cbarratt@users.sourceforge.net>
24 # Copyright (C) 2001-2003 Craig Barratt
26 # This program is free software; you can redistribute it and/or modify
27 # it under the terms of the GNU General Public License as published by
28 # the Free Software Foundation; either version 2 of the License, or
29 # (at your option) any later version.
31 # This program is distributed in the hope that it will be useful,
32 # but WITHOUT ANY WARRANTY; without even the implied warranty of
33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 # GNU General Public License for more details.
36 # You should have received a copy of the GNU General Public License
37 # along with this program; if not, write to the Free Software
38 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 #========================================================================
42 # Version 3.0.0beta1, released 30 Jul 2006.
44 # See http://backuppc.sourceforge.net.
46 #========================================================================
51 use CGI::Carp qw(fatalsToBrowser);
52 use lib "/usr/local/BackupPC/lib";
55 use BackupPC::CGI::Lib qw(:all);
57 BackupPC::CGI::Lib::NewRequest;
59 my %ActionDispatch = (
60 "summary" => "Summary",
61 "Start_Incr_Backup" => "StartStopBackup",
62 "Start_Full_Backup" => "StartStopBackup",
63 "Stop_Dequeue_Backup" => "StartStopBackup",
64 "Stop_Dequeue_Archive" => "StartStopBackup",
67 "LOGlist" => "LOGlist",
68 "emailSummary" => "EmailSummary",
70 "dirHistory" => "DirHistory",
71 "Restore" => "Restore",
72 "RestoreFile" => "RestoreFile",
73 "hostInfo" => "HostInfo",
74 "generalInfo" => "GeneralInfo",
75 "restoreInfo" => "RestoreInfo",
76 "archiveInfo" => "ArchiveInfo",
77 "Start_Archive" => "Archive",
78 "Archive" => "Archive",
79 "Reload" => "ReloadServer",
80 "startServer" => "StartServer",
81 "Stop" => "StopServer",
82 "adminOpts" => "AdminOptions",
83 "editConfig" => "EditConfig",
88 # Set default actions, then call sub handler
90 if ( !defined($ActionDispatch{$In{action}}) ) {
91 $In{action} = defined($In{host}) ? "hostInfo" : "generalInfo";
93 my $action = $ActionDispatch{$In{action}};
96 # For some reason under mod_perl, the use lib above is unreliable,
97 # and sometimes the module below cannot be found. Explicitly push
98 # the directory onto INC if it is missing. This is an ugly hack;
99 # need to figure out what's really going on...
101 my $installDir = '/usr/local/BackupPC/lib';
102 push(@INC, $installDir) if ( !grep($_ eq $installDir, @INC) );
105 # Load the relevant action script and run it
107 require "BackupPC/CGI/$action.pm"
108 if ( !defined($BackupPC::CGI::{"${action}::"}) );
109 $BackupPC::CGI::{"${action}::"}{action}();