#!/bin/bash # The local directory where to put ushahidi LOCALDIR=/var/www/ushahidi SITEHOST=localhost SITEPATH=ushahidi SITENAME="Max's Ushahidi" SITETAGLINE="a test instance" SITELANG=en_US SITEEMAIL="max@lapin-bleu.net" # The URL of the repo to clone REPOURL=git@github.com:maxf/Ushahidi_Web.git # if this branch is a fork of another repo (e.g. ushahidi's Ushahidi_Web) # then add the url so that "git pull master" merges from the trunk # if not needed, comment out ORIGIN_NAME=ushahidi ORIGIN_URL=git@github.com:ushahidi/Ushahidi_Web.git # Database # comment out if you don't want the db to be reset DELETE_DATABASE=yes DBHOST=localhost DBUSER=root DBPASS=passwd49319 DBNAME=ushahidi # must always end with _ #DBPREFIX=ushahidi_ #################################################################### DBCMD="mysql -u $DBUSER -p$DBPASS -h $DBHOST" #Escape for SQL insertion SITENAME=${SITENAME//\'/\\\'} SITETAGLINE=${SITETAGLINE//\'/\\\'} #SITELANG=${SITELANG//\'/\\\'} SITEMAIL=${SITEMAIL//\'/\\\'} echo Removing old repository rm -rf $LOCALDIR echo Fetching new repository git clone $REPOURL mv Ushahidi_Web $LOCALDIR cd $LOCALDIR if [ -n "$ORIGIN_NAME" -a -n "$ORIGIN_URL" ]; then git remote add $ORIGIN_NAME $ORIGIN_URL fi # File premissions chmod 777 $LOCALDIR/application/cache chmod 777 $LOCALDIR/application/logs chmod 777 $LOCALDIR/.htaccess chmod 777 $LOCALDIR/application/config chmod 777 $LOCALDIR/application/config/config.php chmod 777 $LOCALDIR/media/uploads # delete database if [ -n "$DELETE_DATABASE" ]; then echo "Deleting database $DBNAME" echo "DROP DATABASE IF EXISTS $DBNAME;CREATE DATABASE $DBNAME;" | $DBCMD # now reinject db schema $DBCMD $DBNAME < $LOCALDIR/sql/ushahidi.sql # and update local parameters echo "UPDATE ${DBPREFIX}settings SET site_name='$SITENAME', site_tagline='$SITETAGLINE', site_language='$SITELANG', site_email='$SITEEMAIL';" | $DBCMD $DBNAME fi # update database.php echo "writing custom files" echo "- database.php" sed "s/username/$DBUSER/ s/password/$DBPASS/ s/localhost/$DBHOST/ s/db/$DBNAME/" < application/config/database.template.php > application/config/database.php # update .htaccess echo "- .htaccess" sed "s|RewriteBase /|RewriteBase /$SITEPATH/|" < .htaccess >.htaccess.tmp mv .htaccess.tmp .htaccess echo "All done. You can go to http://$SITEHOST/$SITEPATH to view your installation"