Subversion Repositories camp_sysinfo_client_3

Rev

Blame | Last modification | View Log | Download | RSS feed

#! /usr/bin/env perl

# This file will contain information for a specific installer
# this allows the installer to be used on different programs.

# defines a basic install. Values are overridden depending on operating
# system as defined by %operatingSystems
our %install = (  'bindir' => '/opt/camp/sysinfo-client',
                 'confdir' => '/etc/camp/sysinfo-client',
                 'application name' => 'sysinfo client',
                 'default group' => 'root',
                 'default owner' => 'root',
                 'default permission' => '0700',
                 'configuration seed file' => '<installdir>/sysinfo-client.seed.yaml',
                 'configuration' => {
                          'configurator' => '<bindir>/configure.pl',
                          'configuration file' => '<confdir>/sysinfo-client.yaml',
                          'old configuration file' => '<confdir>/sysinfo-client.conf',
                          'permission' => '700',
                          'owner'      => '<default owner>',
                          'target'     => '<confdir>'
                            },
                 'files' => {
                           'configure.pl' => { 
                                 'type' => 'file',
                                 'permission' => '700', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>'
                              },
                           'sysinfo-client' => { 
                                 'type' => 'file',
                                 'permission' => '700',
                                 'owner' => '<default owner>:<default group>',
                                 'target' =>  '<bindir>'
                              },
                           'sysinfoconf.pm' => {
                                 'type' => 'file',
                                 'permission' => '600',
                                 'owner' => '<default owner>:<default group>',
                                 'target' =>  '<bindir>'
                              },
                           'notes' => { 
                                 'type' => 'file',
                                 'permission' => '600', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>'
                              },
                           'sysinfo-client.conf.template.yaml' => { 
                                 'type' => 'file',
                                 'permission' => '600', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>' 
                              },
                           'getSendEmail.pl' => { 
                                 'type' => 'file',
                                 'permission' => '700', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>' 
                              },
                           'install.pl' => {
                                 'type' => 'file',
                                 'permission' => '700', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>' 
                              },
                           'sysinfo-client.seed.example.yaml' => { 
                                 'type' => 'file',
                                 'permission' => '600', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>' 
                              },
                           'VERSION' => { 
                                 'type' => 'file',
                                 'permission' => '600', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>' 
                              },
                              'modules' => {
                                 'type' => 'directory',
                                 'permission' => '700', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>',
                                 'action' => 'chmod 700 *'
                              },
                              'scripts' => {
                                 'type' => 'directory',
                                 'permission' => '700', 
                                 'owner' => '<default owner>:<default group>', 
                                 'target' =>  '<bindir>',
                                 'action' => 'chmod 700 *'
                              },
                     }
                  );

# hash to set up os specific rules. these override values in %install when a particular operating
# system is detected.
our %operatingSystems = (
                  'debian' => {
                     'regex'  => '(debian|mx|devuan)',
                     'bindir' => '/opt/camp/sysinfo-client',
                     'confdir' => '/etc/camp/sysinfo-client',
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/cron.daily/sysinfo-client',
                     'modules' => '((linux)|(dpkg)|(unix)|(all))',
                  },
                  'ipfire' => {
                     'regex'  => 'ipfire',
                     'bindir' => '/opt/camp/sysinfo-client',
                     'confdir' => '/etc/camp/sysinfo-client',
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/fcron.daily/sysinfo-client.fcron',
                     'modules' => '((ipfire)|(unix)|(all))',
                  },
                  'freebsd' => {
                     'regex' => 'freebsd',
                     'bindir' => '/usr/local/opt/camp/sysinfo-client',
                     'confdir' => '/usr/local/etc/camp/sysinfo-client',
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/periodic/daily/sysinfo-client',
                     'modules' => '((bsd)|(unix)|(all))',
                    'default group' => 'wheel',
                    'default owner' => 'root',
                  },
                  'opnsense' => {
                     'fileexists' => '/conf/config.xml',
                     'bindir' => '/usr/local/opt/camp/sysinfo-client',
                     'confdir' => '/usr/local/etc/camp/sysinfo-client',
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/periodic/daily/sysinfo-client',
                     'modules' => '((bsd)|(unix)|(all))',
                    'default group' => 'wheel',
                    'default owner' => 'root',
                    'files' => {
                              'YAML' => { 
                                    'type' => 'directory',
                                    'permission' => '777', 
                                    'owner' => '<default owner>:<default group>', 
                                    'target' =>  '<bindir>'
                                 },
                              'Tiny.pm' => { 
                                    'type' => 'file',
                                    'permission' => '444',
                                    'owner' => '<default owner>:<default group>',
                                    'target' =>  '<bindir>/YAML'
                                 },
                              'actions_sysinfo.conf' => {
                                    'type' => 'file',
                                    'permission' => '755',
                                    'owner' => '<default owner>:<default group>',
                                    'target' => '/usr/local/opnsense/service/conf/actions.d',
                                    'post action' => 'service configd restart',
                                    'message' => 'No automatic run can be done. Please log in through the webui and enable the sysinfo cron job'
                                 },
                              },
                 },
                  
                );

# list of libraries used by the system. We will offer to install them if
# we know how. NOTE: I have chosen to put the full installation command
# for each library. This allows us to use the package selector OR a different
# piece of code on a per-library basis, but results in something like
#      apt-get -y install perl-modules
#      apt-get -y install libwww-perl
# instead of
#      apt-get -y install libwww-perl perl-modules
# flexibility vs efficiency in this case.
our %libraries = ( 
                  'File::Basename' => { 'debian' => 'apt-get -y install perl-modules' },
                  'JSON' => { 'debian' => 'apt-get -y install json-perl' },
                  'Exporter' => { 'debian' => 'apt-get -y install perl-base' },
                  'LWP' => { 
                             'debian' => 'apt-get -y install libwww-perl',
                             'freebsd' => 'pkg install -y p5-libwww'
                           },
                  'YAML::Tiny' => {
                              'debian' => 'apt-get -y install libyaml-tiny-perl',
                              'freebsd' => 'echo y | pkg install p5-YAML-Tiny',
                              'opnsense' => 'gunzip Tiny.pm.gz ; mkdir YAML ; mv Tiny.pm YAML',
                              'ipfire' => 'gunzip Tiny.pm.gz ; mkdir YAML ; mv Tiny.pm YAML'
                           }
                );

our %binaries = (
                   'dmidecode' => {
                                    'debian' => 'apt-get -y install dmidecode',
                                    'freebsd' => 'pkg install -y dmidecode'
                                  }
               );