#!/usr/bin/perl ################################################################################ # Script required by other scripts that work on the foswiki tree ################################################################################ use strict; use warnings; # --- # The foswiki installation root directory should have been passed # --- sub intro { my $root = $ARGV[0]; if (!$root) { $root = "" } $root =~ s/(\/)+$//; # this strips terminating dashes if (!$root) { print STDERR "You have to give the path to the root of the foswiki installation -- exiting\n"; exit 1 } if (! -d $root) { print STDERR "The path you have given, '$root', does not point to a directory -- exiting\n"; exit 1 } print "Working on foswiki installation tree rooted at '$root'\n"; # Check that all the subdirectories are actually there (this also ascertains that we are # in the correct root directory; we don't want to let rip on "/" for example) my $bin = "$root/bin"; my $data = "$root/data"; my $lib = "$root/lib"; my $locale = "$root/locale"; my $pub = "$root/pub"; my $templates = "$root/templates"; my $tools = "$root/tools"; my $working = "$root/working"; my @foswikiDirs = ( $bin, $data, $lib, $locale, $pub, $templates, $tools, $working ); my $exitNow = 0; for my $foswikiDir (@foswikiDirs) { if (! -d $foswikiDir) { print STDERR "The directory '$foswikiDir' does not exist ... something is wrong\n"; $exitNow = 1 } } if ($exitNow) { print STDERR "Exiting!\n"; exit 1 } return ( $root, $bin, $data, $lib, $locale, $pub, $templates, $tools, $working ) } 1;