Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev Author Line No. Line
104 rodolico 1
#! /usr/bin/env perl
2
 
3
use strict;
4
use warnings;
5
 
6
 
7
my %osDefinitions = (
8
                  'debian' => {
9
                     'regex'  => '(debian|mx|devuan)',
10
                  },
11
                  'ipfire' => {
12
                     'regex'  => 'ipfire',
13
                  },
14
                  'freebsd' => {
15
                     'regex' => 'freebsd',
16
                  },
17
                  'opnsense' => {
18
                     'fileexists' => '/conf/config.xml',
19
                  },
20
 
21
                );
22
 
23
# script which determines which operating system we are running on.
24
my $os = shift;
25
my $osType;
26
# first, look through our entries for fileexists
27
unless ( $os ) {
28
   foreach $osType ( keys %osDefinitions ) {
29
      next unless defined $osDefinitions{$osType}{'fileexists'};
30
      if (  -e $osDefinitions{$osType}{'fileexists'} ) {
31
         print $osType;
32
         exit;
33
      } # if
34
   } # foreach
35
} # unless
36
# next, look for uname and see if that gives us a clue
37
unless ( $os ) {
38
   my $osString = `uname -a`;
39
   foreach $osType ( keys %osDefinitions ) {
40
      next unless defined $osDefinitions{$osType}{'regex'};
41
      if ( $osString =~ m/$osDefinitions{$osType}{'regex'}/i ) {
42
         print $osType;
43
         exit;
44
      }
45
   } # foreach
46
} # unless
47
exit 0; # we were not able to determine operating system