Subversion Repositories camp_sysinfo_client_3

Rev

Rev 80 | Rev 82 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 80 Rev 81
Line 106... Line 106...
106
      } # foreach
106
      } # foreach
107
   } # if
107
   } # if
108
} # enableModules
108
} # enableModules
109
 
109
 
110
sub showConf {
110
sub showConf {
-
 
111
   use Data::Dumper;
-
 
112
   
111
   my $configuration = shift;
113
   my $configuration = shift;
-
 
114
   local $Data::Dumper::Purity = 1;
-
 
115
   $Data::Dumper::Indent = 3;
-
 
116
   $Data::Dumper::Varname = '$configuration';
-
 
117
   $Data::Dumper::Quotekeys = 1;
-
 
118
   $Data::Dumper::Sortkeys = 1;
112
#   print Dumper( $configuration ); die;
119
   $config = Data::Dumper->Dump( [$configuration] );
-
 
120
 
-
 
121
   return $conf;
113
   my $conf;
122
   my $conf;
114
   $conf .= "\$clientName = '" .   ( defined( $$configuration{'clientName'}   ) ? $$configuration{'clientName'}   : '' ) . "';\n";
123
   $conf .= "\$clientName = '" .   ( defined( $$configuration{'clientName'}   ) ? $$configuration{'clientName'}   : '' ) . "';\n";
115
   $conf .= "\$serialNumber = '" . ( defined( $$configuration{'serialNumber'} ) ? $$configuration{'serialNumber'} : '' ) . "';\n";
124
   $conf .= "\$serialNumber = '" . ( defined( $$configuration{'serialNumber'} ) ? $$configuration{'serialNumber'} : '' ) . "';\n";
116
   $conf .= "\$hostname = '" .     ( defined( $$configuration{'hostname'}     ) ? $$configuration{'hostname'}     : '' ) . "';\n";
125
   $conf .= "\$hostname = '" .     ( defined( $$configuration{'hostname'}     ) ? $$configuration{'hostname'}     : '' ) . "';\n";
117
   $conf .= "\$UUID = '" .      ( defined( $$configuration{'UUID'}     ) ? $$configuration{'UUID'}     : '' ) . "';\n";
126
   $conf .= "\$UUID = '" .      ( defined( $$configuration{'UUID'}     ) ? $$configuration{'UUID'}     : '' ) . "';\n";
Line 151... Line 160...
151
      my $contents = join( '', <CONF> );
160
      my $contents = join( '', <CONF> );
152
      close CONF;
161
      close CONF;
153
      # now, eval the information we just read.
162
      # now, eval the information we just read.
154
      # NOTE: we must turn off strict while doing this, and we die if something breaks.
163
      # NOTE: we must turn off strict while doing this, and we die if something breaks.
155
      no strict "vars"; eval( $contents ); use strict "vars"; die "Error during eval: $@\n" if $@;
164
      no strict "vars"; eval( $contents ); use strict "vars"; die "Error during eval: $@\n" if $@;
-
 
165
      # if this is a v2 config, we will update it
-
 
166
      $config{'clientName'} = $clientName unless $config{'clientName'};
-
 
167
      $config{'serialNumber'} = $serialNumber unless $config{'serialNumber'};
-
 
168
      $config{'UUID'} = $UUID unless $config{'UUID'};
-
 
169
      $config{'hostname'} = $hostname unless $config{'hostname'};
-
 
170
      $config{'moduleDirs'} = [ @moduleDirs ] unless $config{'moduleDirs'};
-
 
171
      $config{'scriptDirs'} = [ @scriptDirs ] unless $config{'scriptDirs'};
-
 
172
      $config{'transports'} = $transports unless $config{'transports'};
156
   }
173
   }
-
 
174
 
-
 
175
 
157
   unless ( $hostname ) {
176
   unless ( $config{'hostname'} ) {
158
      $hostname = `hostname -f`;
177
      $hostname = `hostname -f`;
159
      chomp $hostname;
178
      chomp $hostname;
-
 
179
      $config{'hostname'} = $hostname;
160
   }
180
   }
161
   unless ( $serialNumber ) {
181
   unless ( $config{'serialnumber'} ) {
162
      $serialNumber = `dmidecode -t 1 | grep 'Serial Number' | cut -d':' -f2` if `which dmidecode`;
182
      $serialNumber = `dmidecode -t 1 | grep 'Serial Number' | cut -d':' -f2` if `which dmidecode`;
163
      chomp $serialNumber;
183
      chomp $serialNumber;
164
      $serialNumber =~ s/\s//gi;
184
      $serialNumber =~ s/\s//gi;
-
 
185
      $config{'serialnumber'} = $serialNumber;
165
   }
186
   }
166
   unless ( $UUID ) {
187
   unless ( $config{'UUID'} ) {
167
      $UUID = `dmidecode -t 1 | grep -i uuid | cut -d':' -f2` if `which dmidecode`;
188
      $UUID = `dmidecode -t 1 | grep -i uuid | cut -d':' -f2` if `which dmidecode`;
168
      $UUID =~ s/\s//gi;
189
      $UUID =~ s/\s//gi;
-
 
190
      $config{'UUID'} = $UUID;
169
   }
191
   }
170
 
192
 
171
   $config{'clientName'} = $clientName;
-
 
172
   $config{'serialNumber'} = $serialNumber;
-
 
173
   $config{'UUID'} = $UUID;
-
 
174
   $config{'hostname'} = $hostname;
-
 
175
   $config{'moduleDirs'} = [ @moduleDirs ];
-
 
176
   $config{'scriptDirs'} = [ @scriptDirs ];
-
 
177
   $config{'transports'} = $transports;
-
 
178
   return \%config;
193
   return \%config;
179
}
194
}
180
 
195
 
181
# prompt the user for a response, then allow them to enter it
196
# prompt the user for a response, then allow them to enter it
182
# the first response is considered the default and is printed
197
# the first response is considered the default and is printed