Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 139 Rev 144
Line 120... Line 120...
120
                  },
120
                  },
121
                  'opnsense' => {
121
                  'opnsense' => {
122
                     'fileexists' => '/conf/config.xml',
122
                     'fileexists' => '/conf/config.xml',
123
                     'bindir' => '/usr/local/opt/camp/sysinfo-client',
123
                     'bindir' => '/usr/local/opt/camp/sysinfo-client',
124
                     'confdir' => '/usr/local/etc/camp/sysinfo-client',
124
                     'confdir' => '/usr/local/etc/camp/sysinfo-client',
125
                     'crontab' => 'ln -fs <bindir>/sysinfo-client /etc/periodic/daily/sysinfo-client',
125
                     #'crontab' => 'ln -fs <bindir>/sysinfo-client /etc/periodic/daily/sysinfo-client',
126
                     'modules' => '((bsd)|(unix)|(all))',
126
                     'modules' => '((bsd)|(unix)|(all))',
127
                    'default group' => 'wheel',
127
                    'default group' => 'wheel',
128
                    'default owner' => 'root',
128
                    'default owner' => 'root',
129
                    'files' => {
129
                    'files' => {
130
                              'YAML' => { 
-
 
131
                                    'type' => 'directory',
-
 
132
                                    'permission' => '777', 
-
 
133
                                    'owner' => '<default owner>:<default group>', 
-
 
134
                                    'target' =>  '<bindir>'
-
 
135
                                 },
-
 
136
                              'Tiny.pm' => { 
-
 
137
                                    'type' => 'file',
-
 
138
                                    'permission' => '444',
-
 
139
                                    'owner' => '<default owner>:<default group>',
-
 
140
                                    'target' =>  '<bindir>/YAML'
-
 
141
                                 },
-
 
142
                              'actions_sysinfo.conf' => {
130
                              'actions_sysinfo.conf' => {
143
                                    'type' => 'file',
131
                                    'type' => 'file',
144
                                    'permission' => '755',
132
                                    'permission' => '755',
145
                                    'owner' => '<default owner>:<default group>',
133
                                    'owner' => '<default owner>:<default group>',
146
                                    'target' => '/usr/local/opnsense/service/conf/actions.d',
134
                                    'target' => '/usr/local/opnsense/service/conf/actions.d',
Line 160... Line 148...
160
#      apt-get -y install libwww-perl
148
#      apt-get -y install libwww-perl
161
# instead of
149
# instead of
162
#      apt-get -y install libwww-perl perl-modules
150
#      apt-get -y install libwww-perl perl-modules
163
# flexibility vs efficiency in this case.
151
# flexibility vs efficiency in this case.
164
our %libraries = ( 
152
our %libraries = ( 
-
 
153
                  'File::Basename' => {
-
 
154
                     'debian' => {
165
                  'File::Basename' => { 'debian' => 'apt-get -y install perl-modules' },
155
                        'command'   => 'apt-get -y install',
-
 
156
                        'parameter' => 'perl-modules'
-
 
157
                     }
-
 
158
                  },
-
 
159
                  'Exporter' => {
-
 
160
                     'debian' => {
166
                  'Exporter' => { 'debian' => 'apt-get -y install perl-base' },
161
                        'comand' => 'apt-get -y install',
-
 
162
                        'parameter' => 'perl-base'
-
 
163
                     },
-
 
164
                  },
167
                  'LWP' => { 
165
                  'LWP' => { 
-
 
166
                     'debian' => {
168
                             'debian' => 'apt-get -y install libwww-perl',
167
                        'command'   => 'apt-get -y install',
-
 
168
                        'parameter' => 'libwww-perl'
-
 
169
                     },
-
 
170
                     'freebsd' => {
-
 
171
                        'command'   => 'echo y | pkg install',
169
                             'freebsd' => 'pkg install -y p5-libwww'
172
                        'parameter' => 'p5-libwww'
170
                           },
173
                     }
-
 
174
                  },
171
                  'YAML::Tiny' => {
175
                  'YAML::Tiny' => {
-
 
176
                     'debian' => {
172
                              'debian' => 'apt-get -y install libyaml-tiny-perl',
177
                        'command'   => 'apt-get -y install',
-
 
178
                        'parameter' => 'libyaml-tiny-perl',
-
 
179
                     },
-
 
180
                     'freebsd' => {
173
                              'freebsd' => 'echo y | pkg install p5-YAML-Tiny',
181
                        'command' => 'echo y | pkg install',
-
 
182
                        'parameter' => 'p5-YAML-Tiny'
-
 
183
                     },
-
 
184
                     'opnsense' => {
-
 
185
                        'command' => 'cpan -i',
-
 
186
                        'parameter' => 'YAML::Tiny'
-
 
187
                     },
-
 
188
                     'ipfire' => {
-
 
189
                        'command' => 'cpan -i',
-
 
190
                        'parameter' => 'YAML::Tiny'
-
 
191
                     }
-
 
192
                  },
-
 
193
                  'Sys::Syslog' => {
-
 
194
                     'debian' => {
174
                              'opnsense' => 'gunzip Tiny.pm.gz ; mkdir YAML ; mv Tiny.pm YAML',
195
                        'command' => 'apt-get -y install',
-
 
196
                        'parameter' => 'libsys-syslog-perl',
-
 
197
                     },
-
 
198
                     'freebsd' => {
175
                              'ipfire' => 'gunzip Tiny.pm.gz ; mkdir YAML ; mv Tiny.pm YAML'
199
                        'command' => 'echo y | pkg install',
-
 
200
                        'parameter' => 'p5-Unix-Syslog',
176
                           }
201
                     }
-
 
202
                  }
177
                );
203
                );
178
 
204
 
179
our %binaries = (
205
our %binaries = (
180
                   'dmidecode' => {
206
                  'dmidecode' => {
-
 
207
                     'debian' => {
181
                                    'debian' => 'apt-get -y install dmidecode',
208
                        'command' => 'apt-get -y install',
-
 
209
                        'parameter' => 'dmidecode'
-
 
210
                     },
-
 
211
                     'freebsd' => {
182
                                    'freebsd' => 'pkg install -y dmidecode'
212
                        'command' => 'echo y | pkg install',
-
 
213
                        'parameter' => 'dmidecode'
-
 
214
                     },
183
                                  }
215
                     'opnsense' => {
-
 
216
                        'command' => 'echo y | pkg install',
-
 
217
                        'parameter' => 'dmidecode'
-
 
218
                     }
-
 
219
                  }
184
               );
220
               );
-
 
221
 
-
 
222
 
-
 
223
# if subroutine &postInstall exists, it is called with a reference to the %install hash
-
 
224
# postInstall may return, or may call some other script. it is the last thing called by
-
 
225
# the installer
-
 
226
sub postInstall {
-
 
227
   my $install = shift;
-
 
228
   
-
 
229
   # We need to open sysinfoconf so we can build the configuration file
-
 
230
   # using eval, since the installer is responsible for loading YAML::Tiny, so we may not
-
 
231
   # have it defined when we first start up.
-
 
232
   eval( 'use sysinfoconf qw/&writeConfig &makeConfig &showConf/;' );
-
 
233
 
-
 
234
   &logIt( 'Entering postInstall to build configuration' );
-
 
235
   # seed configuration, if needed
-
 
236
   if ( $$install{'build config'} ) {
-
 
237
      my $config;
-
 
238
      my @fileList;
-
 
239
 
-
 
240
      # the order is important here as, if multiple files exist, latter ones can
-
 
241
      # overwrite values in the previous. We do a push so the first value pushed
-
 
242
      # is processed last, ie has higher priority.
-
 
243
      push @fileList, $install->{'configuration'}->{'old configuration file'};
-
 
244
      push @fileList, $install->{'configuration'}->{'configuration file'};
-
 
245
 
-
 
246
      my $seedFile = $install->{'configuration'}->{'configuration seed file'};
-
 
247
      if ( -e $install->{'configuration seed file'} ) {
-
 
248
         push @fileList, $install->{'configuration seed file'};
-
 
249
      } # if preload seed file
-
 
250
 
-
 
251
      $config = &makeConfig( @fileList );
-
 
252
      # if ScriptDirs and moduleDirs not populated, do so from our configuration
-
 
253
      if ( ! $$config{'scriptDirs'} || ! scalar @{ $$config{'scriptDirs'} }  ) {
-
 
254
         $config->{'scriptDirs'} = [ $install->{'files'}->{'scripts'}->{'target'} ];
-
 
255
      }
-
 
256
      if ( ! $$config{'moduleDirs'} || ! @{ $$config{'moduleDirs'} }  ) {
-
 
257
         $config->{'moduleDirs'} = [ $install->{'files'}->{'modules'}->{'target'} ];
-
 
258
      }
-
 
259
      # We should have a nice combined configuration, so we'll write it to a temporary file
-
 
260
      my $filename = &writeConfig( '', &showConf( $config ) );
-
 
261
      my $confFileName = $install{'configuration'}{'configuration file'};
-
 
262
      # configure.pl is already designed to combine our temp file with our current config file and write it ou
-
 
263
      # so we'll just use that instead of reinventing the wheel
-
 
264
      exec( "$install{bindir}/configure.pl -f $filename -o $confFileName" );
-
 
265
   } # if we are building/merging configuration
-
 
266
}