#!/bin/bash ######################################################################## #SPOD INSTALLATION SCRIPT############################################### #FIRST VERSION 29/09/2015############################################### ######################################################################## ################OXWALL CONFIGURATION DATA############################### CONFIG0=" > /var/www/ow_includes/config.php service apache2 restart wget -q -O /dev/null http://localhost/ rm -f /var/www/ow_includes/config.php echo $CONFIG0$HOSTNAMESPOD$CONFIG1$CONFIG3 >> /var/www/ow_includes/config.php CRONCHECK=$(crontab -l); if [[ $CRONCHECK == *"http://localhost/ow_cron/run.php"* ]]; then echo "Cron job already exists"; else crontab -l | { cat; echo "* * * * * wget -q -O /dev/null http://localhost/ow_cron/run.php"; } | crontab - fi ;; "uninstall") if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] ; then echo "You must specify the mysql password and username to unistall SPOD." echo " sudo ./spod-manager.sh -a uninstall -m user -n password" exit -2 fi mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "drop database oxwall;" rm -rf /var/www/* rm -rf /var/www/.[^.]* crontab -l | sed '/http:\/\/localhost\/ow_cron\/run\.php/d' | crontab - ;; "backup") if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] ; then echo "You must specify the mysql password and username to unistall SPOD." exit -2 fi service apache2 stop DATEDIR=$(date +%Y-%m-%d-%N) IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') mkdir -p $BACKUPDIR/$DATEDIR mysqldump -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST oxwall | gzip > $BACKUPDIR/$DATEDIR/db_backup_spod.sql.gz mkdir $BACKUPDIR/$DATEDIR/var cp -r /var/www $BACKUPDIR/$DATEDIR/var service apache2 start ;; "restoredb") if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] || [ -z "$DB" ]; then echo "You must specify the mysql password and username, db dump path to restore SPOD." exit -2 fi service apache2 stop mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "drop database oxwall;" mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "create database if not exists oxwall;" mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST --database=oxwall < $DB service apache2 start ;; "restoreall") if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] || [ -z "$SPODWWW" ]; then echo "You must specify the mysql password and username, SPOD backup dir and DB dump path to restore SPOD." exit -2 fi service apache2 stop mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "drop database oxwall;" mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "create database if not exists oxwall;" mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST --database=oxwall < $DB rm -rf /var/www/* rm -rf /var/www/.[^.]* cp -r $SPODWWW /var/www cd /var/www git init git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-core.git cd /var/www/ow_plugins git init git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-plugins.git cd /var/www/ow_themes git init git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-themes.git service apache2 start ;; "update") if [ -z "$GITUSER" ] || [ -z "$GITEMAIL" ] || [ -z "$GITPASSWORD" ] || [ -z "$HOSTNAMESPOD" ]; then echo "You must specify the SPOD git credentials." exit -2 fi git config --global user.name "$GITUSER" git config --global user.email "$GITEMAIL" if [ -x /var/www/.git ] && [ -x /var/www/ow_plugins ] && [ -x /var/www/ow_themes ]; then cd /var/www git pull origin master cd /var/www/ow_plugins git pull origin master cd /var/www/ow_themes git pull origin master service apache2 restart wget -q -O /dev/null http://localhost/ow_cron/run.php rm -f /var/www/ow_includes/config.php echo $CONFIG0$HOSTNAMESPOD$CONFIG1$CONFIG2 >> /var/www/ow_includes/config.php service apache2 restart wget -q -O /dev/null http://localhost/ rm -f /var/www/ow_includes/config.php echo $CONFIG0$HOSTNAMESPOD$CONFIG1$CONFIG3 >> /var/www/ow_includes/config.php service apache2 restart else echo "Your SPOD installation is corrupt, please uninstall and istall it again. Your database will be erased." exit -2 fi ;; *) echo "No valid action found."; exit -1; ;; esac ############################################################################################## ############################################################################################## ############################################################################################## ############################################################################################## ############################################################################################## ############################################################################################## ##############################################################################################