1 |
#!/usr/bin/perl |
2 |
# |
3 |
# Douglas Thrift's Search Engine Install Script |
4 |
# |
5 |
# Douglas Thrift |
6 |
# |
7 |
|
8 |
use strict; |
9 |
|
10 |
my $path; |
11 |
while (<STDIN>) |
12 |
{ |
13 |
$path = $_; |
14 |
chomp($path); |
15 |
} |
16 |
|
17 |
my $install = $path; |
18 |
my $input = "search.cgi.unix"; |
19 |
my $output = "$install/http/search.cgi"; |
20 |
|
21 |
open(INPUT, "< $input") || die "$0: cannot open $input"; |
22 |
open(OUTPUT, "> $output") || die "$0: cannot open $output"; |
23 |
|
24 |
my $line; |
25 |
while ($line = <INPUT>) |
26 |
{ |
27 |
chomp($line); |
28 |
|
29 |
if ($line eq "#!/usr/bin/perl") |
30 |
{ |
31 |
my $perl = qx("which" "perl"); |
32 |
|
33 |
chomp($perl); |
34 |
|
35 |
if ($perl ne "" && $line ne "#!$perl") |
36 |
{ |
37 |
$line = "#!$perl"; |
38 |
} |
39 |
} |
40 |
elsif ($line =~ /my \$root = .+/) |
41 |
{ |
42 |
my $root = $install; |
43 |
|
44 |
my $begin = 0; |
45 |
while ($begin < length($root)) |
46 |
{ |
47 |
my $space = index($root, " ", $begin); |
48 |
|
49 |
last if ($space == -1); |
50 |
|
51 |
$root = substr($root, 0, $space) . "\\ " . substr($root, $space + |
52 |
1); |
53 |
|
54 |
$begin = $space + 2; |
55 |
} |
56 |
|
57 |
if ($line ne "my \$root = \"$root\";") |
58 |
{ |
59 |
$line = "my \$root = \"$root\";"; |
60 |
} |
61 |
} |
62 |
|
63 |
print OUTPUT "$line\n"; |
64 |
} |
65 |
|
66 |
close(INPUT); |
67 |
close(OUTPUT); |
68 |
|
69 |
chmod(0755, $output); |