installer.pl untested

filter: Statementstmt 0.0% 0 / 63 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 107 CC 1 SCAR 6.9
CC
1
Cov
0%
install_file
2.0
BEGIN
2.0
CRAP 2.0
1 use File::Copy "cp";
2  
3 print qq|ConfigDig CGI Installation and Initialization
4  
5 Please provide the full path to your base ht://Dig installation directory
6 (usually something like /opt/www/). This is where your ht://Dig conf,
7 share, bin, and cgi-bin directories are located.
8 |;
9  
10 #Get the path to the ht://Dig base directory
11 do {
12 print "Enter path:";
13 chomp($base_path = <STDIN>);
14 print "$base_path is not a directory.\n" if !-d $base_path;
15 } until -d $base_path;
16  
17 print qq|
18 ConfigDig uses a small registry file that is usually placed in your
19 ht://Dig configuration files directory (although you can technically place
20 it anywhere you wish).
21  
22 Please enter the full path to your ht://Dig configuration files
23 directory (the default ht://Dig conf file is "htdig.conf").
24 The path is usually something like /opt/www/conf/ by default. The
25 ConfigDig registry file, will be created here.
26 |;
27  
28 #Get the path to the ht://Dig conf directory
29 do {
30 print "Enter path:";
31 chomp($conf_path = <STDIN>);
32 print "$conf_path is not a directory.\n" if !-d $conf_path;
33 } until -d $conf_path;
34  
35 print qq|
36 ConfigDig also creates log files that can be useful for reviewing the
37 outcome of index creation and dig processes. Please provide a directory
38 where ConfigDig can place these log files. A good choice is to create a
39 "logs" directory in your ht://Dig base directory and use it (such as
40 /opt/www/logs/"
41 |;
42  
43 #Get the path to the ht://Dig log directory
44 do {
45 print "Enter path:";
46 chomp($log_path = <STDIN>);
47 print "$log_path is not a directory.\n" if !-d $log_path;
48 } until -d $log_path;
49  
50  
51  
52 #Create the registry file
53 open(SITES,">$conf_path/configdig_sites.pl") or die "Couldn't create file
54 at $conf_path. Must have write capability.\n";
55 print SITES qq|\$configdig_log_path = '$log_path';\n|;
56 print SITES qq|\$htdig_base_path = '$base_path';\n|;
57 print SITES "1;\n";
58 close(SITES);
59  
60 print "Successfully created registry file.\n";
61  
62 print qq|
63 Now we need to know where you'd like the CGI files to go.
64 Please provide a valid directory where the CGI files can be
65 placed. It should be marked cgi executible in your web server's
66 configuration. Preferably, it should be empty, as the files will be
67 placed directly in this location, so please be
68 careful not to overwrite files that may already exist!
69  
70 |;
71  
72 #Get the path to the CGI directory
73 do {
74 print "Enter path:";
75 chomp($cgi_path = <STDIN>);
76 print "$cgi_path is not a directory.\n" if !-d $cgi_path;
77 } until -d $cgi_path;
78  
79 #Copy in the cgi files
80 install_file("cd.css");
81 install_file("index.cgi");
82 install_file("autodetect.cgi");
83 install_file("edit_conf.cgi");
84 install_file("edit_site.cgi");
85 install_file("local_inc.pl");
86 install_file("new_site.cgi");
87 install_file("proc_tpl.pl");
88 install_file("view_site.cgi");
89 mkdir("$cgi_path/tpl",0755);
90 if ($! and $! ne "File exists") {
91 die "Couldn't create $cgi_path/tpl directory: $!\n
92 Must have write capability.\n";
93 }
94 install_file("tpl/autodetect.cgi.html");
95 install_file("tpl/index.cgi.html");
96 install_file("tpl/edit_conf.cgi.html");
97 install_file("tpl/new_site.cgi.html");
98 install_file("tpl/view_site.cgi.html");
99 install_file("tpl/edit_site.cgi.html");
100  
101 open(STG, ">$cgi_path/cgi_settings.pl") or die "Couldn't create
102 cgi_settings.pl file in $cgi_path: $!\nMust have write capability.\n";
103  
104 print STG qq|
105 \$conf_path = '$conf_path/configdig_sites.pl';
106 \$T::style_sheet_link =
107 '<LINK REL="stylesheet" HREF="cd.css" TYPE="text/css">';
108 1;
109 |;
110 close STG;
111 print "CGI installation successful.\n";
112  
113 print qq|
114 If you installed the ConfigDig perl modules in a custom directory, your
115 CGI scripts must know about it. If you wish, the local_inc.pl file that
116 is in your ConfigDig CGI directory can be updated to add this directory to
117 the module search path for the CGI scripts. Either enter the directory
118 now, or hit [enter] to skip this part.
119 |;
120  
121 #Get the custom module install path
122 do {
123 print "Enter path (or hit [enter] to skip):";
124 chomp($mod_path = <STDIN>);
125 print "$mod_path is not a directory.\n" if (!-d $mod_path &&
126 $mod_path ne "");
127 } until (-d $mod_path or $mod_path eq "");
128  
129 if ($mod_path) {
130 open(LI, ">$cgi_path/local_inc.pl") or die "Couldn't open
131 $cgi_path/local_inc.pl for writing. Must have write capability.\n";
132 print LI "push(\@INC,'$mod_path');\n1;";
133 close(LI);
134 print "local_inc.pl was updated successfully.\n";
135 }
136  
137 print qq|
138 Configuration is now complete. Problems in installation or usage can be
139 logged on the ConfigDig bug tracking system found at
140 http://configdig.sourceforge.net
141  
142 We hope you find ConfigDig useful!
143 |;
144  
145 #Helper copy routine
146 sub install_file {
147 cp("./cgi/$_[0]", "$cgi_path/$_[0]") or warn "Couldn't copy $_[0]
148 to $cgi_path\n";
149 }