Subversion Repositories camp_sysinfo_client_3

Rev

Rev 225 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
224 rodolico 1
#! /usr/bin/env perl
2
 
3
use strict;
4
use warnings;
5
 
6
# find our location and use it for searching for libraries
7
BEGIN {
8
   use FindBin;
9
   use File::Spec;
10
   # use libraries from the directory this script is in
11
   use lib File::Spec->catdir($FindBin::Bin);
12
   # and its parent
13
   use lib File::Spec->catdir( $FindBin::Bin . '/../' );
14
   eval( 'use YAML::Tiny' );
15
}
16
 
17
use Cwd qw(abs_path);
18
use sysinfosetup;
19
 
20
my $scriptDir = abs_path(File::Spec->catdir($FindBin::Bin) );
21
 
22
use Digest::MD5 qw(md5_hex);
23
use File::Copy;
24
 
25
# define the version number
26
# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
27
use version;
28
our $VERSION = version->declare("v0.001.001");
29
 
30
 
31
use Data::Dumper;
32
use File::Basename;
33
use Getopt::Long;
34
 
35
Getopt::Long::Configure ("bundling"); # allow -vd --os='debian'
36
our $dryRun;
37
our $DEBUG;
38
my $os;
39
my $help = 0;
40
my $version = 0;
41
my $quiet = 0;
42
my $seedFileName = '';
43
 
44
our %operatingSystems;
45
 
46
# simple display if --help is passed
47
sub help {
48
   use File::Basename;
49
   print basename($0) . " $VERSION\n";
50
   print <<END
51
$0 [options]
52
Options:
53
   --os|-o      - lower case name of operating system (debian, freebsd, etc...)
54
   --dryrun|-n  - do not actually do anything, just tell you what I'd do
55
   --version|-v - display version and exit
56
   --quiet|-q   - Do not ask questions, just do stuff
57
   --help|-g    - Show this screen
58
   --seed|-s    - URL/Path to seed file for config
59
   --debug      - Show extra information (--nodebug is default)
60
END
61
}
62
 
63
 
64
################################################################
65
#               Main Code                                      #
66
################################################################
67
 
68
# handle any command line parameters that may have been passed in
69
 
70
GetOptions (
71
            "os|o=s"      => \$os,      # pass in the operating system
72
            "dryrun|n"    => \$dryRun,  # do NOT actually do anything
73
            "seed|s=s"    => \$seedFileName,
74
            'help|h'      => \$help,
75
            'version|v'   => \$version,
76
            'quiet|q'     => \$quiet,
77
            'debug!'      => \$DEBUG
78
            ) or die "Error parsing command line\n";
79
 
80
if ( $help ) { &help() ; exit; }
81
if ( $version ) { use File::Basename; print basename($0) . " $VERSION\n"; exit; }
82
 
83
my $returnValue = 0;
84
 
85
# load the definitions from installer_config.pl
86
do "$scriptDir/installer_config.pl";
87
 
88
our %libraries;
89
our %install;
90
our %binaries;
91
 
92
# Check for configuration file
93
my $configDir = $operatingSystems{ $os }{'confdir'};
94
unless ( -d $configDir ) {
95
   print "Creating $configDir\n";
96
   `mkdir -p $configDir` unless $dryRun;
97
}
98
 
99
my $configFile = $operatingSystems{'configuration file'};
100
$configFile =~ s/<confdir>/$configDir/;
101
unless ( -f $configFile ) {
102
   print "Creating $configFile\n";
103
   $seedFileName = "$scriptDir/sysinfo-client.conf.template.yaml" unless $seedFileName;
104
   `cp $seedFileName $configFile` unless $dryRun;
105
}
106
 
107
# check for cron file(s)