Open Atrium

by aaronlevy
150 deployments · 19 still active · last rev. 9 years ago

Installs Open Atrium, an intranet in a box that has group spaces to allow different teams to have their own conversations. It comes with six features - a blog, a wiki, a calendar, a to do list, a shoutbox, and a dashboard to manage it all.

After StackScript finishes, navigate to to complete the installation.

Compatible with: No distros currently supported
# <UDF name="db_password" Label="MySQL root Password" />
# <UDF name="db_name" Label="Create Database" default="drupal" example="Drupal database name" />
# <UDF name="db_user" Label="Create MySQL User" default="drupal" example="Drupal database user" />
# <UDF name="db_user_password" Label="MySQL User's Password" default="" example="Optionally Drupal database user's password" />

source <ssinclude StackScriptID="1">

# a few more tools we need
function moregoodstuff {

    aptitude -y install php5-cli php5-gd cvs git-core unzip

# install drush and drush make
function drush_install {
  echo "Installing drush"
  cd /tmp && cvs -z6 checkout -d drush contributions/modules/drush
  if [ ! -f /tmp/drush/drush ]; then
    echo "Could not checkout drush from cvs"
    exit 1                           

  cd /usr/local && /tmp/drush/drush dl drush
  # drush changed dl behavior of itself.  Sometimes it dl's to cwd, other times to ~/.drush/drush
  if [ -d ~/.drush/drush ]; then
    mv ~/.drush/drush .
  cd bin && ln -s ../drush/drush drush
  if [ ! -x /usr/local/bin/drush ]; then
    echo "Could not install drush in /usr/local/bin"
    exit 1                   
  echo "Installing Drush Make"
  cd ~
  drush dl drush_make

  cd && rm -rf /tmp/drush
  echo "Done installing drush"

# openatrium stub file for drush make
function make_stub {

cd /tmp
cat > atrium_stub.make <<the_stub
core = "6.x"
projects[] = "drupal"
projects[openatrium][type] = "profile"
projects[openatrium][download][type] = "cvs"
projects[openatrium][download][module] = "contributions/profiles/openatrium"
projects[openatrium][download][revision] = "HEAD"

function openatrium_install {
    VPATH=$(apache_virtualhost_get_docroot $1)
    if [ ! -n "$VPATH" ]; then
        echo "Could not determine DocumentRoot for $1"
        return 1;                                    
    # remove public_html because it will be recreated during drush_make
    cd $VPATH && cd .. && rm -r public_html
    # make openatrium
    if [ ! -f /tmp/atrium_stub.make ]; then
        echo "Could not create make stub"
        exit 1
    /usr/local/bin/drush make /tmp/atrium_stub.make $VPATH

    # database configuration
    if [ ! -n "$DB_USER_PASSWORD" ]; then
        DB_USER_PASSWORD=$(randomString 20)
    mysql_create_database "$DB_PASSWORD" "$DB_NAME"
    mysql_create_user "$DB_PASSWORD" "$DB_USER" "$DB_USER_PASSWORD"
    mysql_grant_user "$DB_PASSWORD" "$DB_USER" "$DB_NAME"

    # settings.php
    cd $VPATH
    cp sites/default/default.settings.php sites/default/settings.php
    chown -R www-data: .
    chmod 600 sites/default/settings.php 
    sed -i "/^$db_url/s/mysql\:\/\/username:password/mysql\:\/\/$DB_USER:$DB_USER_PASSWORD/" sites/default/settings.php
    sed -i "/^$db_url/s/databasename/$DB_NAME/" sites/default/settings.php

    # increase php memory limit to 96MB
    sed -i 's/memory_limit = .*/memory_limit = 96M/' /etc/php5/apache2/php.ini

    # setup crontab and clean-urls
    echo "0 * * * * /usr/local/bin/drush -r $VPATH cron >/dev/null" | crontab - 
    a2enmod rewrite        
    touch /tmp/restart-apache2

mysql_install "$DB_PASSWORD" && mysql_tune 40
php_install_with_apache && php_tune
apache_install && apache_tune 40 && apache_virtualhost_from_rdns
openatrium_install $(get_rdns_primary_ip)