#! /usr/bin/perl -w #my $filePathToTwiki = "/home/mrjc/cairotwiki.mrjc.com/twiki"; #my $urlPathToTwiki = "http://cairotwiki.mrjc.com/twiki"; use Getopt::Long; use Pod::Usage; GetOptions ("filepath=s" => \$filePathToTwiki, # numeric "urlpath=s" => \$urlPathToTwiki, # string 'help|?' => \$help ); pod2usage(1) if $help; if($filePathToTwiki) { pod2usage(1) unless ($urlPathToTwiki); fixPaths(); } fixPerms(); sub fixPerms { system('chmod og-w bin'); system('chmod og-w bin/*'); } sub fixPaths { print "filepath=$filePathToTwiki\n"; print "urlpath=$urlPathToTwiki\n"; my %patterns = ("!FILE_path_to_TWiki!" => $filePathToTwiki, "!URL_path_to_TWiki!" => $urlPathToTwiki); use FileHandle; my $htaccessTXTfh = new FileHandle("< bin/.htaccess.txt") || die $!; local $/; undef $/; my $file = <$htaccessTXTfh>; close $htaccessTXTfh; foreach my $key (keys %patterns) { my $value = $patterns{$key}; # print "replacing $key with $value\n"; $file =~ s/$key/$value/g; } my $htaccessFh = new FileHandle("> bin/.htaccess"); print $htaccessFh $file; close $htaccessFh; } __END__ =head1 NAME fixHtaccess =head1 SYNOPSIS fixHtaccess.pl --filepath=/home/username/mydomain.com/twiki --urlpath=http://mydomain.com/twiki =head1 OPTIONS =over 8 =item B<-help> Print a brief help message and exits. =back =head1 DESCRIPTION B creates a bin/.htaccess file from the bin/.htaccess.txt file # !FILE_path_to_TWiki! # This is the absolute path to the directory where # you installed TWiki (where you unzipped the installation). The first # part should match the $dataDir setting in TWiki.cfg # !URL_path_to_TWiki! # This is the URL path you put into the webserver for users to use to # access TWiki. # =cut