Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 26 Rev 28
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
 
2
 
3
use warnings;
3
use warnings;
4
use strict;  
4
use strict;  
5
 
5
 
6
our $VERSION = '1.1.2';
6
our $VERSION = '1.1.3';
7
 
7
 
8
# find our location and use it for searching for libraries
8
# find our location and use it for searching for libraries
9
BEGIN {
9
BEGIN {
10
   use FindBin;
10
   use FindBin;
11
   use File::Spec;
11
   use File::Spec;
12
   use lib File::Spec->catdir($FindBin::Bin);
12
   use lib File::Spec->catdir($FindBin::Bin);
13
}
13
}
14
 
14
 
15
use sysinfoconf;
15
use sysinfoconf;
16
 
16
 
-
 
17
$TESTING = 1;
-
 
18
 
17
my $seedFile = 'sysinfo-client.seed';
19
my $seedFile = 'sysinfo-client.seed';
18
my $sysinfo2 = '/etc/sysinfo/sysinfo.conf';
20
my $sysinfo2 = '/etc/sysinfo/sysinfo.conf';
19
 
21
 
20
 
22
 
21
sub moveFiles {
23
sub moveFiles {
22
   # an extremely basic installer for sysinfo-client
24
   # an extremely basic installer for sysinfo-client
23
 
25
   
24
   # create all the directories we need, set permissions
26
   # create all the directories we need, set permissions
25
   for $dir ( $binDir, $confDir, @moduleDirs, @scriptDirs ) {
27
   for my $dir ( $binDir, $confDir, @moduleDirs, @scriptDirs ) {
26
      next if -d $dir;
28
      next if -d $dir;
-
 
29
      if ( $TESTING ) {
-
 
30
         print "mkdir -p $dir\n";
-
 
31
         print "chmod 0700 $dir\n";
-
 
32
      } else {
27
      `mkdir -p $dir`;
33
         `mkdir -p $dir`;
28
      `chmod 0700 $dir`;
34
         `chmod 0700 $dir`;
-
 
35
      }
29
   }
36
   }
30
   # copy the modules and scripts
37
   # copy the modules and scripts
31
   # all modules start with 0600, and scripts with 0700
38
   # all modules start with 0600, and scripts with 0700
32
   # modules will be "turned on" by setting their permissions to 0700
39
   # modules will be "turned on" by setting their permissions to 0700
33
   # in the osinstall specialty scrips
40
   # in the osinstall specialty scrips
34
   for $dir ( 'modules', 'scripts' ) {
41
   for my $dir ( 'modules', 'scripts' ) {
-
 
42
      if ( $TESTING ) {
35
      `cp -av $dir $binDir`;
43
         print "cp -av $dir $binDir\n";
36
      `rm -fR $binDir/$dir/.svn`;
44
         print "rm -fR $binDir/$dir/.svn\n";
37
      `chmod 0700 $binDir/$dir`;
45
         print "chmod 0700 $binDir/$dir\n";
38
      if ( $dir eq 'scripts' ) {
-
 
39
         `chmod -fR 0700 $binDir/$dir/*`;
46
         $dir eq 'scripts' ? print "chmod -fR 0700 $binDir/$dir/*\n" : print "chmod -fR 0600 $binDir/$dir/*\n";
40
      } else {
47
      } else {
-
 
48
         `cp -av $dir $binDir`;
-
 
49
         `rm -fR $binDir/$dir/.svn`;
41
         `chmod -fR 0600 $binDir/$dir/*`;
50
         `chmod 0700 $binDir/$dir`;
-
 
51
         $dir eq 'scripts' ? `chmod -fR 0700 $binDir/$dir/*` : `chmod -fR 0600 $binDir/$dir/*`;
42
      }
52
      }
43
   }
53
   }
44
 
54
 
45
   # copy the binary files and the documentation. Default all to
55
   # copy the binary files and the documentation. Default all to
46
   # 0600
56
   # 0600
47
   for $file ( 'sysinfo-client','notes', 'sysinfo-client.conf.template','configure.pl', 'uninstall.pl', 'sysinfoconf.pm' ) {
57
   for my $file ( 'sysinfo-client','notes', 'sysinfo-client.conf.template','configure.pl', 'uninstall.pl', 'sysinfoconf.pm' ) {
-
 
58
      if ( $TESTING ) {
-
 
59
         print "cp $file $binDir\n";
-
 
60
         print "chmod 0600 $binDir/$file\n";
-
 
61
      } else {
48
      `cp $file $binDir`;
62
         `cp $file $binDir`;
49
      `chmod 0600 $binDir/$file`;
63
         `chmod 0600 $binDir/$file`;
-
 
64
      }
50
   }
65
   }
51
 
66
 
52
   # Set permissions for the executable files
67
   # Set permissions for the executable files
53
   for my $file ( "$binDir/sysinfo-client", "$binDir/configure.pl", "$binDir/uninstall.pl" ) {
68
   for my $file ( "$binDir/sysinfo-client", "$binDir/configure.pl", "$binDir/uninstall.pl" ) {
-
 
69
      if ( $TESTING ) {
-
 
70
         print "chmod 0700 $file\n";
-
 
71
      } else {
54
      `chmod 0700 $file`;
72
         `chmod 0700 $file`;
-
 
73
      }
55
   }
74
   }
56
   
75
   
57
   # Everything is owned by root
76
   # Everything is owned by root
58
   foreach my $dir ( $binDir, $confDir ) {
77
   foreach my $dir ( $binDir, $confDir ) {
-
 
78
      if ( $TESTING ) {
-
 
79
         print "chown -fR root:root $dir\n";
-
 
80
      } else {
59
      `chown -fR root:root $dir`;
81
         `chown -fR root:root $dir`;
-
 
82
      }
60
   }
83
   }
61
 
84
 
62
}
85
}
63
 
86
 
64
# simply attempts to detect the operating system so we can do OS
87
# simply attempts to detect the operating system so we can do OS
65
# specific actions at the end.   
88
# specific actions at the end.   
66
sub getOperatingSystem {
89
sub getOperatingSystem {
67
   my @OSTypes = ( 'ipfire','debian' );
90
   my @OSTypes = ( 'ipfire','debian' );
68
   my $OS = `uname -a`;
91
   my $OS = `uname -a`;
69
   foreach $osType ( @OSTypes ) {
92
   foreach my $osType ( @OSTypes ) {
70
      return $osType if $OS =~ m/$osType/i;
93
      return $osType if $OS =~ m/$osType/i;
71
   }
94
   }
72
   return '';
95
   return '';
73
} # getOperatingSystem
96
} # getOperatingSystem
74
 
97
 
Line 140... Line 163...
140
 
163
 
141
&processParameters( @ARGV );
164
&processParameters( @ARGV );
142
 
165
 
143
&moveFiles();
166
&moveFiles();
144
 
167
 
-
 
168
exit ;
-
 
169
 
145
if ( &yesno( "Preseed the configuration file?" ) ) {
170
if ( &yesno( "Preseed the configuration file?" ) ) {
146
   &makeConfig();
171
   &makeConfig();
147
   print "Writing Config file; run configure.pl to modify it\n";
172
   print "Writing Config file; run configure.pl to modify it\n";
148
   &writeConfig( $confDir, $confName, &showConf() );
173
   &writeConfig( $confDir, $confName, &showConf() );
149
   #print &showConf();
174
   #print &showConf();