Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 102 Rev 106
Line 42... Line 42...
42
   my $answer = &getAnswer( $prompt, $default eq 'yes' ? ('yes','no' ) : ('no', 'yes') );
42
   my $answer = &getAnswer( $prompt, $default eq 'yes' ? ('yes','no' ) : ('no', 'yes') );
43
   return lc( substr( $answer, 0, 1 ) ) eq 'y';
43
   return lc( substr( $answer, 0, 1 ) ) eq 'y';
44
}
44
}
45
 
45
 
46
 
46
 
47
# checks various flags to 
-
 
48
sub determineOS {
-
 
49
   my $operatingSystems = shift;
-
 
50
   my $os = shift;
-
 
51
   my $osType;
-
 
52
   # first, look through our entries for fileexists
-
 
53
   unless ( $os ) {
-
 
54
      foreach $osType ( keys %$operatingSystems ) {
-
 
55
         next unless defined $operatingSystems->{$osType}->{'fileexists'};
-
 
56
         if (  -e $operatingSystems->{$osType}->{'fileexists'} ) {
-
 
57
            return $osType;
-
 
58
         } # if
-
 
59
      } # foreach
-
 
60
   } # unless
-
 
61
   # next, look for uname and see if that gives us a clue
-
 
62
   unless ( $os ) {
-
 
63
      my $osString = `uname -a`;
-
 
64
      foreach $osType ( keys %$operatingSystems ) {
-
 
65
         next unless defined $operatingSystems->{$osType}->{'regex'};
-
 
66
         print "Checking if OS is $osType in $osString\n" if $verbose > 2;
-
 
67
         if ( $osString =~ m/$$operatingSystems{$osType}{'regex'}/i ) {
-
 
68
            print "Yes, it is $osType\n" if $verbose > 2;
-
 
69
            return $osType;
-
 
70
         }
-
 
71
      } # foreach
-
 
72
   } # unless
-
 
73
   return '';
-
 
74
}
-
 
75
 
-
 
76
 
-
 
77
# hash to set up os specific rules
47
# hash to set up os specific rules
78
my %operatingSystems = (
48
my %operatingSystems = (
79
                  'debian' => {
49
                  'debian' => {
80
                     'regex'  => '(debian|mx|devuan)',
50
                     'regex'  => '(debian|mx|devuan)',
81
                     'install' => 'apt-get -y install libyaml-tiny-perl',
51
                     'install' => 'apt-get -y install libyaml-tiny-perl',
Line 94... Line 64...
94
                  },
64
                  },
95
                  
65
                  
96
                );
66
                );
97
 
67
 
98
 
68
 
99
my $os = determineOS( \%operatingSystems );
69
my $os = `./determineOS`;
100
 
70
 
101
die "Could not determine operating system, manual installation required\n" unless $os;
71
die "Could not determine operating system, manual installation required\n" unless $os;
102
 
72
 
103
eval( 'use YAML::Tiny' );
73
eval( 'use YAML::Tiny' );
104
if ( $@ ) { # we need to install YAML::Tiny
74
if ( $@ ) { # we need to install YAML::Tiny