configure.pl (BackupPC-4.3.2) | : | configure.pl (BackupPC-4.4.0) | ||
---|---|---|---|---|
skipping to change at line 39 | skipping to change at line 39 | |||
# This program is distributed in the hope that it will be useful, | # This program is distributed in the hope that it will be useful, | |||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
# GNU General Public License for more details. | # GNU General Public License for more details. | |||
# | # | |||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | |||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
# | # | |||
#======================================================================== | #======================================================================== | |||
# | # | |||
# Version 4.3.2, released 17 Feb 2020. | # Version 4.4.0, released 20 Jun 2020. | |||
# | # | |||
# See http://backuppc.sourceforge.net. | # See http://backuppc.sourceforge.net. | |||
# | # | |||
#======================================================================== | #======================================================================== | |||
use strict; | use strict; | |||
no utf8; | no utf8; | |||
use vars qw(%Conf %OrigConf $Upgrade); | use vars qw(%Conf %OrigConf $Upgrade); | |||
use lib "./lib"; | use lib "./lib"; | |||
# | # | |||
# The two strings below are replaced with the full list of BackupPC executables | # The two strings below are replaced with the full list of BackupPC executables | |||
# and libraries by makeDist. | # and libraries by makeDist. | |||
# | # | |||
my @ConfigureBinList = qw( | my @ConfigureBinList = qw( | |||
bin/BackupPC | bin/BackupPC | |||
bin/BackupPC_Admin_SCGI | bin/BackupPC_Admin_SCGI | |||
skipping to change at line 79 | skipping to change at line 79 | |||
bin/BackupPC_poolCntPrint | bin/BackupPC_poolCntPrint | |||
bin/BackupPC_refCountUpdate | bin/BackupPC_refCountUpdate | |||
bin/BackupPC_restore | bin/BackupPC_restore | |||
bin/BackupPC_rrdUpdate | bin/BackupPC_rrdUpdate | |||
bin/BackupPC_sendEmail | bin/BackupPC_sendEmail | |||
bin/BackupPC_serverMesg | bin/BackupPC_serverMesg | |||
bin/BackupPC_tarCreate | bin/BackupPC_tarCreate | |||
bin/BackupPC_tarExtract | bin/BackupPC_tarExtract | |||
bin/BackupPC_zcat | bin/BackupPC_zcat | |||
bin/BackupPC_zipCreate | bin/BackupPC_zipCreate | |||
); | ); | |||
my @ConfigureLibList = qw( | my @ConfigureLibList = qw( | |||
lib/BackupPC/Config/Meta.pm | lib/BackupPC/Config/Meta.pm | |||
lib/BackupPC/DirOps.pm | lib/BackupPC/DirOps.pm | |||
lib/BackupPC/Lib.pm | lib/BackupPC/Lib.pm | |||
lib/BackupPC/Storage.pm | lib/BackupPC/Storage.pm | |||
lib/BackupPC/View.pm | lib/BackupPC/View.pm | |||
lib/BackupPC/Xfer/Archive.pm | lib/BackupPC/Xfer/Archive.pm | |||
lib/BackupPC/Xfer/Ftp.pm | lib/BackupPC/Xfer/Ftp.pm | |||
lib/BackupPC/Xfer/Protocol.pm | lib/BackupPC/Xfer/Protocol.pm | |||
lib/BackupPC/Xfer/Rsync.pm | lib/BackupPC/Xfer/Rsync.pm | |||
skipping to change at line 108 | skipping to change at line 108 | |||
lib/BackupPC/CGI/ArchiveInfo.pm | lib/BackupPC/CGI/ArchiveInfo.pm | |||
lib/BackupPC/CGI/Browse.pm | lib/BackupPC/CGI/Browse.pm | |||
lib/BackupPC/CGI/DeleteBackup.pm | lib/BackupPC/CGI/DeleteBackup.pm | |||
lib/BackupPC/CGI/DirHistory.pm | lib/BackupPC/CGI/DirHistory.pm | |||
lib/BackupPC/CGI/EditConfig.pm | lib/BackupPC/CGI/EditConfig.pm | |||
lib/BackupPC/CGI/EmailSummary.pm | lib/BackupPC/CGI/EmailSummary.pm | |||
lib/BackupPC/CGI/GeneralInfo.pm | lib/BackupPC/CGI/GeneralInfo.pm | |||
lib/BackupPC/CGI/HostInfo.pm | lib/BackupPC/CGI/HostInfo.pm | |||
lib/BackupPC/CGI/Lib.pm | lib/BackupPC/CGI/Lib.pm | |||
lib/BackupPC/CGI/LOGlist.pm | lib/BackupPC/CGI/LOGlist.pm | |||
lib/BackupPC/CGI/Metrics.pm | ||||
lib/BackupPC/CGI/Queue.pm | lib/BackupPC/CGI/Queue.pm | |||
lib/BackupPC/CGI/ReloadServer.pm | lib/BackupPC/CGI/ReloadServer.pm | |||
lib/BackupPC/CGI/Restore.pm | lib/BackupPC/CGI/Restore.pm | |||
lib/BackupPC/CGI/RestoreFile.pm | lib/BackupPC/CGI/RestoreFile.pm | |||
lib/BackupPC/CGI/RestoreInfo.pm | lib/BackupPC/CGI/RestoreInfo.pm | |||
lib/BackupPC/CGI/RSS.pm | ||||
lib/BackupPC/CGI/StartServer.pm | lib/BackupPC/CGI/StartServer.pm | |||
lib/BackupPC/CGI/StartStopBackup.pm | lib/BackupPC/CGI/StartStopBackup.pm | |||
lib/BackupPC/CGI/StopServer.pm | lib/BackupPC/CGI/StopServer.pm | |||
lib/BackupPC/CGI/Summary.pm | lib/BackupPC/CGI/Summary.pm | |||
lib/BackupPC/CGI/View.pm | lib/BackupPC/CGI/View.pm | |||
lib/BackupPC/Lang/cz.pm | lib/BackupPC/Lang/cz.pm | |||
lib/BackupPC/Lang/de.pm | lib/BackupPC/Lang/de.pm | |||
lib/BackupPC/Lang/en.pm | lib/BackupPC/Lang/en.pm | |||
lib/BackupPC/Lang/es.pm | lib/BackupPC/Lang/es.pm | |||
lib/BackupPC/Lang/fr.pm | lib/BackupPC/Lang/fr.pm | |||
lib/BackupPC/Lang/it.pm | lib/BackupPC/Lang/it.pm | |||
lib/BackupPC/Lang/ja.pm | lib/BackupPC/Lang/ja.pm | |||
lib/BackupPC/Lang/nl.pm | lib/BackupPC/Lang/nl.pm | |||
lib/BackupPC/Lang/pl.pm | lib/BackupPC/Lang/pl.pm | |||
lib/BackupPC/Lang/pt_br.pm | lib/BackupPC/Lang/pt_br.pm | |||
lib/BackupPC/Lang/ru.pm | lib/BackupPC/Lang/ru.pm | |||
lib/BackupPC/Lang/uk.pm | lib/BackupPC/Lang/uk.pm | |||
lib/BackupPC/Lang/zh_CN.pm | lib/BackupPC/Lang/zh_CN.pm | |||
lib/BackupPC/Storage/Text.pm | lib/BackupPC/Storage/Text.pm | |||
); | ); | |||
# | # | |||
# Check that makeDist has been run; need to avoid having the magic string | # Check that makeDist has been run; need to avoid having the magic string | |||
# appear exactly (otherwise makeDist will replace it), so compute it instead | # appear exactly (otherwise makeDist will replace it), so compute it instead | |||
# | # | |||
if ( $ConfigureBinList[0] eq "__" . "CONFIGURE_BIN_LIST__" ) { | if ( $ConfigureBinList[0] eq "__" . "CONFIGURE_BIN_LIST__" ) { | |||
die <<EOF; | die <<EOF; | |||
You need to run makeDist first to create a tarball release that includes an | You need to run makeDist first to create a tarball release that includes an | |||
updated configure.pl. After you unpack the tarball, run configure.pl from | updated configure.pl. After you unpack the tarball, run configure.pl from | |||
there. | there. | |||
EOF | EOF | |||
} | } | |||
my @Packages = qw(version Encode Socket File::Path File::Spec File::Copy | my @Packages = qw(version Encode Socket File::Path File::Spec File::Copy | |||
Digest::MD5 Data::Dumper Getopt::Std Getopt::Long Pod::Usage | Digest::MD5 Data::Dumper Getopt::Std Getopt::Long Pod::Usage | |||
File::Listing CGI BackupPC::XS BackupPC::Lib); | File::Listing CGI BackupPC::XS BackupPC::Lib); | |||
my $PackageVersion = { | my $PackageVersion = { | |||
"Encode" => "1.99", | "Encode" => "1.99", | |||
"BackupPC::XS" => "0.53", | "BackupPC::XS" => "0.62", | |||
}; | }; | |||
foreach my $pkg ( @Packages ) { | foreach my $pkg ( @Packages ) { | |||
eval "use $pkg"; | eval "use $pkg"; | |||
if ( !$@ ) { | if ( !$@ ) { | |||
next if ( !defined($PackageVersion->{$pkg}) ); | next if ( !defined($PackageVersion->{$pkg}) ); | |||
my $ver = eval "\$${pkg}::VERSION"; | my $ver = eval "\$${pkg}::VERSION"; | |||
next if ( version->parse($ver) >= version->parse($PackageVersion->{$pkg} ) ); | next if ( version->parse($ver) >= version->parse($PackageVersion->{$pkg} ) ); | |||
die <<EOF; | die <<EOF; | |||
Perl package $pkg needs to be at least version $PackageVersion->{$pkg}. | Perl package $pkg needs to be at least version $PackageVersion->{$pkg}. | |||
skipping to change at line 179 | skipping to change at line 179 | |||
EOF | EOF | |||
} | } | |||
if ( $pkg =~ /BackupPC::Lib/ ) { | if ( $pkg =~ /BackupPC::Lib/ ) { | |||
die <<EOF; | die <<EOF; | |||
Error loading $pkg: $@ | Error loading $pkg: $@ | |||
BackupPC cannot load the package $pkg, which is included in the | BackupPC cannot load the package $pkg, which is included in the | |||
BackupPC distribution. This probably means you did not cd to the | BackupPC distribution. This probably means you did not cd to the | |||
unpacked BackupPC distribution before running configure.pl, eg: | unpacked BackupPC distribution before running configure.pl, eg: | |||
cd BackupPC-4.3.2 | cd BackupPC-4.4.0 | |||
./configure.pl | ./configure.pl | |||
Please try again. | Please try again. | |||
EOF | EOF | |||
} | } | |||
die <<EOF; | die <<EOF; | |||
BackupPC needs the perl package "$pkg". Please install "$pkg" | BackupPC needs the perl package "$pkg". Please install "$pkg" | |||
(eg, using cpan) before installing BackupPC. | (eg, using cpan) before installing BackupPC. | |||
EOF | EOF | |||
} | } | |||
my %opts; | my %opts; | |||
$opts{"set-perms"} = 1; | $opts{"set-perms"} = 1; | |||
if ( !GetOptions( | if ( | |||
\%opts, | !GetOptions( | |||
"batch", | \%opts, "batch", "backuppc-user=s", "bin-path=s%", | |||
"backuppc-user=s", | "cgi-dir=s", "compress-level=i", "config-path=s", "config-overrid | |||
"bin-path=s%", | e=s%", | |||
"cgi-dir=s", | "config-dir=s", "config-only", "data-dir=s", "dest-dir=s", | |||
"compress-level=i", | "fhs!", "help|?", "hostname=s", "html-dir=s", | |||
"config-path=s", | "html-dir-url=s", "install-dir=s", "log-dir=s", "man", | |||
"config-override=s%", | "run-dir=s", "scgi-port=i", "set-perms!", "uid-ignore!", | |||
"config-dir=s", | ) | |||
"config-only", | || @ARGV | |||
"data-dir=s", | ) { | |||
"dest-dir=s", | ||||
"fhs!", | ||||
"help|?", | ||||
"hostname=s", | ||||
"html-dir=s", | ||||
"html-dir-url=s", | ||||
"install-dir=s", | ||||
"log-dir=s", | ||||
"man", | ||||
"run-dir=s", | ||||
"scgi-port=i", | ||||
"set-perms!", | ||||
"uid-ignore!", | ||||
) || @ARGV ) { | ||||
pod2usage(2); | pod2usage(2); | |||
} | } | |||
pod2usage(1) if ( $opts{help} ); | pod2usage(1) if ( $opts{help} ); | |||
pod2usage(-exitstatus => 0, -verbose => 2) if $opts{man}; | pod2usage(-exitstatus => 0, -verbose => 2) if $opts{man}; | |||
my $DestDir = $opts{"dest-dir"}; | my $DestDir = $opts{"dest-dir"}; | |||
$DestDir = "" if ( $DestDir eq "/" ); | $DestDir = "" if ( $DestDir eq "/" ); | |||
if ( !$opts{"uid-ignore"} && $< != 0 ) { | if ( !$opts{"uid-ignore"} && $< != 0 ) { | |||
print <<EOF; | print <<EOF; | |||
This configure script should be run as root, rather than uid $<. | This configure script should be run as root, rather than uid $<. | |||
Provided uid $< has sufficient permissions to create the data and | Provided uid $< has sufficient permissions to create the data and | |||
install directories, then it should be ok to proceed. Otherwise, | install directories, then it should be ok to proceed. Otherwise, | |||
please quit and restart as root. | please quit and restart as root. | |||
EOF | EOF | |||
exit(1) if ( prompt("--> Do you want to continue?", | exit(1) if ( prompt("--> Do you want to continue?", "y") !~ /y/i ); | |||
"y") !~ /y/i ); | ||||
exit(1) if ( $opts{batch} && !$opts{"uid-ignore"} ); | exit(1) if ( $opts{batch} && !$opts{"uid-ignore"} ); | |||
} | } | |||
# | # | |||
# Whether we use the file system hierarchy conventions or not. | # Whether we use the file system hierarchy conventions or not. | |||
# Older versions did not. BackupPC used to be installed in | # Older versions did not. BackupPC used to be installed in | |||
# two main directories (in addition to CGI and html pages) | # two main directories (in addition to CGI and html pages) | |||
# | # | |||
# TopDir which includes subdirs conf, log, pc, pool, cpool | # TopDir which includes subdirs conf, log, pc, pool, cpool | |||
# | # | |||
skipping to change at line 267 | skipping to change at line 251 | |||
# /etc/BackupPC/hosts hosts file (was $TopDir/conf/hosts) | # /etc/BackupPC/hosts hosts file (was $TopDir/conf/hosts) | |||
# /etc/BackupPC/pc/HOST.pl per-pc config file (was $TopDir/pc/HOST/config.pl) | # /etc/BackupPC/pc/HOST.pl per-pc config file (was $TopDir/pc/HOST/config.pl) | |||
# /var/log/BackupPC log files (was $TopDir/log) | # /var/log/BackupPC log files (was $TopDir/log) | |||
# /var/log/BackupPC Pid, status and email info (was $TopDir/log) | # /var/log/BackupPC Pid, status and email info (was $TopDir/log) | |||
# | # | |||
# | # | |||
# Check if this is an upgrade, in which case read the existing | # Check if this is an upgrade, in which case read the existing | |||
# config file to get all the defaults. | # config file to get all the defaults. | |||
# | # | |||
my $ConfigDir = $opts{"config-dir"} || "/etc/BackupPC"; | my $ConfigDir = $opts{"config-dir"} || "/etc/BackupPC"; | |||
my $ConfigPath = ""; | my $ConfigPath = ""; | |||
my $ConfigFileOK = 1; | my $ConfigFileOK = 1; | |||
while ( 1 ) { | while ( 1 ) { | |||
if ( $ConfigFileOK && -f "$DestDir$ConfigDir/config.pl" | if ( $ConfigFileOK | |||
&& (!defined($opts{fhs}) || $opts{fhs}) && !defined($opts{"config-pa | && -f "$DestDir$ConfigDir/config.pl" | |||
th"}) ) { | && (!defined($opts{fhs}) || $opts{fhs}) | |||
&& !defined($opts{"config-path"}) ) { | ||||
$ConfigPath = "$ConfigDir/config.pl"; | $ConfigPath = "$ConfigDir/config.pl"; | |||
$opts{fhs} = 1 if ( !defined($opts{fhs}) ); | $opts{fhs} = 1 if ( !defined($opts{fhs}) ); | |||
print <<EOF; | print <<EOF; | |||
Found $DestDir$ConfigDir/config.pl, so this is an upgrade of an | Found $DestDir$ConfigDir/config.pl, so this is an upgrade of an | |||
existing BackupPC installation. We will verify some existing | existing BackupPC installation. We will verify some existing | |||
information, but you will probably not need to make any | information, but you will probably not need to make any | |||
changes - just hit ENTER to each question. | changes - just hit ENTER to each question. | |||
EOF | EOF | |||
} else { | } else { | |||
print <<EOF; | print <<EOF; | |||
Is this a new installation or upgrade for BackupPC? If this is | Is this a new installation or upgrade for BackupPC? If this is | |||
an upgrade please tell me the full path of the existing BackupPC | an upgrade please tell me the full path of the existing BackupPC | |||
configuration file (eg: $ConfigDir/config.pl). Otherwise, just | configuration file (eg: $ConfigDir/config.pl). Otherwise, just | |||
hit return. | hit return. | |||
EOF | EOF | |||
$ConfigPath = prompt("--> Full path to existing main config.pl", | $ConfigPath = prompt("--> Full path to existing main config.pl", $Config | |||
$ConfigPath, | Path, "config-path"); | |||
"config-path"); | ||||
} | } | |||
last if ( $ConfigPath eq "" | last if ( $ConfigPath eq "" | |||
|| ($ConfigPath =~ /^\// && -f "$DestDir$ConfigPath" && -w "$DestDir $ConfigPath") ); | || ($ConfigPath =~ /^\// && -f "$DestDir$ConfigPath" && -w "$DestDir$Con figPath") ); | |||
my $problem = "is not an absolute path"; | my $problem = "is not an absolute path"; | |||
$problem = "is not writable" if ( !-w $ConfigPath ); | $problem = "is not writable" if ( !-w $ConfigPath ); | |||
$problem = "is not readable" if ( !-r $ConfigPath ); | $problem = "is not readable" if ( !-r $ConfigPath ); | |||
$problem = "is not a regular file" if ( !-f $ConfigPath ); | $problem = "is not a regular file" if ( !-f $ConfigPath ); | |||
$problem = "doesn't exist" if ( !-e $ConfigPath ); | $problem = "doesn't exist" if ( !-e $ConfigPath ); | |||
print("The file '$DestDir$ConfigPath' $problem.\n"); | print("The file '$DestDir$ConfigPath' $problem.\n"); | |||
if ( $opts{batch} ) { | if ( $opts{batch} ) { | |||
print("Need to specify a valid --config-path for upgrade\n"); | print("Need to specify a valid --config-path for upgrade\n"); | |||
exit(1); | exit(1); | |||
} | } | |||
$ConfigFileOK = 0; | $ConfigFileOK = 0; | |||
} | } | |||
$opts{fhs} = 1 if ( !defined($opts{fhs}) && $ConfigPath eq "" ); | $opts{fhs} = 1 if ( !defined($opts{fhs}) && $ConfigPath eq "" ); | |||
my $bpc; | my $bpc; | |||
if ( $ConfigPath ne "" && -r "$DestDir$ConfigPath" ) { | if ( $ConfigPath ne "" && -r "$DestDir$ConfigPath" ) { | |||
($ConfigDir = $ConfigPath) =~ s{/[^/]+$}{}; | ($ConfigDir = $ConfigPath) =~ s{/[^/]+$}{}; | |||
# In config-only mode use installed BackupPC if distribution files are not a vailable. | # In config-only mode use installed BackupPC if distribution files are not a vailable. | |||
my $libPath = ($opts{"config-only"} && ($INC{"BackupPC/Lib.pm"} ne "lib/Back | my $libPath = ($opts{"config-only"} && ($INC{"BackupPC/Lib.pm"} ne "lib/Back | |||
upPC/Lib.pm")) | upPC/Lib.pm")) ? "" : "."; | |||
? "" : "."; | ||||
die("BackupPC::Lib->new failed\n") | die("BackupPC::Lib->new failed\n") | |||
if ( !($bpc = BackupPC::Lib->new(".", $libPath, "$DestDir$ConfigDir" | if ( !($bpc = BackupPC::Lib->new(".", $libPath, "$DestDir$ConfigDir", 1)) | |||
, 1)) ); | ); | |||
%Conf = $bpc->Conf(); | %Conf = $bpc->Conf(); | |||
%OrigConf = %Conf; | %OrigConf = %Conf; | |||
$Upgrade = 1; | $Upgrade = 1; | |||
if ( !defined($opts{fhs}) ) { | if ( !defined($opts{fhs}) ) { | |||
if ( $ConfigPath eq "$Conf{TopDir}/conf/config.pl" ) { | if ( $ConfigPath eq "$Conf{TopDir}/conf/config.pl" ) { | |||
$opts{fhs} = 0; | $opts{fhs} = 0; | |||
} else { | } else { | |||
$opts{fhs} = 1; | $opts{fhs} = 1; | |||
} | } | |||
} | } | |||
if ( !$opts{fhs} ) { | if ( !$opts{fhs} ) { | |||
($Conf{TopDir} = $ConfigPath) =~ s{/[^/]+/[^/]+$}{} | ($Conf{TopDir} = $ConfigPath) =~ s{/[^/]+/[^/]+$}{} | |||
if ( $Conf{TopDir} eq '' ); | if ( $Conf{TopDir} eq '' ); | |||
$bpc->{LogDir} = $Conf{LogDir} = "$Conf{TopDir}/log" | $bpc->{LogDir} = $Conf{LogDir} = "$Conf{TopDir}/log" | |||
if ( $Conf{LogDir} eq '' ); | if ( $Conf{LogDir} eq '' ); | |||
$bpc->{RunDir} = $Conf{RunDir} = "$Conf{TopDir}/log" | $bpc->{RunDir} = $Conf{RunDir} = "$Conf{TopDir}/log" | |||
if ( $Conf{RunDir} eq '' ); | if ( $Conf{RunDir} eq '' ); | |||
} | } | |||
$bpc->{ConfDir} = $Conf{ConfDir} = $ConfigDir; | $bpc->{ConfDir} = $Conf{ConfDir} = $ConfigDir; | |||
if ( !length($DestDir) ) { | if ( !length($DestDir) ) { | |||
my $err = $bpc->ServerConnect($Conf{ServerHost}, $Conf{ServerPort}, 1); | my $err = $bpc->ServerConnect($Conf{ServerHost}, $Conf{ServerPort}, 1); | |||
if ( $err eq "" ) { | if ( $err eq "" ) { | |||
print <<EOF; | print <<EOF; | |||
BackupPC is running on $Conf{ServerHost}. You need to stop BackupPC before | BackupPC is running on $Conf{ServerHost}. You need to stop BackupPC before | |||
you can upgrade the code. Depending upon your installation, you could | you can upgrade the code. Depending upon your installation, you could | |||
run "systemctl stop backuppc.service" if you use systemd, | run "systemctl stop backuppc.service" if you use systemd, | |||
skipping to change at line 359 | skipping to change at line 343 | |||
EOF | EOF | |||
exit(1); | exit(1); | |||
} | } | |||
} | } | |||
} | } | |||
# | # | |||
# Create filesystem hierarchy defaults | # Create filesystem hierarchy defaults | |||
# | # | |||
$Conf{TopDir} ||= $opts{"data-dir"} || "/data/BackupPC"; | $Conf{TopDir} ||= $opts{"data-dir"} || "/data/BackupPC"; | |||
$Conf{InstallDir} ||= $opts{"install-dir"} || "/usr/local/BackupPC"; | $Conf{InstallDir} ||= $opts{"install-dir"} || "/usr/local/BackupPC"; | |||
# | # | |||
# These are the programs whose paths we need to find | # These are the programs whose paths we need to find | |||
# | # | |||
my %Programs = ( | my %Programs = ( | |||
perl => "PerlPath", | perl => "PerlPath", | |||
rsync_bpc => "RsyncBackupPCPath", | rsync_bpc => "RsyncBackupPCPath", | |||
'gtar/tar' => "TarClientPath", | 'gtar/tar' => "TarClientPath", | |||
smbclient => "SmbClientPath", | smbclient => "SmbClientPath", | |||
nmblookup => "NmbLookupPath", | nmblookup => "NmbLookupPath", | |||
rsync => "RsyncClientPath", | rsync => "RsyncClientPath", | |||
ping => "PingPath", | ping => "PingPath", | |||
ping6 => "Ping6Path", | ping6 => "Ping6Path", | |||
df => "DfPath", | df => "DfPath", | |||
'ssh/ssh2' => "SshPath", | 'ssh/ssh2' => "SshPath", | |||
sendmail => "SendmailPath", | sendmail => "SendmailPath", | |||
hostname => "HostnamePath", | hostname => "HostnamePath", | |||
split => "SplitPath", | split => "SplitPath", | |||
par2 => "ParPath", | par2 => "ParPath", | |||
cat => "CatPath", | cat => "CatPath", | |||
gzip => "GzipPath", | gzip => "GzipPath", | |||
bzip2 => "Bzip2Path", | bzip2 => "Bzip2Path", | |||
rrdtool => "RrdToolPath", | rrdtool => "RrdToolPath", | |||
); | ); | |||
foreach my $prog ( sort(keys(%Programs)) ) { | foreach my $prog ( sort(keys(%Programs)) ) { | |||
my $path; | my $path; | |||
foreach my $subProg ( split(/\//, $prog) ) { | foreach my $subProg ( split(/\//, $prog) ) { | |||
$path = FindProgram("$ENV{PATH}:/usr/bin:/bin:/sbin:/usr/sbin:/usr/local | $path = FindProgram("$ENV{PATH}:/usr/bin:/bin:/sbin:/usr/sbin:/usr/local | |||
/bin", | /bin", $subProg) if ( !length($path) ); | |||
$subProg) if ( !length($path) ); | ||||
} | } | |||
$Conf{$Programs{$prog}} = $path if ( !length($Conf{$Programs{$prog}}) ); | $Conf{$Programs{$prog}} = $path if ( !length($Conf{$Programs{$prog}}) ); | |||
} | } | |||
while ( 1 ) { | while ( 1 ) { | |||
print <<EOF; | print <<EOF; | |||
I found the following locations for these programs: | I found the following locations for these programs: | |||
EOF | EOF | |||
foreach my $prog ( sort(keys(%Programs)) ) { | foreach my $prog ( sort(keys(%Programs)) ) { | |||
printf(" %-12s => %s\n", $prog, $Conf{$Programs{$prog}}); | printf(" %-12s => %s\n", $prog, $Conf{$Programs{$prog}}); | |||
} | } | |||
print "\n"; | print "\n"; | |||
last if (prompt('--> Are these paths correct?', 'y') =~ /^y/i); | last if ( prompt('--> Are these paths correct?', 'y') =~ /^y/i ); | |||
foreach my $prog ( sort(keys(%Programs)) ) { | foreach my $prog ( sort(keys(%Programs)) ) { | |||
$Conf{$Programs{$prog}} = prompt("--> $prog path", | $Conf{$Programs{$prog}} = prompt("--> $prog path", $Conf{$Programs{$prog | |||
$Conf{$Programs{$prog}}); | }}); | |||
} | } | |||
} | } | |||
my $Perl58 = system($Conf{PerlPath} | my $Perl58 = system($Conf{PerlPath} . q{ -e 'exit($^V && $^V ge v5.8.0 ? 1 : 0); | |||
. q{ -e 'exit($^V && $^V ge v5.8.0 ? 1 : 0);'}); | '}); | |||
if ( !$Perl58 ) { | if ( !$Perl58 ) { | |||
print <<EOF; | print <<EOF; | |||
BackupPC needs perl version 5.8.0 or later. $Conf{PerlPath} appears | BackupPC needs perl version 5.8.0 or later. $Conf{PerlPath} appears | |||
to be an older version. Please upgrade to a newer version of perl | to be an older version. Please upgrade to a newer version of perl | |||
and re-run this configure script. | and re-run this configure script. | |||
EOF | EOF | |||
exit(1); | exit(1); | |||
} | } | |||
print <<EOF; | print <<EOF; | |||
Please tell me the hostname of the machine that BackupPC will run on. | Please tell me the hostname of the machine that BackupPC will run on. | |||
EOF | EOF | |||
chomp($Conf{ServerHost} = `$Conf{HostnamePath}`) | chomp($Conf{ServerHost} = `$Conf{HostnamePath}`) | |||
if ( defined($Conf{HostnamePath}) && !defined($Conf{ServerHost}) ); | if ( defined($Conf{HostnamePath}) && !defined($Conf{ServerHost}) ); | |||
$Conf{ServerHost} = prompt("--> BackupPC will run on host", | $Conf{ServerHost} = prompt("--> BackupPC will run on host", $Conf{ServerHost}, " | |||
$Conf{ServerHost}, | hostname"); | |||
"hostname"); | ||||
print <<EOF; | print <<EOF; | |||
BackupPC should run as a dedicated user with limited privileges. You | BackupPC should run as a dedicated user with limited privileges. You | |||
need to create a user. This user will need read/write permission on | need to create a user. This user will need read/write permission on | |||
the main data directory and read/execute permission on the install | the main data directory and read/execute permission on the install | |||
directory (these directories will be setup shortly). | directory (these directories will be setup shortly). | |||
The primary group for this user should also be chosen carefully. | The primary group for this user should also be chosen carefully. | |||
The data directories and files will have group read permission, | The data directories and files will have group read permission, | |||
so group members can access backup files. | so group members can access backup files. | |||
EOF | EOF | |||
my($name, $passwd, $Uid, $Gid); | my($name, $passwd, $Uid, $Gid); | |||
while ( 1 ) { | while ( 1 ) { | |||
$Conf{BackupPCUser} = prompt("--> BackupPC should run as user", | $Conf{BackupPCUser} = prompt("--> BackupPC should run as user", $Conf{Backup | |||
$Conf{BackupPCUser} || "backuppc", | PCUser} || "backuppc", "backuppc-user"); | |||
"backuppc-user"); | ||||
if ( $opts{"set-perms"} ) { | if ( $opts{"set-perms"} ) { | |||
($name, $passwd, $Uid, $Gid) = getpwnam($Conf{BackupPCUser}); | ($name, $passwd, $Uid, $Gid) = getpwnam($Conf{BackupPCUser}); | |||
last if ( $name ne "" ); | last if ( $name ne "" ); | |||
print <<EOF; | print <<EOF; | |||
getpwnam() says that user $Conf{BackupPCUser} doesn't exist. Please | getpwnam() says that user $Conf{BackupPCUser} doesn't exist. Please | |||
check the name and verify that this user is in the passwd file. | check the name and verify that this user is in the passwd file. | |||
EOF | EOF | |||
exit(1) if ( $opts{batch} ); | exit(1) if ( $opts{batch} ); | |||
skipping to change at line 477 | skipping to change at line 454 | |||
} | } | |||
print <<EOF; | print <<EOF; | |||
Please specify an install directory for BackupPC. This is where the | Please specify an install directory for BackupPC. This is where the | |||
BackupPC scripts, library and documentation will be installed. | BackupPC scripts, library and documentation will be installed. | |||
EOF | EOF | |||
while ( 1 ) { | while ( 1 ) { | |||
$Conf{InstallDir} = prompt("--> Install directory (full path)", | $Conf{InstallDir} = prompt("--> Install directory (full path)", $Conf{Instal | |||
$Conf{InstallDir}, | lDir}, "install-dir"); | |||
"install-dir"); | ||||
last if ( $Conf{InstallDir} =~ /^\// ); | last if ( $Conf{InstallDir} =~ /^\// ); | |||
if ( $opts{batch} ) { | if ( $opts{batch} ) { | |||
print("Need to specify --install-dir for new installation\n"); | print("Need to specify --install-dir for new installation\n"); | |||
exit(1); | exit(1); | |||
} | } | |||
} | } | |||
print <<EOF; | print <<EOF; | |||
Please specify a data directory for BackupPC. This is where all the | Please specify a data directory for BackupPC. This is where all the | |||
PC backup data is stored. This file system needs to be big enough to | PC backup data is stored. This file system needs to be big enough to | |||
accommodate all the PCs you expect to backup (eg: at least several GB | accommodate all the PCs you expect to backup (eg: at least several GB | |||
per machine). | per machine). | |||
EOF | EOF | |||
while ( 1 ) { | while ( 1 ) { | |||
$Conf{TopDir} = prompt("--> Data directory (full path)", | $Conf{TopDir} = prompt("--> Data directory (full path)", $Conf{TopDir}, "dat | |||
$Conf{TopDir}, | a-dir"); | |||
"data-dir"); | ||||
last if ( $Conf{TopDir} =~ /^\// ); | last if ( $Conf{TopDir} =~ /^\// ); | |||
if ( $opts{batch} ) { | if ( $opts{batch} ) { | |||
print("Need to specify --data-dir for new installation\n"); | print("Need to specify --data-dir for new installation\n"); | |||
exit(1); | exit(1); | |||
} | } | |||
} | } | |||
if ( $opts{fhs} ) { | if ( $opts{fhs} ) { | |||
$Conf{ConfDir} ||= $ConfigDir || "/etc/BackupPC"; | $Conf{ConfDir} ||= $ConfigDir || "/etc/BackupPC"; | |||
$Conf{LogDir} ||= $opts{"log-dir"} || "/var/log/BackupPC"; | $Conf{LogDir} ||= $opts{"log-dir"} || "/var/log/BackupPC"; | |||
$Conf{RunDir} ||= $opts{"run-dir"} || "/var/run/BackupPC"; | $Conf{RunDir} ||= $opts{"run-dir"} || "/var/run/BackupPC"; | |||
} else { | } else { | |||
$Conf{ConfDir} ||= $ConfigDir || "$Conf{TopDir}/conf"; | $Conf{ConfDir} ||= $ConfigDir || "$Conf{TopDir}/conf"; | |||
$Conf{LogDir} ||= $opts{"log-dir"} || "$Conf{TopDir}/log"; | $Conf{LogDir} ||= $opts{"log-dir"} || "$Conf{TopDir}/log"; | |||
$Conf{RunDir} ||= $opts{"run-dir"} || "$Conf{TopDir}/log"; | $Conf{RunDir} ||= $opts{"run-dir"} || "$Conf{TopDir}/log"; | |||
} | } | |||
$Conf{CompressLevel} = $opts{"compress-level"} | $Conf{CompressLevel} = $opts{"compress-level"} | |||
if ( defined($opts{"compress-level"}) ); | if ( defined($opts{"compress-level"}) ); | |||
print <<EOF; | print <<EOF; | |||
BackupPC has SCGI and CGI perl interfaces that run under Apache. You need | BackupPC has SCGI and CGI perl interfaces that run under Apache. You need | |||
to pick which one to run. | to pick which one to run. | |||
For SCGI, Apache uses the scgi_mod module to communicate with BackupPC_Admin_SCG I, | For SCGI, Apache uses the scgi_mod module to communicate with BackupPC_Admin_SCG I, | |||
which handles the requests. This allows Apache to run as a different user as | which handles the requests. This allows Apache to run as a different user as | |||
$Conf{BackupPCUser}. To use SCGI you need to set SCGIServerPort to any spare | $Conf{BackupPCUser}. To use SCGI you need to set SCGIServerPort to any spare | |||
non-privileged TCP port number. A negative value disables SCGI. | non-privileged TCP port number. A negative value disables SCGI. | |||
Important security warning!! The SCGIServerPort must not be accessible by | ** Important security warning!! The SCGIServerPort must not be accessible by | |||
anyone untrusted. That means you can't allow untrusted users access to the | ** anyone untrusted. That means you can't allow untrusted users access to the | |||
BackupPC server, and you should block the SCGIServerPort TCP port from | ** BackupPC server, and you should block the SCGIServerPort TCP port from | |||
network access. | ** network access. | |||
The traditional alternative is to use CGI. In this case, an executable needs | The traditional alternative is to use CGI. In this case, an executable needs | |||
to be installed Apache's cgi-bin directory. This executable needs to run as | to be installed Apache's cgi-bin directory. This executable needs to run as | |||
set-uid $Conf{BackupPCUser}, or it can be run under mod_perl with Apache | set-uid $Conf{BackupPCUser}, or it can be run under mod_perl with Apache | |||
running as user $Conf{BackupPCUser}. | running as user $Conf{BackupPCUser}. | |||
EOF | EOF | |||
$Conf{SCGIServerPort} = prompt("--> SCGI port (-1 to disable)", | $Conf{SCGIServerPort} = prompt("--> SCGI port (-1 to disable)", $Conf{SCGIServer | |||
$Conf{SCGIServerPort} || -1, | Port} || -1, "scgi-port"); | |||
"scgi-port"); | ||||
if ( $Conf{SCGIServerPort} < 0 ) { | if ( $Conf{SCGIServerPort} < 0 ) { | |||
while ( 1 ) { | while ( 1 ) { | |||
$Conf{CgiDir} = prompt("--> CGI bin directory (full path, or empty for n | $Conf{CgiDir} = prompt("--> CGI bin directory (full path, or empty for n | |||
o CGI)", | o CGI)", $Conf{CgiDir}, "cgi-dir"); | |||
$Conf{CgiDir}, | ||||
"cgi-dir"); | ||||
last if ( $Conf{CgiDir} =~ /^\// || $Conf{CgiDir} eq "" ); | last if ( $Conf{CgiDir} =~ /^\// || $Conf{CgiDir} eq "" ); | |||
if ( $opts{batch} ) { | if ( $opts{batch} ) { | |||
print("Need to specify --cgi-dir for new installation\n"); | print("Need to specify --cgi-dir for new installation\n"); | |||
exit(1); | exit(1); | |||
} | } | |||
} | } | |||
} | } | |||
if ( $Conf{SCGIServerPort} > 0 || $Conf{CgiDir} ne "" ) { | if ( $Conf{SCGIServerPort} > 0 || $Conf{CgiDir} ne "" ) { | |||
print <<EOF; | print <<EOF; | |||
skipping to change at line 574 | skipping to change at line 543 | |||
should be placed somewhere under Apache's DocumentRoot. BackupPC | should be placed somewhere under Apache's DocumentRoot. BackupPC | |||
also needs to know the URL to access these images. Example: | also needs to know the URL to access these images. Example: | |||
Apache image directory: /var/www/htdocs/BackupPC | Apache image directory: /var/www/htdocs/BackupPC | |||
URL for image directory: /BackupPC | URL for image directory: /BackupPC | |||
The URL for the image directory should start with a slash. | The URL for the image directory should start with a slash. | |||
EOF | EOF | |||
while ( 1 ) { | while ( 1 ) { | |||
$Conf{CgiImageDir} = prompt("--> Apache image directory (full path, or e | $Conf{CgiImageDir} = | |||
mpty for no S/CGI)", | prompt("--> Apache image directory (full path, or empty for no S/CGI)" | |||
$Conf{CgiImageDir}, | , $Conf{CgiImageDir}, "html-dir"); | |||
"html-dir"); | ||||
last if ( $Conf{CgiImageDir} =~ /^\// || $Conf{CgiImageDir} eq "" ); | last if ( $Conf{CgiImageDir} =~ /^\// || $Conf{CgiImageDir} eq "" ); | |||
if ( $opts{batch} ) { | if ( $opts{batch} ) { | |||
print("Need to specify --html-dir for new installation\n"); | print("Need to specify --html-dir for new installation\n"); | |||
exit(1); | exit(1); | |||
} | } | |||
} | } | |||
while ( 1 ) { | while ( 1 ) { | |||
$Conf{CgiImageDirURL} = prompt("--> URL for image directory (omit http:/ | $Conf{CgiImageDirURL} = | |||
/host; starts with '/', or empty for no S/CGI)", | prompt("--> URL for image directory (omit http://host; starts with '/' | |||
$Conf{CgiImageDirURL}, | , or empty for no S/CGI)", | |||
"html-dir-url"); | $Conf{CgiImageDirURL}, "html-dir-url"); | |||
last if ( $Conf{CgiImageDirURL} =~ /^\// || $Conf{CgiImageDirURL} eq "" ); | last if ( $Conf{CgiImageDirURL} =~ /^\// || $Conf{CgiImageDirURL} eq "" ); | |||
if ( $opts{batch} ) { | if ( $opts{batch} ) { | |||
print("Need to specify --html-dir-url for new installation\n"); | print("Need to specify --html-dir-url for new installation\n"); | |||
exit(1); | exit(1); | |||
} | } | |||
} | } | |||
} | } | |||
print <<EOF; | print <<EOF; | |||
skipping to change at line 620 | skipping to change at line 588 | |||
EOF | EOF | |||
exit unless prompt("--> Do you want to continue?", "y") =~ /y/i; | exit unless prompt("--> Do you want to continue?", "y") =~ /y/i; | |||
CleanPidSock(); | CleanPidSock(); | |||
DoInstall() if ( !$opts{"config-only"} ); | DoInstall() if ( !$opts{"config-only"} ); | |||
print("Installing config.pl and hosts in $DestDir$Conf{ConfDir}\n"); | print("Installing config.pl and hosts in $DestDir$Conf{ConfDir}\n"); | |||
InstallFile("conf/hosts", "$DestDir$Conf{ConfDir}/hosts.sample", 0644) | InstallFile("conf/hosts", "$DestDir$Conf{ConfDir}/hosts.sample", 0644) | |||
if ( !$opts{"config-only"} ); | if ( !$opts{"config-only"} ); | |||
my $hostsSample = $opts{"config-only"} ? "$DestDir$Conf{ConfDir}/hosts.sample" : "conf/hosts"; | my $hostsSample = $opts{"config-only"} ? "$DestDir$Conf{ConfDir}/hosts.sample" : "conf/hosts"; | |||
InstallFile($hostsSample, "$DestDir$Conf{ConfDir}/hosts", 0644) | InstallFile($hostsSample, "$DestDir$Conf{ConfDir}/hosts", 0644) | |||
if ( !-f "$DestDir$Conf{ConfDir}/hosts" ); | if ( !-f "$DestDir$Conf{ConfDir}/hosts" ); | |||
# | # | |||
# Now do the config file. If there is an existing config file we | # Now do the config file. If there is an existing config file we | |||
# merge in the new config file, adding any new configuration | # merge in the new config file, adding any new configuration | |||
# parameters and deleting ones that are no longer needed. | # parameters and deleting ones that are no longer needed. | |||
# | # | |||
my $dest = "$DestDir$Conf{ConfDir}/config.pl"; | my $dest = "$DestDir$Conf{ConfDir}/config.pl"; | |||
my $configSample = $opts{"config-only"} ? "$DestDir$Conf{ConfDir}/config.pl.samp le" : "conf/config.pl"; | my $configSample = $opts{"config-only"} ? "$DestDir$Conf{ConfDir}/config.pl.samp le" : "conf/config.pl"; | |||
my ($distConf, $distVars) = ConfigParse($configSample); | my($distConf, $distVars) = ConfigParse($configSample); | |||
my ($oldConf, $oldVars); | my($oldConf, $oldVars); | |||
my ($newConf, $newVars) = ($distConf, $distVars); | my($newConf, $newVars) = ($distConf, $distVars); | |||
if ( -f $dest ) { | if ( -f $dest ) { | |||
($oldConf, $oldVars) = ConfigParse($dest); | ($oldConf, $oldVars) = ConfigParse($dest); | |||
($newConf, $newVars) = ConfigMerge($oldConf, $oldVars, $distConf, $distVars) ; | ($newConf, $newVars) = ConfigMerge($oldConf, $oldVars, $distConf, $distVars) ; | |||
} | } | |||
# | # | |||
# Update various config parameters. The old config is in Conf{} | # Update various config parameters. The old config is in Conf{} | |||
# and the new config is an array in text form in $newConf->[]. | # and the new config is an array in text form in $newConf->[]. | |||
# | # | |||
$Conf{EMailFromUserName} ||= $Conf{BackupPCUser}; | $Conf{EMailFromUserName} ||= $Conf{BackupPCUser}; | |||
skipping to change at line 666 | skipping to change at line 635 | |||
} | } | |||
# | # | |||
# The smbclient commands have moved from hard-coded to the config file. | # The smbclient commands have moved from hard-coded to the config file. | |||
# $Conf{SmbClientArgs} no longer exists, so merge it into the new | # $Conf{SmbClientArgs} no longer exists, so merge it into the new | |||
# commands if it still exists. | # commands if it still exists. | |||
# | # | |||
if ( defined($Conf{SmbClientArgs}) ) { | if ( defined($Conf{SmbClientArgs}) ) { | |||
if ( $Conf{SmbClientArgs} ne "" ) { | if ( $Conf{SmbClientArgs} ne "" ) { | |||
foreach my $param ( qw(SmbClientRestoreCmd SmbClientFullCmd | foreach my $param ( qw(SmbClientRestoreCmd SmbClientFullCmd | |||
SmbClientIncrCmd) ) { | SmbClientIncrCmd) ) { | |||
$newConf->[$newVars->{$param}]{text} | $newConf->[$newVars->{$param}]{text} =~ s/(-E\s+-N)/$1 $Conf{SmbClie | |||
=~ s/(-E\s+-N)/$1 $Conf{SmbClientArgs}/; | ntArgs}/; | |||
} | } | |||
} | } | |||
delete($Conf{SmbClientArgs}); | delete($Conf{SmbClientArgs}); | |||
} | } | |||
# | # | |||
# CSS is now stored in a file rather than a big config variable. | # CSS is now stored in a file rather than a big config variable. | |||
# | # | |||
delete($Conf{CSSstylesheet}); | delete($Conf{CSSstylesheet}); | |||
# | # | |||
# The blackout timing settings are now stored in a list of hashes, rather | # The blackout timing settings are now stored in a list of hashes, rather | |||
# than three scalar parameters. | # than three scalar parameters. | |||
# | # | |||
if ( defined($Conf{BlackoutHourBegin}) ) { | if ( defined($Conf{BlackoutHourBegin}) ) { | |||
$Conf{BlackoutPeriods} = [ | $Conf{BlackoutPeriods} = [{ | |||
{ | hourBegin => $Conf{BlackoutHourBegin}, | |||
hourBegin => $Conf{BlackoutHourBegin}, | hourEnd => $Conf{BlackoutHourEnd}, | |||
hourEnd => $Conf{BlackoutHourEnd}, | weekDays => $Conf{BlackoutWeekDays}, | |||
weekDays => $Conf{BlackoutWeekDays}, | }]; | |||
} | ||||
]; | ||||
delete($Conf{BlackoutHourBegin}); | delete($Conf{BlackoutHourBegin}); | |||
delete($Conf{BlackoutHourEnd}); | delete($Conf{BlackoutHourEnd}); | |||
delete($Conf{BlackoutWeekDays}); | delete($Conf{BlackoutWeekDays}); | |||
} | } | |||
# | # | |||
# $Conf{RsyncLogLevel} has been replaced by $Conf{XferLogLevel} | # $Conf{RsyncLogLevel} has been replaced by $Conf{XferLogLevel} | |||
# | # | |||
if ( defined($Conf{RsyncLogLevel}) ) { | if ( defined($Conf{RsyncLogLevel}) ) { | |||
$Conf{XferLogLevel} = $Conf{RsyncLogLevel}; | $Conf{XferLogLevel} = $Conf{RsyncLogLevel}; | |||
skipping to change at line 724 | skipping to change at line 690 | |||
$Conf{ParPath} = '' if ( $Conf{ParPath} ne '' && !-x $Conf{ParPath} ); | $Conf{ParPath} = '' if ( $Conf{ParPath} ne '' && !-x $Conf{ParPath} ); | |||
# | # | |||
# Figure out sensible arguments for the ping command | # Figure out sensible arguments for the ping command | |||
# | # | |||
if ( defined($Conf{PingArgs}) ) { | if ( defined($Conf{PingArgs}) ) { | |||
$Conf{PingCmd} = '$pingPath ' . $Conf{PingArgs}; | $Conf{PingCmd} = '$pingPath ' . $Conf{PingArgs}; | |||
delete($Conf{PingArgs}); | delete($Conf{PingArgs}); | |||
} elsif ( $Upgrade && !defined($Conf{PingCmd}) ) { | } elsif ( $Upgrade && !defined($Conf{PingCmd}) ) { | |||
if ( $^O eq "solaris" || $^O eq "sunos" ) { | if ( $^O eq "solaris" || $^O eq "sunos" ) { | |||
$Conf{PingCmd} = '$pingPath -s $host 56 1'; | $Conf{PingCmd} = '$pingPath -s $host 56 1'; | |||
} elsif ( ($^O eq "linux" || $^O eq "openbsd" || $^O eq "netbsd") | } elsif ( ($^O eq "linux" || $^O eq "openbsd" || $^O eq "netbsd") | |||
&& !system("$Conf{PingPath} -c 1 -w 3 localhost") ) { | && !system("$Conf{PingPath} -c 1 -w 3 localhost") ) { | |||
$Conf{PingCmd} = '$pingPath -c 1 -w 3 $host'; | $Conf{PingCmd} = '$pingPath -c 1 -w 3 $host'; | |||
} else { | } else { | |||
$Conf{PingCmd} = '$pingPath -c 1 $host'; | $Conf{PingCmd} = '$pingPath -c 1 $host'; | |||
} | } | |||
} | } | |||
# | # | |||
# Figure out sensible arguments for the df command | # Figure out sensible arguments for the df command | |||
# | # | |||
if ( !defined($Conf{DfCmd}) ) { | if ( !defined($Conf{DfCmd}) ) { | |||
if ( $^O eq "solaris" || $^O eq "sunos" ) { | if ( $^O eq "solaris" || $^O eq "sunos" ) { | |||
$Conf{DfCmd} = '$dfPath -k $topDir'; | $Conf{DfCmd} = '$dfPath -k $topDir'; | |||
} | } | |||
} | } | |||
# | # | |||
# $Conf{SmbClientTimeout} is now $Conf{ClientTimeout} | # $Conf{SmbClientTimeout} is now $Conf{ClientTimeout} | |||
# | # | |||
if ( defined($Conf{SmbClientTimeout}) ) { | if ( defined($Conf{SmbClientTimeout}) ) { | |||
$Conf{ClientTimeout} = $Conf{SmbClientTimeout}; | $Conf{ClientTimeout} = $Conf{SmbClientTimeout}; | |||
delete($Conf{SmbClientTimeout}); | delete($Conf{SmbClientTimeout}); | |||
} | } | |||
skipping to change at line 776 | skipping to change at line 742 | |||
# So we need to extract the new hash of settings, update it, | # So we need to extract the new hash of settings, update it, | |||
# and merge the text. Ugh... | # and merge the text. Ugh... | |||
# | # | |||
my $new; | my $new; | |||
my $str = $distConf->[$distVars->{CgiUserConfigEdit}]{text}; | my $str = $distConf->[$distVars->{CgiUserConfigEdit}]{text}; | |||
$str =~ s/^\s*\$Conf\{.*?\}\s*=\s*/\$new = /m; | $str =~ s/^\s*\$Conf\{.*?\}\s*=\s*/\$new = /m; | |||
eval($str); | eval($str); | |||
foreach my $p ( keys(%$new) ) { | foreach my $p ( keys(%$new) ) { | |||
$new->{$p} = $Conf{CgiUserConfigEdit}{$p} | $new->{$p} = $Conf{CgiUserConfigEdit}{$p} | |||
if ( defined($Conf{CgiUserConfigEdit}{$p}) ); | if ( defined($Conf{CgiUserConfigEdit}{$p}) ); | |||
} | } | |||
$Conf{CgiUserConfigEdit} = $new; | $Conf{CgiUserConfigEdit} = $new; | |||
my $d = Data::Dumper->new([$new], [*value]); | my $d = Data::Dumper->new([$new], [*value]); | |||
$d->Indent(1); | $d->Indent(1); | |||
$d->Terse(1); | $d->Terse(1); | |||
$d->Sortkeys(1); | $d->Sortkeys(1); | |||
my $value = $d->Dump; | my $value = $d->Dump; | |||
$value =~ s/(.*)\n/$1;\n/s; | $value =~ s/(.*)\n/$1;\n/s; | |||
$newConf->[$newVars->{CgiUserConfigEdit}]{text} | $newConf->[$newVars->{CgiUserConfigEdit}]{text} =~ s/^(\s*\$Conf\{.*?\}\s*=\ | |||
=~ s/^(\s*\$Conf\{.*?\}\s*=\s*).*/$1$value/ms; | s*).*/$1$value/ms; | |||
} | } | |||
# | # | |||
# If this is an upgrade from V3, then set $Conf{PoolV3Enabled} | # If this is an upgrade from V3, then set $Conf{PoolV3Enabled} | |||
# and update $Conf{RsyncArgs} and $Conf{RsyncRestoreArgs}. | # and update $Conf{RsyncArgs} and $Conf{RsyncRestoreArgs}. | |||
# | # | |||
if ( $Upgrade && !defined($Conf{PoolV3Enabled}) ) { | if ( $Upgrade && !defined($Conf{PoolV3Enabled}) ) { | |||
$Conf{PoolV3Enabled} = 1; | $Conf{PoolV3Enabled} = 1; | |||
# | # | |||
# for an upgrade, remove the new --one-file-system flag if it wasn't there b efore | # for an upgrade, remove the new --one-file-system flag if it wasn't there b efore | |||
# | # | |||
if ( $oldConf->[$oldVars->{RsyncArgs}]{text} !~ /--one-file-system/ ) { | if ( $oldConf->[$oldVars->{RsyncArgs}]{text} !~ /--one-file-system/ ) { | |||
$distConf->[$distVars->{RsyncArgs}]{text} =~ s/\n\s*'--one-file-system', \n/\n/; | $distConf->[$distVars->{RsyncArgs}]{text} =~ s/\n\s*'--one-file-system', \n/\n/; | |||
} | } | |||
$newConf->[$newVars->{RsyncArgs}]{text} = $distConf->[$distVars->{Rsy ncArgs}]{text}; | $newConf->[$newVars->{RsyncArgs}]{text} = $distConf->[$distVars->{Rsy ncArgs}]{text}; | |||
$newConf->[$newVars->{RsyncRestoreArgs}]{text} = $distConf->[$distVars->{Rsy ncRestoreArgs}]{text}; | $newConf->[$newVars->{RsyncRestoreArgs}]{text} = $distConf->[$distVars->{Rsy ncRestoreArgs}]{text}; | |||
# | # | |||
# If it exists, use $Conf{RsyncClientCmd} to create the default $Conf{RsyncS shArgs}. | # If it exists, use $Conf{RsyncClientCmd} to create the default $Conf{RsyncS shArgs}. | |||
# | # | |||
if ( $Conf{RsyncClientCmd} =~ /(\$sshPath.* +-l +\S+)/ && defined($newVars-> {RsyncSshArgs}) ) { | if ( $Conf{RsyncClientCmd} =~ /(\$sshPath.* +-l +\S+)/ && defined($newVars-> {RsyncSshArgs}) ) { | |||
my $value = "[\n '-e', '$1',\n];\n\n"; | my $sshEArg = $1; | |||
$newConf->[$newVars->{RsyncSshArgs}]{text} | my $value = "[\n '-e', '$sshEArg',\n];\n\n"; | |||
=~ s/^(\s*\$Conf\{RsyncSshArgs}\s*=\s*).*/$1$value/ms; | $newConf->[$newVars->{RsyncSshArgs}]{text} =~ s/^(\s*\$Conf\{RsyncSshArg | |||
s}\s*=\s*).*/$1$value/ms; | ||||
printf("** Warning: setting \$Conf{RsyncSshArgs} to ['-e', '%s'] based o | ||||
n deprecated V3 setting" | ||||
. " \$Conf{RsyncClientCmd} = '%s'; please" | ||||
. " check & fix \$Conf{RsyncClientPath} and \$Conf{RsyncSshArgs}\n | ||||
", | ||||
$sshEArg, $Conf{RsyncClientCmd}); | ||||
} else { | ||||
printf( | ||||
"** Warning: unable to set \$Conf{RsyncSshArgs} based on deprecated | ||||
V3 setting" | ||||
. " \$Conf{RsyncClientCmd} = '%s'; please" | ||||
. " check & fix \$Conf{RsyncClientPath} and \$Conf{RsyncSshArgs}\n | ||||
", | ||||
$Conf{RsyncClientCmd} | ||||
); | ||||
} | ||||
# | ||||
# check if any per-host config files have a $Conf{RsyncClientCmd} setting; i | ||||
f so | ||||
# warn the user they need to manually check/update them | ||||
# | ||||
my @hostConfigs = ( | ||||
<$DestDir$Conf{ConfDir}/pc/*.pl>, # FHS case | ||||
<$DestDir$Conf{TopDir}/pc/*/config.pl> # non-FHS case | ||||
); | ||||
foreach my $hostConfigFile ( @hostConfigs ) { | ||||
next if ( !-f $hostConfigFile ); | ||||
my($hostConf, $hostVars) = ConfigParse($hostConfigFile); | ||||
if ( defined($hostVars->{RsyncClientCmd}) ) { | ||||
print( "** Warning: host config $hostConfigFile contains deprecated | ||||
V3 \$Conf{RsyncClientCmd} setting;" | ||||
. " you need to manually update \$Conf{RsyncClientPath} and \$ | ||||
Conf{RsyncSshArgs} for this host\n"); | ||||
} | ||||
if ( defined($hostVars->{RsyncClientRestoreCmd}) ) { | ||||
print( | ||||
"** Warning: host config $hostConfigFile contains deprecated V3 | ||||
\$Conf{RsyncClientRestoreCmd} setting;" | ||||
. " you need to manually update \$Conf{RsyncClientPath} and \$ | ||||
Conf{RsyncSshArgs} for this host\n"); | ||||
} | ||||
} | } | |||
} | } | |||
# | # | |||
# Update $Conf{CgiNavBarLinks} with github URLs | # Update $Conf{CgiNavBarLinks} with github URLs | |||
# | # | |||
$newConf->[$newVars->{CgiNavBarLinks}]{text} =~ s{http://backuppc.wiki.sourcefor | $newConf->[$newVars->{CgiNavBarLinks}]{text} =~ | |||
ge.net}{https://github.com/backuppc/backuppc/wiki}g; | s{http://backuppc.wiki.sourceforge.net}{https://github.com/backuppc/backuppc/w | |||
$newConf->[$newVars->{CgiNavBarLinks}]{text} =~ s{http://backuppc.sourceforge.ne | iki}g; | |||
t}{https://backuppc.github.io/backuppc}g; | $newConf->[$newVars->{CgiNavBarLinks}]{text} =~ | |||
s{http://backuppc.sourceforge.net}{https://backuppc.github.io/backuppc}g; | ||||
$newConf->[$newVars->{CgiNavBarLinks}]{text} =~ s{SourceForge}{Homepage}g; | $newConf->[$newVars->{CgiNavBarLinks}]{text} =~ s{SourceForge}{Homepage}g; | |||
# | # | |||
# Apply any command-line configuration parameter settings | # Apply any command-line configuration parameter settings | |||
# | # | |||
foreach my $param ( keys(%{$opts{"config-override"}}) ) { | foreach my $param ( keys(%{$opts{"config-override"}}) ) { | |||
my $value = $opts{"config-override"}{$param}; | my $value = $opts{"config-override"}{$param}; | |||
my $val = eval { $value }; | my $val = eval {$value}; | |||
if ( @$ ) { | if ( @$ ) { | |||
printf("Can't eval --config-override setting %s=%s\n", | printf("Can't eval --config-override setting %s=%s\n", $param, $opts{"co | |||
$param, $opts{"config-override"}{$param}); | nfig-override"}{$param}); | |||
exit(1); | exit(1); | |||
} | } | |||
if ( !defined($newVars->{$param}) ) { | if ( !defined($newVars->{$param}) ) { | |||
printf("Unkown config parameter %s in --config-override\n", $param); | printf("Unkown config parameter %s in --config-override\n", $param); | |||
exit(1); | exit(1); | |||
} | } | |||
$value .= ";\n\n"; | $value .= ";\n\n"; | |||
$newConf->[$newVars->{$param}]{text} | $newConf->[$newVars->{$param}]{text} =~ s/^(\s*\$Conf\{$param}\s*=\s*).*/$1$ | |||
=~ s/^(\s*\$Conf\{$param}\s*=\s*).*/$1$value/ms; | value/ms; | |||
} | } | |||
# | # | |||
# Now backup and write the config file | # Now backup and write the config file | |||
# | # | |||
my $confCopy = "$dest.pre-4.3.2"; | my $confCopy = "$dest.pre-4.4.0"; | |||
if ( -f $dest && !-f $confCopy ) { | if ( -f $dest && !-f $confCopy ) { | |||
# | # | |||
# Make copy of config file, preserving ownership and modes | # Make copy of config file, preserving ownership and modes | |||
# | # | |||
print("Making backup copy of $dest -> $confCopy\n"); | print("Making backup copy of $dest -> $confCopy\n"); | |||
my @stat = stat($dest); | my @stat = stat($dest); | |||
my $mode = $stat[2]; | my $mode = $stat[2]; | |||
my $uid = $stat[4]; | my $uid = $stat[4]; | |||
my $gid = $stat[5]; | my $gid = $stat[5]; | |||
die("can't copy($dest, $confCopy)\n") | die("can't copy($dest, $confCopy)\n") | |||
unless copy($dest, $confCopy); | unless copy($dest, $confCopy); | |||
die("can't chown $uid, $gid $confCopy\n") | die("can't chown $uid, $gid $confCopy\n") | |||
unless my_chown($uid, $gid, $confCopy); | unless my_chown($uid, $gid, $confCopy); | |||
die("can't chmod $mode $confCopy\n") | die("can't chmod $mode $confCopy\n") | |||
unless my_chmod($mode, $confCopy); | unless my_chmod($mode, $confCopy); | |||
} | } | |||
open(OUT, ">", $dest) || die("can't open $dest for writing\n"); | open(OUT, ">", $dest) || die("can't open $dest for writing\n"); | |||
binmode(OUT); | binmode(OUT); | |||
my $blockComment; | my $blockComment; | |||
foreach my $var ( @$newConf ) { | foreach my $var ( @$newConf ) { | |||
if ( length($blockComment) | if ( length($blockComment) | |||
&& substr($var->{text}, 0, length($blockComment)) eq $blockComment ) { | && substr($var->{text}, 0, length($blockComment)) eq $blockComment ) { | |||
$var->{text} = substr($var->{text}, length($blockComment)); | $var->{text} = substr($var->{text}, length($blockComment)); | |||
$blockComment = undef; | $blockComment = undef; | |||
} | } | |||
$blockComment = $1 if ( $var->{text} =~ /^([\s\n]*#{70}.*#{70}[\s\n]+)/s ); | $blockComment = $1 if ( $var->{text} =~ /^(\s*#{70}.*#{70}\s+)/s ); | |||
$var->{text} =~ s/^\s*\$Conf\{(.*?)\}(\s*=\s*['"]?)(.*?)(['"]?\s*;)/ | $var->{text} =~ s/^\s*\$Conf\{(.*?)\}(\s*=\s*['"]?)(.*?)(['"]?\s*;)/ | |||
my $varName = $1; | my $varName = $1; | |||
my $a = $2; | my $a = $2; | |||
my $varValue = $3; | my $varValue = $3; | |||
my $b = $4; | my $b = $4; | |||
# Get quotes from default config to avoid missing or extra quote s | # Get quotes from default config to avoid missing or extra quote s | |||
# when replacing misused undef or empty string values | # when replacing misused undef or empty string values | |||
($a, $b) = GetQuotes($varName) | ($a, $b) = GetQuotes($varName) | |||
if ( (!defined($OrigConf{$varName}) || $OrigConf{$ varName} eq "") | if ( (!defined($OrigConf{$varName}) || $OrigConf{$ varName} eq "") | |||
&& $Conf{$varName} ne $OrigConf{$varName} ); | && $Conf{$varName} ne $OrigConf{$varName} ); | |||
defined($Conf{$varName}) && ref($Conf{$varName}) eq "" | defined($Conf{$varName}) && ref($Conf{$varName}) eq "" | |||
&& !defined($opts{"config-override"}{$varName }) | && !defined($opts{"config-override"}{$varName }) | |||
&& $Conf{$varName} ne $OrigConf{$varName} | && $Conf{$varName} ne $OrigConf{$varName} | |||
? "\$Conf{$varName}$a$Conf{$varName}$b" | ? "\$Conf{$varName}$a$Conf{$varName}$b" | |||
: "\$Conf{$varName}$a$varValue$b"/emg; | : "\$Conf{$varName}$a$varValue$b"/emsg; | |||
print OUT $var->{text}; | print OUT $var->{text}; | |||
} | } | |||
close(OUT); | close(OUT); | |||
if ( !defined($oldConf) ) { | if ( !defined($oldConf) ) { | |||
die("can't chmod 0640 mode $dest\n") unless my_chmod(0640, $dest); | die("can't chmod 0640 mode $dest\n") unless my_chmod(0640, $dest); | |||
die("can't chown $Uid, $Gid $dest\n") unless my_chown($Uid, $Gid, $dest); | die("can't chown $Uid, $Gid $dest\n") unless my_chown($Uid, $Gid, $dest); | |||
} | } | |||
InstallFile($dest, "$DestDir$Conf{ConfDir}/config.pl.sample", 0644) | InstallFile($dest, "$DestDir$Conf{ConfDir}/config.pl.sample", 0644) | |||
if ( !$opts{"config-only"} ); | if ( !$opts{"config-only"} ); | |||
print <<EOF; | print <<EOF; | |||
Ok, it looks like we are finished. There are several more things you | Ok, it looks like we are finished. There are several more things you | |||
will need to do: | will need to do: | |||
- Browse through the config file, $Conf{ConfDir}/config.pl, | - Browse through the config file, $Conf{ConfDir}/config.pl, | |||
and make sure all the settings are correct. In particular, | and make sure all the settings are correct. In particular, | |||
you will need to set \$Conf{CgiAdminUsers} so you have | you will need to set \$Conf{CgiAdminUsers} so you have | |||
administration privileges in the CGI interface. | administration privileges in the CGI interface. | |||
skipping to change at line 953 | skipping to change at line 949 | |||
########################################################################### | ########################################################################### | |||
# Subroutines | # Subroutines | |||
########################################################################### | ########################################################################### | |||
sub DoInstall | sub DoInstall | |||
{ | { | |||
# | # | |||
# Create install directories | # Create install directories | |||
# | # | |||
foreach my $dir ( qw(bin | foreach my $dir ( qw(bin | |||
share share/doc share/doc/BackupPC | share share/doc share/doc/BackupPC | |||
lib lib/BackupPC | lib lib/BackupPC | |||
lib/BackupPC/CGI | lib/BackupPC/CGI | |||
lib/BackupPC/Config | lib/BackupPC/Config | |||
lib/BackupPC/Lang | lib/BackupPC/Lang | |||
lib/BackupPC/Storage | lib/BackupPC/Storage | |||
lib/BackupPC/Xfer | lib/BackupPC/Xfer | |||
lib/BackupPC/Zip | lib/BackupPC/Zip | |||
lib/Net lib/Net/FTP | lib/Net lib/Net/FTP | |||
) ) { | ) ) { | |||
next if ( -d "$DestDir$Conf{InstallDir}/$dir" ); | next if ( -d "$DestDir$Conf{InstallDir}/$dir" ); | |||
mkpath("$DestDir$Conf{InstallDir}/$dir", 0, 0755); | mkpath("$DestDir$Conf{InstallDir}/$dir", 0, 0755); | |||
if ( !-d "$DestDir$Conf{InstallDir}/$dir" | if ( !-d "$DestDir$Conf{InstallDir}/$dir" | |||
|| !my_chown($Uid, $Gid, "$DestDir$Conf{InstallDir}/$dir") ) { | || !my_chown($Uid, $Gid, "$DestDir$Conf{InstallDir}/$dir") ) { | |||
die("Failed to create or chown $DestDir$Conf{InstallDir}/$dir\n"); | die("Failed to create or chown $DestDir$Conf{InstallDir}/$dir\n"); | |||
} else { | } else { | |||
print("Created $DestDir$Conf{InstallDir}/$dir\n"); | print("Created $DestDir$Conf{InstallDir}/$dir\n"); | |||
} | } | |||
} | } | |||
# | # | |||
# Create CGI image directory | # Create CGI image directory | |||
# | # | |||
foreach my $dir ( ($Conf{CgiImageDir}) ) { | foreach my $dir ( ($Conf{CgiImageDir}) ) { | |||
skipping to change at line 990 | skipping to change at line 986 | |||
die("Failed to create or chown $DestDir$dir"); | die("Failed to create or chown $DestDir$dir"); | |||
} else { | } else { | |||
print("Created $DestDir$dir\n"); | print("Created $DestDir$dir\n"); | |||
} | } | |||
} | } | |||
# | # | |||
# Create other directories | # Create other directories | |||
# | # | |||
foreach my $dir ( ( | foreach my $dir ( ( | |||
"$Conf{TopDir}", | "$Conf{TopDir}", "$Conf{TopDir}/pool", "$Conf{TopDir}/cpool", "$Conf{To | |||
"$Conf{TopDir}/pool", | pDir}/pc", | |||
"$Conf{TopDir}/cpool", | "$Conf{ConfDir}", "$Conf{LogDir}", "$Conf{RunDir}", | |||
"$Conf{TopDir}/pc", | ) ) { | |||
"$Conf{ConfDir}", | ||||
"$Conf{LogDir}", | ||||
"$Conf{RunDir}", | ||||
) ) { | ||||
eval { mkpath("$DestDir$dir", 0, 0750) } if ( !-d "$DestDir$dir" ); | eval { mkpath("$DestDir$dir", 0, 0750) } if ( !-d "$DestDir$dir" ); | |||
if ( $@ || !-d "$DestDir$dir" | if ( $@ | |||
|| !my_chown($Uid, $Gid, "$DestDir$dir") ) { | || !-d "$DestDir$dir" | |||
|| !my_chown($Uid, $Gid, "$DestDir$dir") ) { | ||||
if ( $dir eq $Conf{RunDir} ) { | if ( $dir eq $Conf{RunDir} ) { | |||
print("Failed to create or chown $DestDir$dir... continuing\n"); | print("Failed to create or chown $DestDir$dir... continuing\n"); | |||
} else { | } else { | |||
die("Failed to create or chown $DestDir$dir\n"); | die("Failed to create or chown $DestDir$dir\n"); | |||
} | } | |||
} else { | } else { | |||
print("Created $DestDir$dir\n"); | print("Created $DestDir$dir\n"); | |||
} | } | |||
} | } | |||
print("Installing binaries in $DestDir$Conf{InstallDir}/bin\n"); | print("Installing binaries in $DestDir$Conf{InstallDir}/bin\n"); | |||
foreach my $prog ( @ConfigureBinList ) { | foreach my $prog ( @ConfigureBinList ) { | |||
InstallFile($prog, "$DestDir$Conf{InstallDir}/$prog", 0555); | InstallFile($prog, "$DestDir$Conf{InstallDir}/$prog", 0555); | |||
} | } | |||
# | # | |||
# remove old pre-v4 programs | # remove old pre-v4 programs | |||
# | # | |||
foreach my $prog ( qw( | foreach my $prog ( qw( | |||
bin/BackupPC_link | bin/BackupPC_link | |||
bin/BackupPC_tarPCCopy | bin/BackupPC_tarPCCopy | |||
bin/BackupPC_trashClean | bin/BackupPC_trashClean | |||
bin/BackupPC_compressPool | bin/BackupPC_compressPool | |||
) ) { | ) ) { | |||
unlink("$DestDir$Conf{InstallDir}/$prog"); | unlink("$DestDir$Conf{InstallDir}/$prog"); | |||
} | } | |||
print("Installing library in $DestDir$Conf{InstallDir}/lib\n"); | print("Installing library in $DestDir$Conf{InstallDir}/lib\n"); | |||
foreach my $lib ( @ConfigureLibList ) { | foreach my $lib ( @ConfigureLibList ) { | |||
InstallFile($lib, "$DestDir$Conf{InstallDir}/$lib", 0444); | InstallFile($lib, "$DestDir$Conf{InstallDir}/$lib", 0444); | |||
} | } | |||
# | # | |||
# remove old pre-v4 libraries | # remove old pre-v4 libraries | |||
# | # | |||
foreach my $lib ( qw( | foreach my $lib ( qw( | |||
lib/BackupPC/Attrib.pm | lib/BackupPC/Attrib.pm | |||
lib/BackupPC/Config.pm | lib/BackupPC/Config.pm | |||
lib/BackupPC/FileZIO.pm | lib/BackupPC/FileZIO.pm | |||
lib/BackupPC/PoolWrite.pm | lib/BackupPC/PoolWrite.pm | |||
lib/BackupPC/Xfer/RsyncDigest.pm | lib/BackupPC/Xfer/RsyncDigest.pm | |||
lib/BackupPC/Xfer/RsyncFileIO.pm | lib/BackupPC/Xfer/RsyncFileIO.pm | |||
) ) { | ) ) { | |||
unlink("$DestDir$Conf{InstallDir}/$lib"); | unlink("$DestDir$Conf{InstallDir}/$lib"); | |||
} | } | |||
if ( $Conf{CgiImageDir} ne "" ) { | if ( $Conf{CgiImageDir} ne "" ) { | |||
print("Installing images in $DestDir$Conf{CgiImageDir}\n"); | print("Installing images in $DestDir$Conf{CgiImageDir}\n"); | |||
foreach my $img ( <images/*> ) { | foreach my $img ( <images/*> ) { | |||
(my $destImg = $img) =~ s{^images/}{}; | (my $destImg = $img) =~ s{^images/}{}; | |||
InstallFile($img, "$DestDir$Conf{CgiImageDir}/$destImg", 0444, 1); | InstallFile($img, "$DestDir$Conf{CgiImageDir}/$destImg", 0444, 1); | |||
} | } | |||
# | # | |||
# Install new CSS file, making a backup copy if necessary | # Install new CSS file, making a backup copy if necessary | |||
# | # | |||
my $cssBackup = "$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css.pre-4.3.2" ; | my $cssBackup = "$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css.pre-4.4.0" ; | |||
if ( -f "$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css" && !-f $cssBackup ) { | if ( -f "$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css" && !-f $cssBackup ) { | |||
rename("$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css", $cssBackup); | rename("$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css", $cssBackup); | |||
} | } | |||
InstallFile("conf/BackupPC_stnd.css", | InstallFile("conf/BackupPC_stnd.css", "$DestDir$Conf{CgiImageDir}/Ba | |||
"$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css", 0444, 0); | ckupPC_stnd.css", 0444, 0); | |||
InstallFile("conf/BackupPC_retro_v2.css", | InstallFile("conf/BackupPC_retro_v2.css", "$DestDir$Conf{CgiImageDir}/Ba | |||
"$DestDir$Conf{CgiImageDir}/BackupPC_retro_v2.css", 0444, 0) | ckupPC_retro_v2.css", 0444, 0); | |||
; | InstallFile("conf/BackupPC_retro_v3.css", "$DestDir$Conf{CgiImageDir}/Ba | |||
InstallFile("conf/BackupPC_retro_v3.css", | ckupPC_retro_v3.css", 0444, 0); | |||
"$DestDir$Conf{CgiImageDir}/BackupPC_retro_v3.css", 0444, 0) | InstallFile("conf/sorttable.js", "$DestDir$Conf{CgiImageDir}/so | |||
; | rttable.js", 0444, 0); | |||
InstallFile("conf/sorttable.js", | ||||
"$DestDir$Conf{CgiImageDir}/sorttable.js", 0444, 0); | ||||
} | } | |||
print("Making systemd and init.d scripts\n"); | print("Making systemd and init.d scripts\n"); | |||
foreach my $dir ( qw(systemd systemd/init.d) ) { | foreach my $dir ( qw(systemd systemd/init.d) ) { | |||
mkpath($dir, 0, 0755); | mkpath($dir, 0, 0755); | |||
if ( !-d $dir || !my_chown($Uid, $Gid, $dir) ) { | if ( !-d $dir || !my_chown($Uid, $Gid, $dir) ) { | |||
die("Failed to create or chown $dir\n"); | die("Failed to create or chown $dir\n"); | |||
} | } | |||
} | } | |||
InstallFile("systemd/src/backuppc.service", "systemd/backuppc.service", 0644 ); | InstallFile("systemd/src/backuppc.service", "systemd/backuppc.service", 0644 ); | |||
foreach my $init ( qw(init.d/gentoo-backuppc init.d/gentoo-backuppc.conf | foreach my $init ( qw(init.d/gentoo-backuppc init.d/gentoo-backuppc.conf | |||
init.d/linux-backuppc init.d/solaris-backuppc init.d/d | init.d/linux-backuppc init.d/solaris-backuppc init.d/debian-backuppc | |||
ebian-backuppc | init.d/freebsd-backuppc init.d/freebsd-backuppc2 init.d/suse-backuppc | |||
init.d/freebsd-backuppc init.d/freebsd-backuppc2 init. | init.d/slackware-backuppc init.d/ubuntu-backuppc ) ) { | |||
d/suse-backuppc | ||||
init.d/slackware-backuppc init.d/ubuntu-backuppc ) ) { | ||||
InstallFile("systemd/src/$init", "systemd/$init", 0755); | InstallFile("systemd/src/$init", "systemd/$init", 0755); | |||
} | } | |||
print("Making Apache configuration file for suid-perl\n"); | print("Making Apache configuration file for suid-perl\n"); | |||
InstallFile("httpd/src/BackupPC.conf", "httpd/BackupPC.conf", 0644); | InstallFile("httpd/src/BackupPC.conf", "httpd/BackupPC.conf", 0644); | |||
print("Installing docs in $DestDir$Conf{InstallDir}/share/doc/BackupPC\n"); | print("Installing docs in $DestDir$Conf{InstallDir}/share/doc/BackupPC\n"); | |||
foreach my $doc ( qw(BackupPC.pod BackupPC.html) ) { | foreach my $doc ( qw(BackupPC.pod BackupPC.html) ) { | |||
InstallFile("doc/$doc", "$DestDir$Conf{InstallDir}/share/doc/BackupPC/$d oc", 0444); | InstallFile("doc/$doc", "$DestDir$Conf{InstallDir}/share/doc/BackupPC/$d oc", 0444); | |||
# | # | |||
skipping to change at line 1105 | skipping to change at line 1093 | |||
unlink("$DestDir$Conf{InstallDir}/doc/$doc") if ( -f "$DestDir$Conf{Inst allDir}/doc/$doc" ); | unlink("$DestDir$Conf{InstallDir}/doc/$doc") if ( -f "$DestDir$Conf{Inst allDir}/doc/$doc" ); | |||
} | } | |||
# | # | |||
# clean up old directory (ok if it quietly fails if there are other files in that directory) | # clean up old directory (ok if it quietly fails if there are other files in that directory) | |||
# | # | |||
rmdir("$DestDir$Conf{InstallDir}/doc") if ( -d "$DestDir$Conf{InstallDir}/do c" ); | rmdir("$DestDir$Conf{InstallDir}/doc") if ( -d "$DestDir$Conf{InstallDir}/do c" ); | |||
if ( $Conf{CgiDir} ne "" ) { | if ( $Conf{CgiDir} ne "" ) { | |||
print("Installing cgi script BackupPC_Admin in $DestDir$Conf{CgiDir}\n") ; | print("Installing cgi script BackupPC_Admin in $DestDir$Conf{CgiDir}\n") ; | |||
mkpath("$DestDir$Conf{CgiDir}", 0, 0755); | mkpath("$DestDir$Conf{CgiDir}", 0, 0755); | |||
InstallFile("cgi-bin/BackupPC_Admin", "$DestDir$Conf{CgiDir}/BackupPC_Ad | InstallFile("cgi-bin/BackupPC_Admin", "$DestDir$Conf{CgiDir}/BackupPC_Ad | |||
min", | min", 04554); | |||
04554); | ||||
} | } | |||
} | } | |||
sub CleanPidSock | sub CleanPidSock | |||
{ | { | |||
# | # | |||
# clean pid and sock files from old location (they are now in $Conf{RunDir}, and they | # clean pid and sock files from old location (they are now in $Conf{RunDir}, and they | |||
# get re-created each time BackupPC starts, so it's ok if RunDir eq LogDir). | # get re-created each time BackupPC starts, so it's ok if RunDir eq LogDir). | |||
# | # | |||
unlink("$DestDir$Conf{LogDir}/BackupPC.pid") if ( -f "$DestDir$Conf{LogDir} /BackupPC.pid" ); | unlink("$DestDir$Conf{LogDir}/BackupPC.pid") if ( -f "$DestDir$Conf{LogDir} /BackupPC.pid" ); | |||
skipping to change at line 1137 | skipping to change at line 1124 | |||
# | # | |||
# preserve ownership and modes of files that already exist | # preserve ownership and modes of files that already exist | |||
# | # | |||
my @stat = stat($dest); | my @stat = stat($dest); | |||
$mode = $stat[2]; | $mode = $stat[2]; | |||
$uid = $stat[4]; | $uid = $stat[4]; | |||
$gid = $stat[5]; | $gid = $stat[5]; | |||
} | } | |||
unlink($dest) if ( -f $dest ); | unlink($dest) if ( -f $dest ); | |||
if ( $binary ) { | if ( $binary ) { | |||
die("can't copy($prog, $dest)\n") unless copy($prog, $dest); | die("can't copy($prog, $dest)\n") unless copy($prog, $dest); | |||
} else { | } else { | |||
open(PROG, $prog) || die("can't open $prog for reading\n"); | open(PROG, $prog) || die("can't open $prog for reading\n"); | |||
open(OUT, ">", $dest) || die("can't open $dest for writing\n"); | open(OUT, ">", $dest) || die("can't open $dest for writing\n"); | |||
binmode(PROG); | binmode(PROG); | |||
binmode(OUT); | binmode(OUT); | |||
while ( <PROG> ) { | while ( <PROG> ) { | |||
s/__INSTALLDIR__/$Conf{InstallDir}/g; | s/__INSTALLDIR__/$Conf{InstallDir}/g; | |||
s/__LOGDIR__/$Conf{LogDir}/g; | s/__LOGDIR__/$Conf{LogDir}/g; | |||
s/__RUNDIR__/$Conf{RunDir}/g; | s/__RUNDIR__/$Conf{RunDir}/g; | |||
s/__CONFDIR__/$Conf{ConfDir}/g; | s/__CONFDIR__/$Conf{ConfDir}/g; | |||
s/__TOPDIR__/$Conf{TopDir}/g; | s/__TOPDIR__/$Conf{TopDir}/g; | |||
s/^(\s*my \$useFHS\s*=\s*)\d;/${1}$opts{fhs};/ | s/^(\s*my \$useFHS\s*=\s*)\d;/${1}$opts{fhs};/ | |||
if ( $prog =~ /Lib.pm/ ); | if ( $prog =~ /Lib.pm/ ); | |||
s/__BACKUPPCUSER__/$Conf{BackupPCUser}/g; | s/__BACKUPPCUSER__/$Conf{BackupPCUser}/g; | |||
s/__CGIDIR__/$Conf{CgiDir}/g; | s/__CGIDIR__/$Conf{CgiDir}/g; | |||
s/__IMAGEDIR__/$Conf{CgiImageDir}/g; | s/__IMAGEDIR__/$Conf{CgiImageDir}/g; | |||
s/__IMAGEDIRURL__/$Conf{CgiImageDirURL}/g; | s/__IMAGEDIRURL__/$Conf{CgiImageDirURL}/g; | |||
if ( $first && /^#.*bin\/perl/ ) { | ||||
# | if ( $first && /^#.*bin\/perl/ ) { | |||
# Fill in correct path to perl (no taint for >= 2.0.1). | # | |||
# | # Fill in correct path to perl (no taint for >= 2.0.1). | |||
print OUT "#!$Conf{PerlPath}\n"; | # | |||
} else { | print OUT "#!$Conf{PerlPath}\n"; | |||
print OUT; | } else { | |||
} | print OUT; | |||
$first = 0; | } | |||
} | $first = 0; | |||
close(PROG); | } | |||
close(OUT); | close(PROG); | |||
close(OUT); | ||||
} | } | |||
die("can't chown $uid, $gid $dest") unless my_chown($uid, $gid, $dest); | die("can't chown $uid, $gid $dest") unless my_chown($uid, $gid, $dest); | |||
die("can't chmod $mode $dest") unless my_chmod($mode, $dest); | die("can't chmod $mode $dest") unless my_chmod($mode, $dest); | |||
} | } | |||
sub FindProgram | sub FindProgram | |||
{ | { | |||
my($path, $prog) = @_; | my($path, $prog) = @_; | |||
if ( defined($opts{"bin-path"}{$prog}) ) { | if ( defined($opts{"bin-path"}{$prog}) ) { | |||
skipping to change at line 1202 | skipping to change at line 1190 | |||
my $comment = 1; | my $comment = 1; | |||
my $allVars = {}; | my $allVars = {}; | |||
my $endLine = undef; | my $endLine = undef; | |||
while ( <C> ) { | while ( <C> ) { | |||
if ( /^#/ && !defined($endLine) ) { | if ( /^#/ && !defined($endLine) ) { | |||
if ( $comment ) { | if ( $comment ) { | |||
$out .= $_; | $out .= $_; | |||
} else { | } else { | |||
if ( $out ne "" ) { | if ( $out ne "" ) { | |||
$allVars->{$var} = @conf if ( defined($var) ); | $allVars->{$var} = @conf if ( defined($var) ); | |||
push(@conf, { | push(@conf, {text => $out, var => $var}); | |||
text => $out, | ||||
var => $var, | ||||
}); | ||||
} | } | |||
$var = undef; | $var = undef; | |||
$comment = 1; | $comment = 1; | |||
$out = $_; | $out = $_; | |||
} | } | |||
} elsif ( /^\s*\$Conf\{([^}]*)/ ) { | } elsif ( /^\s*\$Conf\{([^}]*)/ ) { | |||
$comment = 0; | $comment = 0; | |||
if ( defined($var) ) { | if ( defined($var) ) { | |||
$allVars->{$var} = @conf if ( defined($var) ); | $allVars->{$var} = @conf if ( defined($var) ); | |||
push(@conf, { | push(@conf, {text => $out, var => $var}); | |||
text => $out, | ||||
var => $var, | ||||
}); | ||||
$out = $_; | $out = $_; | |||
} else { | } else { | |||
$out .= $_; | $out .= $_; | |||
} | } | |||
$var = $1; | $var = $1; | |||
$endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<(.*);/ ); | $endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<(.*);/ ); | |||
$endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<'(.*)';/ ); | $endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<'(.*)';/ ); | |||
} else { | } else { | |||
$endLine = undef if ( defined($endLine) && /^\Q$endLine\E[\n\r]*$/ ); | $endLine = undef if ( defined($endLine) && /^\Q$endLine\E[\n\r]*$/ ) ; | |||
$out .= $_; | $out .= $_; | |||
} | } | |||
} | } | |||
if ( $out ne "" ) { | if ( $out ne "" ) { | |||
$allVars->{$var} = @conf if ( defined($var) ); | $allVars->{$var} = @conf if ( defined($var) ); | |||
push(@conf, { | push(@conf, {text => $out, var => $var}); | |||
text => $out, | ||||
var => $var, | ||||
}); | ||||
} | } | |||
close(C); | close(C); | |||
return (\@conf, $allVars); | return (\@conf, $allVars); | |||
} | } | |||
sub ConfigMerge | sub ConfigMerge | |||
{ | { | |||
my($old, $oldVars, $new, $newVars) = @_; | my($old, $oldVars, $new, $newVars) = @_; | |||
my $posn = 0; | my $posn = 0; | |||
my($res, $resVars); | my($res, $resVars); | |||
skipping to change at line 1289 | skipping to change at line 1268 | |||
$resVars->{$res->[$i]{var}} = $i; | $resVars->{$res->[$i]{var}} = $i; | |||
} | } | |||
return ($res, $resVars); | return ($res, $resVars); | |||
} | } | |||
sub GetQuotes | sub GetQuotes | |||
{ | { | |||
my($varName) = @_; | my($varName) = @_; | |||
my $posn = $distVars->{$varName}; | my $posn = $distVars->{$varName}; | |||
$distConf->[$posn]->{text} =~ /^\s*\$Conf\{.*?\}(\s*=\s*['"]?).*?(['"]?\s*;) /mg; | $distConf->[$posn]->{text} =~ /^\s*\$Conf\{.*?\}(\s*=\s*['"]?).*?(['"]?\s*;) /ms; | |||
return ($1, $2); | return ($1, $2); | |||
} | } | |||
sub my_chown | sub my_chown | |||
{ | { | |||
my($uid, $gid, $file) = @_; | my($uid, $gid, $file) = @_; | |||
return 1 if ( !$opts{"set-perms"} ); | return 1 if ( !$opts{"set-perms"} ); | |||
return chown($uid, $gid, $file); | return chown($uid, $gid, $file); | |||
} | } | |||
sub my_chmod | sub my_chmod | |||
{ | { | |||
my ($mode, $file) = @_; | my($mode, $file) = @_; | |||
return 1 if ( !$opts{"set-perms"} ); | return 1 if ( !$opts{"set-perms"} ); | |||
return chmod($mode, $file); | return chmod($mode, $file); | |||
} | } | |||
sub prompt | sub prompt | |||
{ | { | |||
my($question, $default, $option) = @_; | my($question, $default, $option) = @_; | |||
$default = $opts{$option} if ( defined($opts{$option}) ); | $default = $opts{$option} if ( defined($opts{$option}) ); | |||
skipping to change at line 1339 | skipping to change at line 1318 | |||
configure.pl [options] | configure.pl [options] | |||
=head1 DESCRIPTION | =head1 DESCRIPTION | |||
configure.pl is a script that is used to install or upgrade a BackupPC | configure.pl is a script that is used to install or upgrade a BackupPC | |||
installation. It is usually run interactively without arguments. It | installation. It is usually run interactively without arguments. It | |||
also supports a batch mode where all the options can be specified | also supports a batch mode where all the options can be specified | |||
via the command-line. | via the command-line. | |||
For upgrading BackupPC you need to make sure that BackupPC is not | For upgrading BackupPC you need to make sure that BackupPC is not | |||
running prior to running BackupPC. | running prior to running configure.pl. | |||
Typically configure.pl needs to run as the super user (root). | Typically configure.pl needs to run as the super user (root). | |||
=head1 OPTIONS | =head1 OPTIONS | |||
=over 8 | =over 8 | |||
=item B<--batch> | =item B<--batch> | |||
Run configure.pl in batch mode. configure.pl will run without | Run configure.pl in batch mode. configure.pl will run without | |||
skipping to change at line 1556 | skipping to change at line 1535 | |||
configuration file: | configuration file: | |||
configure.pl --batch --config-path /data/BackupPC/conf/config.pl | configure.pl --batch --config-path /data/BackupPC/conf/config.pl | |||
=head1 AUTHOR | =head1 AUTHOR | |||
Craig Barratt <cbarratt@users.sourceforge.net> | Craig Barratt <cbarratt@users.sourceforge.net> | |||
=head1 COPYRIGHT | =head1 COPYRIGHT | |||
Copyright (C) 2001-2010 Craig Barratt. | Copyright (C) 2001-2020 Craig Barratt. | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
=cut | =cut | |||
End of changes. 91 change blocks. | ||||
278 lines changed or deleted | 279 lines changed or added |