2014-12-11 11:57:44 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2015-11-18 15:24:58 +01:00
|
|
|
VARGANTDEV=1
|
2015-06-15 16:11:26 +02:00
|
|
|
DIR=/vagrant
|
|
|
|
DIRDATA=$DIR/data
|
|
|
|
MYSQL_PASS=scores
|
2015-12-14 12:19:15 +01:00
|
|
|
MARIADB_VERSION="10.0"
|
|
|
|
PHPMYADMIN_VERSION="4.5.2"
|
2015-06-15 16:11:26 +02:00
|
|
|
|
2015-08-04 17:39:19 +02:00
|
|
|
# --- Add a file action.upgrade to perfom a system upgrade
|
2015-06-15 16:11:26 +02:00
|
|
|
if [ -f $DIR/action.upgrade ]
|
2015-02-06 10:10:04 +01:00
|
|
|
then
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get -y upgrade
|
2015-08-04 17:39:19 +02:00
|
|
|
sudo rm -rf $DIR/action.upgrade
|
2015-02-06 10:10:04 +01:00
|
|
|
fi
|
2014-12-12 13:43:26 +01:00
|
|
|
|
2015-01-15 15:55:08 +01:00
|
|
|
# --- Installation Wkhtmltopdf
|
2014-12-16 15:30:39 +01:00
|
|
|
if [ ! -f /usr/local/bin/wkhtmltopdf ]
|
|
|
|
then
|
2015-06-15 16:11:26 +02:00
|
|
|
sudo dpkg -i $DIRDATA/Apps/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
|
2014-12-16 15:30:39 +01:00
|
|
|
sudo apt-get -f install -y
|
|
|
|
fi
|
|
|
|
|
2015-06-15 16:11:26 +02:00
|
|
|
# --- Database
|
|
|
|
if [ $VARGANTDEV -eq 1 ]
|
|
|
|
then
|
|
|
|
# --- Installation MariaDB
|
|
|
|
if [ ! -f /etc/mysql/vagrant ]
|
|
|
|
then
|
|
|
|
sudo apt-get install software-properties-common
|
|
|
|
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
|
|
|
|
sudo add-apt-repository 'deb http://nwps.ws/pub/mariadb/repo/10.0/ubuntu trusty main'
|
|
|
|
sudo apt-get update
|
|
|
|
sudo debconf-set-selections <<< "mariadb-server-$MARIADB_VERSION mysql-server/root_password password $MYSQL_PASS"
|
|
|
|
sudo debconf-set-selections <<< "mariadb-server-$MARIADB_VERSION mysql-server/root_password_again password $MYSQL_PASS"
|
2015-12-15 10:55:10 +01:00
|
|
|
sudo apt-get -y --allow-unauthenticated install mariadb-server mariadb-client
|
2015-06-15 16:11:26 +02:00
|
|
|
sudo sed -i -e 's/bind-address[ \t]*= 127.0.0.1/bind-address = 0.0.0.0/g' /etc/mysql/my.cnf
|
|
|
|
sudo sed -i -e 's/max_connections[ \t]*= 100/max_connections = 20/g' /etc/mysql/my.cnf
|
|
|
|
sudo touch /etc/mysql/vagrant
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# --- Installation MySQL Server
|
|
|
|
if [ ! -f /etc/mysql/vagrant ]
|
|
|
|
then
|
|
|
|
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $MYSQL_PASS"
|
|
|
|
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $MYSQL_PASS"
|
|
|
|
sudo apt-get -y install mysql-server
|
|
|
|
sudo sed -i -e 's/bind-address[ \t]*= 127.0.0.1/bind-address = 0.0.0.0/g' /etc/mysql/my.cnf
|
|
|
|
sudo sed -i -e 's/max_connections[ \t]*= 100/max_connections = 20/g' /etc/mysql/my.cnf
|
|
|
|
sudo touch /etc/mysql/vagrant
|
|
|
|
fi
|
2014-12-12 13:43:26 +01:00
|
|
|
fi
|
|
|
|
|
2015-06-15 16:11:26 +02:00
|
|
|
# --- PHP
|
|
|
|
if [ ! -f /usr/bin/php5 ]
|
2015-05-26 09:29:10 +02:00
|
|
|
then
|
|
|
|
|
2015-06-15 16:11:26 +02:00
|
|
|
sudo apt-get update
|
2015-12-15 10:55:10 +01:00
|
|
|
sudo apt-get -y install htop unzip apache2 php5 php5-apcu php5-curl php5-xmlrpc php5-xsl php5-mysqlnd
|
2015-06-15 16:11:26 +02:00
|
|
|
if [ $VARGANTDEV -eq 1 ]
|
|
|
|
then
|
|
|
|
sudo apt-get -y install php5-xdebug
|
|
|
|
fi
|
|
|
|
|
|
|
|
# --- Configuration PHP / CLI
|
|
|
|
if [ -f /etc/php5/cli/php.ini ]
|
|
|
|
then
|
|
|
|
sudo sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/cli/php.ini
|
2015-08-04 17:39:19 +02:00
|
|
|
sudo sed -i -e 's/;mbstring.internal_encoding = UTF-8/mbstring.internal_encoding = UTF-8/g' /etc/php5/cli/php.ini
|
2015-06-15 16:11:26 +02:00
|
|
|
sudo sed -i -e 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php5/cli/php.ini
|
|
|
|
fi
|
2015-05-26 09:29:10 +02:00
|
|
|
|
2015-06-15 16:11:26 +02:00
|
|
|
# --- Configuration PHP / APACHE2
|
|
|
|
if [ -f /etc/php5/apache2/php.ini ]
|
|
|
|
then
|
|
|
|
sudo sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/apache2/php.ini
|
2015-08-04 17:39:19 +02:00
|
|
|
sudo sed -i -e 's/;mbstring.internal_encoding = UTF-8/mbstring.internal_encoding = UTF-8/g' /etc/php5/apache2/php.ini
|
2015-06-15 16:11:26 +02:00
|
|
|
sudo sed -i -e 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php5/apache2/php.ini
|
|
|
|
sudo sed -i -e 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php5/apache2/php.ini
|
|
|
|
sudo sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php5/apache2/php.ini
|
|
|
|
sudo sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php5/apache2/php.ini
|
|
|
|
sudo sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php5/apache2/php.ini
|
|
|
|
sudo cp $DIRDATA/PHP/xdebug.ini /etc/php5/mods-available/xdebug.ini
|
|
|
|
|
|
|
|
# --- Browscap
|
|
|
|
sudo cp -f $DIRDATA/PHP/php_browscap.ini /etc/php5/apache2/
|
|
|
|
sudo sed -i -e 's/;browscap = extra\/browscap.ini/browscap = \/etc\/php5\/apache2\/php_browscap.ini/g' /etc/php5/apache2/php.ini
|
|
|
|
fi
|
|
|
|
|
|
|
|
# --- ChartDirector
|
|
|
|
if [ ! -f /usr/lib/php5/20121212/chartdir.lic ]
|
|
|
|
then
|
|
|
|
sudo cp -R $DIRDATA/ChartDirector/lib/fonts /usr/lib/php5/20121212/
|
|
|
|
sudo cp $DIRDATA/ChartDirector/lib/libchartdir.so /usr/lib/php5/20121212/
|
|
|
|
sudo cp $DIRDATA/ChartDirector/lib/phpchartdir550.dll /usr/lib/php5/20121212/
|
|
|
|
sudo cp $DIRDATA/ChartDirector/chartdir.lic /usr/lib/php5/20121212/
|
|
|
|
sudo cp $DIRDATA/ChartDirector/chartdir.ini /etc/php5/mods-available/
|
|
|
|
sudo php5enmod chartdir
|
|
|
|
fi
|
|
|
|
|
|
|
|
sudo a2enmod autoindex deflate expires headers rewrite
|
2015-05-26 09:29:10 +02:00
|
|
|
|
2014-12-19 22:18:20 +01:00
|
|
|
fi
|
|
|
|
|
2015-12-15 10:55:10 +01:00
|
|
|
# --- Composer
|
|
|
|
if [ ! -f /bin/composer ]
|
|
|
|
then
|
|
|
|
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=bin --filename=composer
|
|
|
|
fi
|
|
|
|
|
2015-01-15 15:55:08 +01:00
|
|
|
# --- Installation phpMyAdmin
|
2015-12-15 10:55:10 +01:00
|
|
|
PHPMYADMIN_DIR="phpMyAdmin-$PHPMYADMIN_VERSION-all-languages"
|
2015-12-14 11:10:03 +01:00
|
|
|
PHPMYADMIN_URL="https://files.phpmyadmin.net/phpMyAdmin"
|
2015-12-15 10:55:10 +01:00
|
|
|
if [ ! -d "/home/vhosts/$PHPMYADMIN_DIR" ]
|
2014-12-12 13:43:26 +01:00
|
|
|
then
|
2015-12-15 10:55:10 +01:00
|
|
|
wget -q "$PHPMYADMIN_URL/$PHPMYADMIN_VERSION/$PHPMYADMIN_DIR.tar.xz" -O "/home/vagrant/$PHPMYADMIN_DIR.tar.xz"
|
|
|
|
if [ -f "/home/vagrant/$PHPMYADMIN_DIR.tar.xz" ]
|
2014-12-12 16:31:18 +01:00
|
|
|
then
|
2015-12-15 10:55:10 +01:00
|
|
|
tar xJvf "/home/vagrant/$PHPMYADMIN_DIR.tar.xz" --directory /home/vhosts/
|
2015-06-15 16:11:26 +02:00
|
|
|
mysql -hlocalhost -uroot -p$MYSQL_PASS < $DIRDATA/Apps/phpmyadmin.sql
|
2015-12-15 10:55:10 +01:00
|
|
|
mysql -hlocalhost -uroot -p$MYSQL_PASS < /home/vhosts/$PHPMYADMIN_DIR/sql/create_tables.sql
|
2014-12-22 14:05:06 +01:00
|
|
|
sudo service mysql restart
|
2015-12-15 10:55:10 +01:00
|
|
|
cp $DIRDATA/Apps/config.inc.php /home/vhosts/$PHPMYADMIN_DIR/
|
|
|
|
chmod 0444 /home/vhosts/$PHPMYADMIN_DIR/config.inc.php
|
2014-12-12 16:31:18 +01:00
|
|
|
fi
|
2014-12-12 13:43:26 +01:00
|
|
|
fi
|
2014-12-11 11:57:44 +01:00
|
|
|
|
2015-01-15 15:55:08 +01:00
|
|
|
# --- Configuration Apache
|
2014-12-16 15:30:39 +01:00
|
|
|
if [ ! -f /etc/apache2/conf-available/httpd.conf ]
|
|
|
|
then
|
2015-08-04 17:39:19 +02:00
|
|
|
sudo echo "ServerName 127.0.0.1" > /etc/apache2/conf-available/httpd.conf
|
2015-12-15 10:55:10 +01:00
|
|
|
sudo a2enconf httpd
|
2014-12-16 15:30:39 +01:00
|
|
|
fi
|
|
|
|
|
2015-01-15 15:55:08 +01:00
|
|
|
# --- Disable all website
|
2014-12-11 11:57:44 +01:00
|
|
|
cd /etc/apache2/sites-available/
|
2015-11-18 15:24:58 +01:00
|
|
|
for f in *.conf; do
|
|
|
|
if [ $f = "000-default.conf" ]; then
|
2015-12-15 10:55:10 +01:00
|
|
|
continue
|
2015-11-18 15:24:58 +01:00
|
|
|
fi
|
|
|
|
if [ $f = "default-ssl.conf" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
sudo a2dissite $f;
|
|
|
|
sudo rm -vf /etc/apache2/sites-available/$f;
|
|
|
|
done;
|
|
|
|
|
2015-12-15 10:55:10 +01:00
|
|
|
# --- phpmyadmin.sd.dev
|
2015-12-15 11:17:40 +01:00
|
|
|
cp -f $DIRDATA/Apache/phpmyadmin.conf $DIR/vhosts/phpmyadmin.conf
|
|
|
|
sed -i -e "s/VERSION/$PHPMYADMIN_VERSION/" $DIR/vhosts/phpmyadmin.conf
|
2015-12-15 10:55:10 +01:00
|
|
|
|
|
|
|
# --- test.sd.dev
|
2015-11-18 15:24:58 +01:00
|
|
|
cp -f $DIRDATA/Apache/test.conf /etc/apache2/sites-available/test.conf
|
|
|
|
if [ ! -d /home/vhosts/test ]
|
|
|
|
then
|
|
|
|
sudo mkdir /home/vhosts/test
|
|
|
|
fi
|
2014-12-11 11:57:44 +01:00
|
|
|
|
2015-01-15 15:55:08 +01:00
|
|
|
# --- Copy Vhosts files
|
2014-12-16 15:30:39 +01:00
|
|
|
VHOSTS='000-default.conf'
|
2015-06-15 16:11:26 +02:00
|
|
|
cd $DIR/vhosts/
|
2015-08-05 09:34:18 +02:00
|
|
|
for f in *.conf; do
|
|
|
|
if [ $f = "000-default.conf" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if [ $f = "default-ssl.conf" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2014-12-16 15:30:39 +01:00
|
|
|
if [ -f $f ]
|
|
|
|
then
|
2015-08-05 09:34:18 +02:00
|
|
|
sudo cp -vf $f /etc/apache2/sites-available/;
|
2014-12-16 15:30:39 +01:00
|
|
|
VHOSTS+=" $f"
|
2014-12-19 22:18:20 +01:00
|
|
|
fi
|
2014-12-11 11:57:44 +01:00
|
|
|
done;
|
2015-08-05 09:34:18 +02:00
|
|
|
|
2014-12-16 15:30:39 +01:00
|
|
|
sudo a2ensite $VHOSTS
|
2014-12-11 11:57:44 +01:00
|
|
|
|
2015-01-15 15:55:08 +01:00
|
|
|
# --- Restart apache
|
2014-12-16 15:30:39 +01:00
|
|
|
sudo service apache2 restart
|
2015-06-15 17:22:51 +02:00
|
|
|
|