Friday, August 9, 2013

Install script to CollectiveAccess on a debian Wheezy server

I've been looking at using CollectiveAccess, a very nice GPL'ed cataloguing tool and web-based application for museums, archives and digital collections, to use for a local historical society and surname genealogy group. If you know me IRL, I can set you up with a test account on a CA instance.

The installation is pretty straight forward, but I took the time to automate the installation progress to install it on a stock Debian Wheezy 7.1 image running in hpcloud.com (standard.xsmall)

Download it to the server, and then as root: sh ca-install.sh

ca-install.sh


#!/bin/bash
########################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
########################################################################
#
# This script will install Collectiveaccess Providence & Pawtucket
# v1.3 on a stock Debian Wheezy server.
#
# Scan down for CHANGEME and replace it with whatever you want the
# Collectiveaccess (ca) account's mysql password to be.
#
# I tested this using the "209316 – Debian Wheezy 7.1 Server 64-bit
# 20130701 (b)" base image on http://hpcloud.com
#
# -marc nozell
# marc@nozell.com
# 2013-08-08
#
apt-get update
echo "get more packages"
apt-get install apache2 mysql-server php5 php5-imagick libtiff5 libgd-tools php5-ffmpeg libav-tools ghostscript dcraw poppler-utils abiword mediainfo php-getid3 php5-mysql

echo "update php.ini"
perl -pi -e "s/post_max_size = 8M/post_max_size = 32M/" /etc/php5/apache2/php.ini
perl -pi -e "s/upload_max_filesize = 2M/upload_max_filesize = 2M/" /etc/php5/apache2/php.ini
perl -pi -e "s/memory_limit = 128M/memory_limit = 256M/" /etc/php5/apache2/php.ini
perl -pi -e "s/display_errors = Off/display_errors = On/" /etc/php5/apache2/php.ini

echo "restart apache"
service apache2 restart

echo "configure mysql -- enter the mysql root password:"
mysql -p < < EOF
create database ca;
create user 'ca'@'localhost' identified by 'CHANGEME';
grant all on ca.* to 'ca'@'localhost';
EOF

echo "get providence 1.3 kit"
cd /usr/src/
wget -c http://collectiveaccess.org/downloads/collectiveaccess-providence-1.3.tgz

echo "unpack providence"
cd /var/www/
tar zxvf /usr/src/collectiveaccess-providence-1.3.tgz
mv collectiveaccess-providence-1.3 providence

cd providence

echo "edit providence setup.php"
cp setup.php-dist setup.php

perl -pi -e "s/my_database_user/ca/" setup.php
perl -pi -e "s/my_database_password/CHANGEME/" setup.php
perl -pi -e "s/name_of_my_database/ca/" setup.php
perl -pi -e "s/my_database_user/ca/" setup.php

echo "set some providence directory protections"
cd ..
chmod a+w providence/app/tmp
chmod a+w providence
chmod a+w providence/app/lib/core/Parsers/htmlpurifier/standalone/HTMLPurifier/DefinitionCache

echo "get the pawtucket kit"
cd /usr/src/
wget -c http://collectiveaccess.org/downloads/collectiveaccess-pawtucket-1.3.tgz

echo "unpack pawtucket"
cd /var/www/providence
tar zxvf /usr/src/collectiveaccess-pawtucket-1.3.tgz
mv collectiveaccess-pawtucket-1.3 pawtucket

cd pawtucket

echo "edit pawtucket setup.php"
cp setup.php-dist setup.php


perl -pi -e "s/my_database_user/ca/" setup.php
perl -pi -e "s/my_database_password/CHANGEME/" setup.php
perl -pi -e "s/name_of_my_database/ca/" setup.php
perl -pi -e "s/my_database_user/ca/" setup.php

cd /var/www/providence/pawtucket

echo "create media softlink"
ln -s ../media ./

echo "fix pawtucket directory protections"
chmod a+w /var/www/providence/pawtucket/app/tmp /var/www/providence/pawtucket/app/lib/core/Parsers/htmlpurifier/standalone/HTMLPurifier/DefinitionCache
chmod 777 /var/www/providence/pawtucket/app/lib/core/Parsers/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer

echo "Now go open http://THIS-SERVER/providence/install and complete the setup"