Blame | Last modification | View Log | Download | RSS feed
#! /usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
# used as a small file to download and install sysinfo client
# perl install_sysinfo_client.pl \
# --dryRun \
# --repo=http://svn.dailydata.net/svn/camp_sysinfo_client_3/trunk \
# --target ~/test \
# --seed=http://phantom.dailydata.net/uploadFiles299q/sysinfo-client.seed.yaml
# define the version number
# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
use version;
our $VERSION = version->declare("v1.001.001");
my %operatingSystems = (
'linux' => '/opt/camp/sysinfo-client', # '/opt/camp/sysinfo-client',
'bsd' => '/usr/local/opt/camp/sysinfo-client'
);
Getopt::Long::Configure ("bundling"); # allow -vd --os='debian'
my $repository = 'http://svn.dailydata.net/svn/camp_sysinfo_client_3/tags/stable';
my $svn = '';
my $dryRun = 0;
my $os;
my $help = 0;
my $version = 0;
my $targetDir;
my $seedFileURL;
# simple display if --help is passed
sub help {
my $oses = join( ', ', keys %operatingSystems );
use File::Basename;
print basename($0) . " $VERSION\n";
print <<END
$0 [options]
Options:
--os - osname, one of [$oses]
--dryrun - do not actually do anything, just tell you what I'd do
--version - display version and exit
--svn - path to svn command
--repo - full URL of subversion repository
--target - Target directory for installation
--seed - URL to download a seed file for new installs
END
}
################################################################
# Main Code #
################################################################
# handle any command line parameters that may have been passed in
GetOptions (
"os|o=s" => \$os, # pass in the operating system
"dryrun|n" => \$dryRun, # do NOT actually do anything
'help|h' => \$help,
'version|v' => \$version,
'svn|s=s' => \$svn,
'repo|r=s' => \$repository,
'target|t=s' => \$targetDir,
'seed=s' => \$seedFileURL
) or die "Error parsing command line\n";
if ( $help ) { &help() ; exit; }
if ( $version ) { use File::Basename; print basename($0) . " $VERSION\n"; exit; }
unless ( $svn ) {
$svn = `which svn`;
chomp $svn;
}
die "Could not locate svn command\n" unless $svn;
die "This installer requires subvsion, and it is not found on this system\n" unless `$svn --version --quiet`;
$os = `uname` unless $os;
$os = lc $os;
chomp $os;
$targetDir = $operatingSystems{$os} unless $targetDir;
# if the target directory is NOT an svn repository, we want to
# move it out of the way.
my $eraseOld = `svn info $target >/dev/null 2>&1` ? 0 : 1;
if ( $dryRun ) {
print "Dry Run!!\nDownloading sysinfo\nfrom $repository\nusing $svn\ninto $targetDir\n";
print "Using seed file from $seedFileURL\n" if $seedFileURL;
} else {
`mkdir -p $targetDir`; # verify the target directory exists
`$svn co $repository $targetDir`;
if ( $seedFileURL ) {
my $seedFileName = $targetDir . '/sysinfo-client.seed.yaml';
`wget --output-document=$seedFileName $seedFileURL`;
}
}
1;
Generated by GNU Enscript 1.6.5.90.