#!/usr/bin/perl -w use strict; my $opentext_file = "Socialtext-Open-2.0.0.1"; my $opentext_url = "http://switch.dl.sourceforge.net/sourceforge/socialtext/$opentext_file.tar.gz"; my $apt_get = 'apt-get'; # This is your local CPAN mirror my $base_server = 'http://192.168.1.13:8082/'; my @debian_packages = parse_list(<<'=cut'); =head1 PRELIMINARY STEPS Start the clean VM image. Log in as C, password is C. Configure Perl to use a local CPAN mirror. No remote CPAN mirror will likely be fast enough when loading the 150 or so CPAN dependencies. perl -MCPAN -eshell ... configure it to follow prerequisites o conf prerequisite_policy follow o conf urllist push http://localserver:localport/ o conf commit =head1 DEBIAN NON-PERL PREREQUISITES =head2 ssh sudo C and C are used for later maintenance =head2 apache-perl libapache-mod-perl # apache-dev apache =head1 DEBIAN PERL PREREQUISITES Here are some more prerequisites I load directly from Debian packages instead of relying on the CPAN download later. That way, the overall (re)installation should go faster. =head2 perl perl-modules build-essential Just to be on the safe side. I wonder how you'd run this script without any of these, anyway. =head2 socialtext-keyring st-perl-deps =head2 imagemagick perlmagick ... because ImageMagick is ugly to install manually =head2 postgresql-dev postgresql apache-perl PostgreSQL is the underlying database. A database user C will be created with the password C. =head2 perl-doc libmime-lite-perl libcrypt-ssleay-perl Just to get some nice modules =head2 libxml2-dev libxml2 libxml-libxml-perl libxml-xpath-perl libxml-parser-perl for L, L and L =head2 libtemplate-perl Template Toolkit =head2 libdbi-perl libdbd-pg-perl libalzabo-perl The database drivers, as I'm too lazy to load that stuff into the Perl =head2 libdatetime-perl libtime-piece-perl ... just so the tests go faster =head2 libsoap-lite-perl One of the more hairy modules to install via CPAN/Perl. Unfortunately, the packaged version in Sarge is too old. For Etch, the version should be good enough, maybe. =head2 libclass-accessor-perl =head2 libhtml-parser-perl libhtml-mason-perl =head2 libplucene-perl =head2 libxml-rss-perl =head2 libyaml-perl Unfortunately, this one is too old for OpenText =cut my @cpan_packages = parse_list(<<'=cut'); =head1 UNLISTED PERL DEPENDENCIES =head2 Test::Base Only v0.47 gets required/installed, but we need 0.52. =cut # Add the SocialText repository run("echo 'deb http://open.socialtext.net/apt socialtext-open main'>> /etc/apt/sources.list"); # Update the system to the latest versions of things run("apt-get", 'update'); run("apt-get", 'upgrade'); # Install the system prerequisites: apt_get(@debian_packages); cpan(@cpan_packages); # Install the Perl modules that Socialtext forgot: # Add the user permissions to Postgresql run($^X,'-pi.bak', '-e', 'if (/METHOD\s*$/) {$_ .= " local template1 nlw 127.0.0.1 255.255.255.255 trust\nlocal NLW nlw 127.0.0.1 255.255.255.255 trust\n"}', '/etc/postgresql/7.4/main/pg_hba.conf'); # Restart Postgresql run('/etc/init.d/postgresql-7.4','restart'); # Create the "nlw" user, without any super privileges # Allow it to create new databases, but not new users # Create the "NLW" database, owned by "nlw" # We can't check for failure here ... system("sudo","-u","postgres","createuser", '-A', '-d', "nlw"); system("sudo","-u","postgres","createdb","-O","nlw","NLW"); system("sudo","-u","postgres","createdb","-O","nlw","NLW_nlw_testing"); # These aren't needed, likely, anyway #system("sudo","-u","postgres","createuser", '-a', '-d', "root"); #system("sudo","-u","postgres","createdb","-O","root","NLW"); #system("sudo","-u","postgres","createdb","-O","root","NLW_root_testing"); # Now, download OpenText and install the Perl packages chdir("/home/nlw"); run("wget '$opentext_url'"); run("tar xzvf '$opentext_file.tar.gz'"); chdir($opentext_file) or die "Couldn't change to '$opentext_file': $!"; run("./configure"); run("sudo", "-", "nlw", "make", "test"); run("make install"); sub parse_list { grep { /^\w/ } map { split /\s+/ } grep /^=head2/, split /\s*\n/, $_[0] }; sub apt_get { run($apt_get, 'install', @_); }; sub cpan { run('cpan', @_); }; sub run { print "[run]: @_\n"; system(@_) == 0 or die "[fatal] Couldn't launch '@_': $! / $?"; };