bootstrap_vagrant 2.17 KB
Newer Older
chris's avatar
chris committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#! /usr/bin/env bash

# Variables
DBHOST=localhost
DBNAME=domainepublic
DBUSER=user
DBPASSWD=password

apt-get -qq update
apt-get -y install vim

echo "--- Install MySQL specific packages and settings ---"
debconf-set-selections <<< "mysql-server mysql-server/root_password password $DBPASSWD"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DBPASSWD"
#debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true"
#debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password $DBPASSWD"
#debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password $DBPASSWD"
#debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $DBPASSWD"
#debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect none"
apt-get -y install mysql-server #phpmyadmin

echo "--- Setup our MySQL user and db ---"
mysql -uroot -p$DBPASSWD -e "CREATE DATABASE $DBNAME"
mysql -uroot -p$DBPASSWD -e "grant all privileges on $DBNAME.* to '$DBUSER'@'localhost' identified by '$DBPASSWD'"

echo "--- Install PHP packages ---"
apt-get -y install apache2 php5 libapache2-mod-php5

echo "--- Install spip dependencies ---"
apt-get -y install php5-mysql php5-imagick php5-gd netpbm

echo "--- Enable mod-rewrite ---"
a2enmod rewrite

echo "--- Allow Apache override to all ---"
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf

echo "--- Set document root to public directory ---"
rm -rf /var/www/html
ln -fs /vagrant /var/www/html

echo "--- Display PHP errors ---"
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini

echo "--- Create Spip connect.php and folders---"
[ -f /vagrant/config/connect.php ] || cp /vagrant/config/connect-example.php /vagrant/config/connect.php
[ -d /vagrant/tmp/cache/xml ] || mkdir -p /vagrant/tmp/cache/xml/

echo "--- Import Spip database ---"
[ -f /vagrant/domainepublic.sql ] || scp ginger.domainepublic.net:/srv/domainepublic.sql /vagrant/
mysql -uroot -p$DBPASSWD $DBNAME < /vagrant/domainepublic.sql

echo "--- Restart Apache ---"
service apache2 restart