Subversion Repositories camp_sysinfo_client_3

Rev

Rev 104 | Rev 123 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#! /usr/bin/env perl

use strict;
use warnings;


my %osDefinitions = (
                  'debian' => {
                     'regex'  => '(debian|mx|devuan)',
                  },
                  'ipfire' => {
                     'regex'  => 'ipfire',
                  },
                  'freebsd' => {
                     'regex' => 'freebsd',
                  },
                  'opnsense' => {
                     'fileexists' => '/conf/config.xml',
                  },
                  
                );

# script which determines which operating system we are running on.
my $os = shift;
my $osType;
# first, look through our entries for fileexists
unless ( $os ) {
   foreach $osType ( keys %osDefinitions ) {
      next unless defined $osDefinitions{$osType}{'fileexists'};
      if (  -e $osDefinitions{$osType}{'fileexists'} ) {
         print $osType;
         exit;
      } # if
   } # foreach
} # unless
# next, look for uname and see if that gives us a clue
unless ( $os ) {
   my $osString = `uname -a`;
   foreach $osType ( keys %osDefinitions ) {
      next unless defined $osDefinitions{$osType}{'regex'};
      if ( $osString =~ m/$osDefinitions{$osType}{'regex'}/i ) {
         print $osType;
         exit;
      }
   } # foreach
} # unless
exit 0; # we were not able to determine operating system

Generated by GNU Enscript 1.6.5.90.