#!c:/Perl/bin/perl print "Twiki NT Installer\n"; print "------------------------------\n"; print "Enter Install Directory\n"; $installDir = ; chop($installDir); copyDirs('.', $installDir); #now the file system paths need to use unix style slashes $installDir =~ s/\\/\//g; #enter configuration details.. print "please enter the Host URL of your wiki (eg http://your.domain.com)\n"; $hostURL = ; chop($hostURL); print "enter the relative URL path to your wiki (eg /twiki)\n"; $relativeUrlPath = ; chop($relativeUrlPath); open(IN, "$installDir\\lib\\TWiki.cfg.orig"); open(OUT, ">$installDir\\lib\\TWiki.cfg"); while () { if ($_ =~ /^\$wikiHomeUrl/) { $_ = "\$wikiHomeUrl = \"$hostURL$relativeUrlPath\";\n"; } if ($_ =~ /^\$defaultUrlHost/) { $_ = "\$defaultUrlHost = \"$hostURL\";\n"; } if ($_ =~ /^\$scriptUrlPath/) { $_ = "\$scriptUrlPath = \"$relativeUrlPath/bin\";\n"; } if ($_ =~ /^\$pubUrlPath/) { $_ = "\$pubUrlPath = \"$relativeUrlPath/pub\";\n"; } if ($_ =~ /^\$pubDir/) { $_ = "\$pubDir = \"$installDir/pub\";\n"; } if ($_ =~ /^\$templateDir/) { $_ = "\$templateDir = \"$installDir/templates\";\n"; } if ($_ =~ /^\$dataDir/) { $_ = "\$dataDir = \"$installDir/data\";\n"; } if ($_ =~ /^\$scriptSuffix/) { $_ = "\$scriptSuffix = \".pl\";\n"; } print OUT; } close(IN); close(OUT); ##Apache configuration.... print "please enter the directory location of your Apache httpd.conf file (c:\\perl\\conf)\n"; $httpConf = ; chop($httpConf); $httpConf = "$httpConf\\httpd.conf"; open(OUT, ">>$httpConf"); print OUT "#twikiConfig\n"; print OUT "Alias $relativeUrlPath \"$installDir\"\n"; print OUT "ScriptAlias $relativeUrlPath/bin/ \"$installDir/bin/\"\n"; print OUT " \n"; print OUT " AllowOverride None\n"; print OUT " Options ExecCGI\n"; print OUT " Order allow,deny\n"; print OUT " Allow from all\n"; print OUT " \n"; close(OUT); #END sub fixPerlFiles { local($from, $to) = @_; local ($first) = 0; open(IN, $from); open(OUT, ">$to"); while () { if ($first == 0) { $first = 1; $_ = "#!perl\n"; } print OUT; } close(IN); close(OUT); } sub copyDirs # from, to { local($from, $to) = @_; local(@filenames); local($copyCmd); if ( ! -e $to) { #print "$to does not exist - creating it..\n"; mkdir($to); } # print "opening $from \n"; opendir(DIR, $from); @filenames = readdir(DIR); closedir(DIR); for (@filenames) { next if $_ eq '.'; next if $_ eq '..'; next if $_ eq '.cvsignore'; if ( -d "$from\\$_" ) { #print "copyDirs(\"$from\\$_\", \"$to\\$_\")\n"; ©Dirs("$from\\$_", "$to\\$_"); } else { open(FILE, "$from\\$_"); local($line) = ; chop($line); close(FILE); # print "testing {$from\\$_}{$line}\n"; if ( $line =~ /perl/i ) { #print "$from\\$_ is a perl file\n"; fixPerlFiles("$from\\$_", "$to\\$_.pl"); print "p"; } else { $copyCmd = "copy $from\\$_ $to\\$_"; if ( $_ =~ /TWiki.cfg/i ) { $copyCmd = "$copyCmd.orig"; } # print "$copyCmd\n"; `$copyCmd`; print "."; } } } }