#! /usr/bin/perl -w use strict; use Data::Dumper; use Cwd; use CPAN; use File::Copy qw( cp ); ################################################################################ # TODO: # put in package namespace # compare/contrast with MS-'s installer # why is root needed? (oh, for writing the apache.conf file) # install plugin dependencies (ooh, add to twiki form) # (external dependencies like imagemagick and latex, not other perl modules as those will be handled automatically) # install perl modules to ~user account (see CpanPerlModulesRequirement) (work in progress in cpan.pl) # CPAN:Test::Unit (CPAN:Error, CPAN:Class::Inner, CPAN:Devel::Symdump) # CPAN:LWP::Simple (CPAN:URI, CPAN:HTML::Parser, CPAN:HTML::Tagset) # CPAN:CGI::Session (CPAN:Digest::MD5, CPAN:Storable) (SmartSessionPlugin) # find proper instructions for locking/unlocking/updating the rcs files (?, for a proper topic update) ################################################################################ my $twiki = 'TWiki20040901.tar'; #================================================================================ # check to run as root (need permissions--- grrr, fix that) (why, again? i forget..., oh yeah, for apache.conf) chomp( my $whoami = `whoami` ); die "must run this as root (or sudo)\n" unless $whoami eq 'root'; my $account = shift or die "Usage: install.pl \n"; # validate account exists -- how do you do that generally? (eg, /etc/users doesn't exist on MacOsX) #================================================================================ # find official TWiki distribution file unless ( -f $twiki ) { chdir 'install' } die "no twiki install tar file ($twiki)\n" unless -f $twiki; #================================================================================ # prepare for the actual installation print <<__CONFIRM__; About to install TWiki ($twiki) to user account (short account name is "$account") (Ctrl+C to abort installation, ENTER to continue) __CONFIRM__ <>; #================================================================================ # "install" official TWiki distribution file chdir '..'; # twiki/.. system qq{tar xf install/$twiki --owner $account} and die $!; # update standard webs # (created with: (sudo) tar cjvf ../install/ProjectManagement.wiki.tar.bz2 data/ProjectManagement/ pub/ProjectManagement/) (pkg-webs script now) opendir( WIKIS, 'install/webs' ) or die $!; my @webs = grep { /\.wiki\.tar\.bz2$/ } readdir( WIKIS ) or die $!; closedir( WIKIS ) or die $!; chdir 'twiki'; foreach my $web ( @webs ) { print STDERR "Updating system web [$web]\n"; `tar xjvf ../install/webs/$web` or die $!; } chdir '..'; # install local webs if ( opendir( WIKIS, 'install/webs/local' ) ) { my @myWebs = grep { /\.wiki\.tar\.bz2$/ } readdir( WIKIS ) or die $!; closedir( WIKIS ) or die $!; chdir 'twiki'; foreach my $localweb ( @myWebs ) { print STDERR "Installing web [$localweb]\n"; `tar xjvf ../install/webs/local/$localweb` or die $! } chdir '..'; } # install plugins my @plugins = qw( TWikiReleaseTrackerPlugin BuildContrib DistributionContrib AttrsContrib MacrosPlugin ImageGalleryPlugin MathModePlugin SmartSessionPlugin ); chdir 'twiki'; foreach my $plugin ( @plugins ) { `unzip -u ../install/downloads/$plugin.zip` or die $!; # TODO: run an standard-named install script (if included) } chdir '..'; # install addons chdir 'twiki/bin'; cp( qw( ../../install/downloads/xmlrpc xmlrpc ) ) or die $!; `chmod +x xmlrpc` and die $!; chdir '../..'; ################################################################################ # install plugins dependencies (and/or optional core dependencies) # MathModePlugin: sudo fink install latex2html (tetex, ...) # ImageGalleryPlugin: sudo fink install ImageMagick (...) ################################################################################ # install cpan modules used by plugins (and, optionally, by the core) #CPAN::Shell->o( qw( conf urllist push file://localhost/Users/wbniv/twiki/cpan/MIRROR/MINICPAN ) ); #CPAN::Shell->o( qw( conf prerequisites_policy follow ) ); #my @modules = qw( Test::Unit Error Class::Inner Devel::Symdump LWP::Simple URI HTML::Parser HTML::Tagset CGI::Session Digest::MD5 Storable ); #foreach my $module ( @modules ) #{ # my $obj = CPAN::Shell->expand( Module => $module ) or warn $!; # $obj->install; # or warn "Error installing $module\n"; #} ################################################################################ my $apacheConfig = "/private/etc/httpd/users/$account.conf"; # MacOsX-specific apache configuration file (shouldn't be hard to finish generalising) if ( open( CONF, ">$apacheConfig" ) ) { print CONF <<__APACHECONF__; Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all ScriptAlias /~$account/twiki/bin/ "/Users/$account/Sites/twiki/bin/" Alias /~$account/twiki/ "/Users/$account/Sites/twiki/" Options +ExecCGI SetHandler cgi-script Allow from all Options FollowSymLinks +Includes AllowOverride None Allow from all deny from all deny from all __APACHECONF__ close( CONF ); } else { print STDERR "Unable to write apache configuration file!\n"; } ### fix file permissions ### grrr, add these checks for file persmissions and ownerships to testenv... chdir 'twiki'; # twiki chdir 'bin'; # twiki/bin my $bin = `ls | grep -v \\\\.`;; #`chmod 755 $bin` and die $!; chdir '..'; # twiki `chown -R www pub data` and die $!; chdir 'data'; # twiki/data `chmod -R 644 *` and die $!; `chmod 775 *` and die $!; chdir '..'; # twiki chdir '..'; # twiki/.. ################################################################################ ### various patches/fixes/upgrades # make testenv a little more useful... `patch -p0 %WEB% `patch -p0