-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·100 lines (89 loc) · 3.47 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
my $clientdir = 'client';
my $examplesdir = 'examples';
my $make_file_in = 'Makefile.in';
my $conf_file_in = 'pilite.conf.in';
my $make_file_out = 'Makefile';
my $conf_file_out = 'pilite.conf';
my @server_client_opts = ('installdir', 'homedir');
my @client_needed_opts = ('userkeyfile', 'remotehostname', 'remoteusername', 'remotescriptdir');
my @client_optional_opts = ('localscriptdir', 'sshexec', 'scpexec');
my $in_opts;
$in_opts->{installdir}= "";
$in_opts->{homedir} = "";
$in_opts->{userkeyfile} = "";
$in_opts->{remotehostname} = "";
$in_opts->{remoteusername} = "";
$in_opts->{remotescriptdir} = "";
$in_opts->{localscriptdir} = "";
$in_opts->{sshexec} = "";
$in_opts->{scpexec} = "";
my $result = GetOptions (
"installdir=s" => \$in_opts->{installdir},
"homedir=s" => \$in_opts->{homedir},
"userkeyfile=s" => \$in_opts->{userkeyfile},
"remotehostname=s" => \$in_opts->{remotehostname},
"remoteusername=s" => \$in_opts->{remoteusername},
"remotescriptdir=s" => \$in_opts->{remotescriptdir},
"localscriptdir=s" => \$in_opts->{localscriptdir},
"sshexec=s" => \$in_opts->{sshexec},
"scpexec=s" => \$in_opts->{scpexec});
if ((not length($in_opts->{installdir})) or (not length($in_opts->{homedir}))) {
print "ERROR: mandatory options installdir and homedir are not defined or empty!\n";
exit 1;
}
my $install_client = -1;
my $fdmake_in;
my $fdmake_out;
open($fdmake_in, "./$make_file_in") or die "ERROR: can not open $make_file_in file to configure: $!";
open($fdmake_out, ">", "./$make_file_out") or die "ERROR: can not open $make_file_out file for writing: $!";
foreach my $line (<$fdmake_in>) {
foreach my $key (@server_client_opts) {
$line =~ s{<$key>}{$in_opts->{$key}}xs;
}
print $fdmake_out $line;
}
close($fdmake_out);
close($fdmake_in);
print "configure of main required options done!!!\n";
my $needed_opts_count = 0;
my $message = "";
foreach my $key (@client_needed_opts) {
if (not length($in_opts->{$key})) {
$message .= "ERROR: client required option ".$key." is not defined or empty!\n";
} else {
$needed_opts_count++;
}
}
if ($needed_opts_count > 0) {
if (length($message) > 0) {
print "$message";
exit 1;
}
} else {
exit 0;
}
my $fdconf_in;
my $fdconf_out;
open($fdconf_in, "./$clientdir/$examplesdir/$conf_file_in") or die "ERROR: can not open $conf_file_in file to configure: $!";
open($fdconf_out, ">", "./$clientdir/$examplesdir/$conf_file_out") or die "ERROR: can not open $conf_file_out file for writing: $!";
foreach my $line (<$fdconf_in>) {
my $print_line = 1;
foreach my $key (@server_client_opts, @client_needed_opts) {
$line =~ s{<$key>}{$in_opts->{$key}}xs;
}
foreach my $key (@client_optional_opts) {
if (length($in_opts->{$key})) {
$line =~ s{<$key>}{$in_opts->{$key}}xs;
} else {
$print_line = 0 if ($line =~ /<$key>/);
}
}
print $fdconf_out $line if ($print_line);
}
close($fdconf_out);
close($fdconf_in);
print "client configure done!!!\n";