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