Subversion Repositories camp_sysinfo_client_3

Rev

Rev 45 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 45 Rev 50
Line 11... Line 11...
11
# Revision history
11
# Revision history
12
#
12
#
13
# Version 1.1.7 20161010 RWR
13
# Version 1.1.7 20161010 RWR
14
# Added ability to validate required libraries are installed
14
# Added ability to validate required libraries are installed
15
#
15
#
-
 
16
# version 1.2 20170327 RWR
-
 
17
# did some major modifications to correctly work on BSD systems also
16
 
18
 
17
our $VERSION = '1.1.7';
19
our $VERSION = '1.2';
18
 
20
 
19
# find our location and use it for searching for libraries
21
# find our location and use it for searching for libraries
20
BEGIN {
22
BEGIN {
21
   use FindBin;
23
   use FindBin;
22
   use File::Spec;
24
   use File::Spec;
Line 46... Line 48...
46
my $installType;
48
my $installType;
47
 
49
 
48
my %install = (  'bindir' => '/opt/camp/sysinfo-client',
50
my %install = (  'bindir' => '/opt/camp/sysinfo-client',
49
                 'confdir' => '/etc/camp/sysinfo-client',
51
                 'confdir' => '/etc/camp/sysinfo-client',
50
                 'application name' => 'sysinfo client',
52
                 'application name' => 'sysinfo client',
-
 
53
                 'default group' => 'root',
-
 
54
                 'default owner' => 'root',
-
 
55
                 'default permission' => '0700',
51
                 'configuration' => {
56
                 'configuration' => {
52
                          'configurator' => '<bindir>/configure.pl',
57
                          'configurator' => '<bindir>/configure.pl',
53
                          'configuration file' => '<confdir>/sysinfo-client.conf',
58
                          'configuration file' => '<confdir>/sysinfo-client.conf',
54
                          'configuration seed file' => 'sysinfo-client.seed',
59
                          'configuration seed file' => 'sysinfo-client.seed',
55
                          'permission' => '700',
60
                          'permission' => '700',
56
                          'owner'      => 'root',
61
                          'owner'      => '<default owner>',
57
                          'target'     => '<confdir>'
62
                          'target'     => '<confdir>'
58
                            },
63
                            },
59
                 'files' => {
64
                 'files' => {
60
                           'configure.pl' => { 
65
                           'configure.pl' => { 
61
                                 'type' => 'file',
66
                                 'type' => 'file',
62
                                 'permission' => '700', 
67
                                 'permission' => '700', 
63
                                 'owner' => 'root:root', 
68
                                 'owner' => '<default owner>:<default group>', 
64
                                 'target' =>  '<bindir>'
69
                                 'target' =>  '<bindir>'
65
                              },
70
                              },
66
                           'sysinfo-client' => { 
71
                           'sysinfo-client' => { 
67
                                 'type' => 'file',
72
                                 'type' => 'file',
68
                                 'permission' => '700',
73
                                 'permission' => '700',
69
                                 'owner' => 'root:root',
74
                                 'owner' => '<default owner>:<default group>',
70
                                 'target' =>  '<bindir>'
75
                                 'target' =>  '<bindir>'
71
                              },
76
                              },
72
                           'sysinfoconf.pm' => {
77
                           'sysinfoconf.pm' => {
73
                                 'type' => 'file',
78
                                 'type' => 'file',
74
                                 'permission' => '600',
79
                                 'permission' => '600',
75
                                 'owner' => 'root:root',
80
                                 'owner' => '<default owner>:<default group>',
76
                                 'target' =>  '<bindir>'
81
                                 'target' =>  '<bindir>'
77
                              },
82
                              },
78
                           'notes' => { 
83
                           'notes' => { 
79
                                 'type' => 'file',
84
                                 'type' => 'file',
80
                                 'permission' => '600', 
85
                                 'permission' => '600', 
81
                                 'owner' => 'root:root', 
86
                                 'owner' => '<default owner>:<default group>', 
82
                                 'target' =>  '<bindir>'
87
                                 'target' =>  '<bindir>'
83
                              },
88
                              },
84
                           'sysinfo-client.conf.template' => { 
89
                           'sysinfo-client.conf.template' => { 
85
                                 'type' => 'file',
90
                                 'type' => 'file',
86
                                 'permission' => '600', 
91
                                 'permission' => '600', 
87
                                 'owner' => 'root:root', 
92
                                 'owner' => '<default owner>:<default group>', 
88
                                 'target' =>  '<bindir>' 
93
                                 'target' =>  '<bindir>' 
89
                              },
94
                              },
90
                           'getSendEmail.pl' => { 
95
                           'getSendEmail.pl' => { 
91
                                 'type' => 'file',
96
                                 'type' => 'file',
92
                                 'permission' => '700', 
97
                                 'permission' => '700', 
93
                                 'owner' => 'root:root', 
98
                                 'owner' => '<default owner>:<default group>', 
94
                                 'target' =>  '<bindir>' 
99
                                 'target' =>  '<bindir>' 
95
                              },
100
                              },
96
                           'install.pl' => {
101
                           'install.pl' => {
97
                                 'type' => 'file',
102
                                 'type' => 'file',
98
                                 'permission' => '700', 
103
                                 'permission' => '700', 
99
                                 'owner' => 'root:root', 
104
                                 'owner' => '<default owner>:<default group>', 
100
                                 'target' =>  '<bindir>' 
105
                                 'target' =>  '<bindir>' 
101
                              },
106
                              },
102
                           'MANIFEST' => {
107
                           'MANIFEST' => {
103
                                 'type' => 'file',
108
                                 'type' => 'file',
104
                                 'permission' => '600', 
109
                                 'permission' => '600', 
105
                                 'owner' => 'root:root', 
110
                                 'owner' => '<default owner>:<default group>', 
106
                                 'target' =>  '<bindir>' 
111
                                 'target' =>  '<bindir>' 
107
                              },
112
                              },
108
                           'sysinfo-client.seed.example' => { 
113
                           'sysinfo-client.seed.example' => { 
109
                                 'type' => 'file',
114
                                 'type' => 'file',
110
                                 'permission' => '600', 
115
                                 'permission' => '600', 
111
                                 'owner' => 'root:root', 
116
                                 'owner' => '<default owner>:<default group>', 
112
                                 'target' =>  '<bindir>' 
117
                                 'target' =>  '<bindir>' 
113
                              },
118
                              },
114
                           'VERSION' => { 
119
                           'VERSION' => { 
115
                                 'type' => 'file',
120
                                 'type' => 'file',
116
                                 'permission' => '600', 
121
                                 'permission' => '600', 
117
                                 'owner' => 'root:root', 
122
                                 'owner' => '<default owner>:<default group>', 
118
                                 'target' =>  '<bindir>' 
123
                                 'target' =>  '<bindir>' 
119
                              },
124
                              },
120
                              'modules' => {
125
                              'modules' => {
121
                                 'type' => 'directory',
126
                                 'type' => 'directory',
122
                                 'permission' => '700', 
127
                                 'permission' => '700', 
123
                                 'owner' => 'root:root', 
128
                                 'owner' => '<default owner>:<default group>', 
124
                                 'target' =>  '<bindir>',
129
                                 'target' =>  '<bindir>',
125
                                 'action' => 'chmod 700 *'
130
                                 'action' => 'chmod 700 *'
126
                              },
131
                              },
127
                              'scripts' => {
132
                              'scripts' => {
128
                                 'type' => 'directory',
133
                                 'type' => 'directory',
129
                                 'permission' => '700', 
134
                                 'permission' => '700', 
130
                                 'owner' => 'root:root', 
135
                                 'owner' => '<default owner>:<default group>', 
131
                                 'target' =>  '<bindir>',
136
                                 'target' =>  '<bindir>',
132
                                 'action' => 'chmod 700 *'
137
                                 'action' => 'chmod 700 *'
133
                              },
138
                              },
134
                     }
139
                     }
135
                  );
140
                  );
Line 143... Line 148...
143
                     'modules' => '((dpkg)|(unix)|(ipmi)|(xen))',
148
                     'modules' => '((dpkg)|(unix)|(ipmi)|(xen))',
144
                  },
149
                  },
145
                  'ipfire' => {
150
                  'ipfire' => {
146
                     'bindir' => '/opt/camp/sysinfo-client',
151
                     'bindir' => '/opt/camp/sysinfo-client',
147
                     'confdir' => '/etc/camp/sysinfo-client',
152
                     'confdir' => '/etc/camp/sysinfo-client',
148
                     'crontab' => 'ln -s <bindir>sysinfo-client /etc/fcron.daily/sysinfo-client.fcron',
153
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/fcron.daily/sysinfo-client.fcron',
149
                     'modules' => '((ipfire)|(unix))',
154
                     'modules' => '((ipfire)|(unix))',
150
                  },
155
                  },
151
                  'freebsd' => {
156
                  'freebsd' => {
152
                     'bindir' => '/usr/local/opt/camp/sysinfo-client',
157
                     'bindir' => '/usr/local/opt/camp/sysinfo-client',
153
                     'confdir' => '/usr/local/etc/camp/sysinfo-client',
158
                     'confdir' => '/usr/local/etc/camp/sysinfo-client',
154
                     'crontab' => 'ln -s <bindir>sysinfo-client /etc/periodic/daily/sysinfo-client',
159
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/periodic/daily/sysinfo-client',
155
                     'modules' => '((bsd)|(unix))',
160
                     'modules' => '((bsd)|(unix))',
-
 
161
                    'default group' => 'wheel',
-
 
162
                    'default owner' => 'root',
156
                  },
163
                  },
157
                  
164
                  
158
                );
165
                );
159
 
166
 
160
# list of libraries used by the system. We will offer to install them if
167
# list of libraries used by the system. We will offer to install them if
Line 167... Line 174...
167
#      apt-get -y install libwww-perl perl-modules
174
#      apt-get -y install libwww-perl perl-modules
168
# flexibility vs efficiency in this case.
175
# flexibility vs efficiency in this case.
169
my %libraries = ( 
176
my %libraries = ( 
170
                  'File::Basename' => { 'debian' => 'apt-get -y install perl-modules' },
177
                  'File::Basename' => { 'debian' => 'apt-get -y install perl-modules' },
171
                  'Exporter' => { 'debian' => 'apt-get -y install perl-base' },
178
                  'Exporter' => { 'debian' => 'apt-get -y install perl-base' },
-
 
179
                  'LWP' => { 
172
                  'LWP' => { 'debian' => 'apt-get -y install libwww-perl',
180
                             'debian' => 'apt-get -y install libwww-perl',
173
                             'freebsd' => 'pkg install p5-libwww' },
181
                             'freebsd' => 'pkg install p5-libwww'
-
 
182
                           },
174
                );
183
                );
175
 
184
 
176
# utilities md5sum
185
# utilities md5sum
177
# freebsd isomd5sum
186
# freebsd isomd5sum
178
 
187
 
Line 286... Line 295...
286
sub populateSourceDir {
295
sub populateSourceDir {
287
   my ( $install, $sourceDir ) = @_;
296
   my ( $install, $sourceDir ) = @_;
288
   my %placeHolders = 
297
   my %placeHolders = 
289
      ( 
298
      ( 
290
        '<bindir>' => $$install{'bindir'},
299
        '<bindir>' => $$install{'bindir'},
291
        '<confdir>' => $$install{'confdir'}
300
        '<confdir>' => $$install{'confdir'},
-
 
301
        '<default owner>' => $$install{'default owner'},
-
 
302
        '<default group>' => $$install{'default group'},
-
 
303
        '<default permission>' => $$install{'default permission'}
292
      );
304
      );
293
 
305
 
294
   my $allFiles = $$install{'files'};
306
   my $allFiles = $$install{'files'};
295
 
307
 
296
   # find all directory entries and load files in that directory into $$install{'files'}
308
   # find all directory entries and load files in that directory into $$install{'files'}
Line 363... Line 375...
363
# this actually does the installation, except for the configuration
375
# this actually does the installation, except for the configuration
364
sub doInstall {
376
sub doInstall {
365
   my $install = shift;
377
   my $install = shift;
366
   my $fileList = $$install{'files'};
378
   my $fileList = $$install{'files'};
367
   
379
   
368
   &checkDirectoryExists( $$install{'bindir'} . '/' );
380
   &checkDirectoryExists( $$install{'bindir'} . '/', $$install{'default permission'}, "$$install{'default owner'}:$$install{'default group'}" );
369
   foreach my $file ( keys %$fileList ) {
381
   foreach my $file ( keys %$fileList ) {
370
      next unless ( $$fileList{$file}{'type'} && $$fileList{$file}{'type'} eq 'file' );
382
      next unless ( $$fileList{$file}{'type'} && $$fileList{$file}{'type'} eq 'file' );
371
      next if $$install{'action'} eq 'upgrade' && ! defined( $$fileList{$file}{'installed version'} )
383
      next if $$install{'action'} eq 'upgrade' && ! defined( $$fileList{$file}{'installed version'} )
372
              ||
384
              ||
373
              ( $$fileList{$file}{'new version'} eq $$fileList{$file}{'installed version'} );
385
              ( $$fileList{$file}{'new version'} eq $$fileList{$file}{'installed version'} );
374
      &checkDirectoryExists( $$fileList{$file}{'target'} );
386
      &checkDirectoryExists( $$fileList{$file}{'target'}, $$install{'default permission'}, "$$install{'default owner'}:$$install{'default group'}" );
375
      &runCommand( 
387
      &runCommand( 
376
            "cp $$fileList{$file}{'source'} $$fileList{$file}{'target'}",
388
            "cp $$fileList{$file}{'source'} $$fileList{$file}{'target'}",
377
            "chmod $$fileList{$file}{'permission'} $$fileList{$file}{'target'}",
389
            "chmod $$fileList{$file}{'permission'} $$fileList{$file}{'target'}",
378
            "chown  $$fileList{$file}{'owner'} $$fileList{$file}{'target'}"
390
            "chown  $$fileList{$file}{'owner'} $$fileList{$file}{'target'}"
379
            );
391
            );