vagrant/script.sh
#! /usr/bin/env bash # VariablesAPPENV=localDBHOST=localhostDBNAME=eisenDBUSER=rootDBPASSWD=password echo -e "\n--- Mkay, installing now... ---\n" echo -e "\n--- Updating packages list ---\n"apt-get -qq update echo -e "\n--- Install base packages ---\n"apt-get -y install vim curl build-essential python-software-properties git > /dev/null 2>&1 echo -e "\n--- Add some repos to update our distro ---\n"add-apt-repository ppa:ondrej/php5-5.6 > /dev/null 2>&1add-apt-repository ppa:chris-lea/node.js > /dev/null 2>&1 echo -e "\n--- Updating packages list ---\n"apt-get -qq update echo -e "\n--- Install MySQL specific packages and settings ---\n"echo "mysql-server mysql-server/root_password password $DBPASSWD" | debconf-set-selectionsecho "mysql-server mysql-server/root_password_again password $DBPASSWD" | debconf-set-selectionsecho "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selectionsecho "phpmyadmin phpmyadmin/app-password-confirm password $DBPASSWD" | debconf-set-selectionsecho "phpmyadmin phpmyadmin/mysql/admin-pass password $DBPASSWD" | debconf-set-selectionsecho "phpmyadmin phpmyadmin/mysql/app-pass password $DBPASSWD" | debconf-set-selectionsecho "phpmyadmin phpmyadmin/reconfigure-webserver multiselect none" | debconf-set-selectionsapt-get -y install mysql-server-5.5 phpmyadmin > /dev/null 2>&1 echo -e "\n--- Setting up our MySQL user and db ---\n"mysql -uroot -p$DBPASSWD -e "CREATE DATABASE $DBNAME"mysql -uroot -p$DBPASSWD -e "grant all privileges on *.* to '$DBUSER'@'%' identified by '$DBPASSWD' WITH GRANT OPTION; FLUSH PRIVILEGES;"cp -f /vagrant/vagrant/my.cnf /etc/mysql/my.cnf echo -e "\n--- Installing PHP-specific packages ---\n"apt-get -y install php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-mysql php-apc > /dev/null 2>&1 echo -e "\n--- Enabling mod-rewrite ---\n"a2enmod rewrite > /dev/null 2>&1 echo -e "\n--- Allowing Apache override to all ---\n"sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf echo -e "\n--- Setting document root to public directory ---\n"rm -rf /var/wwwln -fs /vagrant/webd /var/www echo -e "\n--- We definitly need to see the PHP errors, turning them on ---\n"sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.inised -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini echo -e "\n--- Turn off disabled pcntl functions so we can use Boris ---\n"sed -i "s/disable_functions = .*//" /etc/php5/cli/php.ini echo -e "\n--- Configure Apache to use phpmyadmin ---\n"echo -e "\n\nListen 81\n" >> /etc/apache2/ports.confcat > /etc/apache2/conf-available/phpmyadmin.conf << "EOF"<VirtualHost *:81> ServerAdmin webmaster@localhost DocumentRoot /usr/share/phpmyadmin DirectoryIndex index.php ErrorLog ${APACHE_LOG_DIR}/phpmyadmin-error.log CustomLog ${APACHE_LOG_DIR}/phpmyadmin-access.log combined</VirtualHost>EOFa2enconf phpmyadmin > /dev/null 2>&1 echo -e "\n--- Add environment variables to Apache ---\n"cat > /etc/apache2/sites-enabled/000-default.conf <<EOF<VirtualHost *:80> DocumentRoot /var/www ErrorLog \${APACHE_LOG_DIR}/error.log CustomLog \${APACHE_LOG_DIR}/access.log combined SetEnv APP_ENV $APPENV SetEnv DB_HOST $DBHOST SetEnv DB_NAME $DBNAME SetEnv DB_USER $DBUSER SetEnv DB_PASS $DBPASSWD</VirtualHost>EOF echo -e "\n--- generate japanese locale ---\n"locale-gen ja_JP.UTF-8 echo -e "\n--- Restarting Apache ---\n"service apache2 restart > /dev/null 2>&1 echo -e "\n--- Restarting Mysql ---\n"service mysql restart > /dev/null 2>&1 echo -e "\n--- Installing Composer for PHP package management ---\n"curl --silent https://getcomposer.org/installer | php > /dev/null 2>&1mv composer.phar /usr/local/bin/composer echo -e "\n--- Installing NodeJS and NPM ---\n"apt-get -y install nodejs > /dev/null 2>&1curl --silent https://npmjs.org/install.sh | sh > /dev/null 2>&1 echo -e "\n--- Installing javascript components ---\n"npm install -g gulp bower typescript dtsm > /dev/null 2>&1 echo -e "\n--- Updating project components and pulling latest versions ---\n"cd /vagrantsudo -u vagrant -H sh -c "composer install" > /dev/null 2>&1sudo -u vagrant -H sh -c "npm install" > /dev/null 2>&1sudo -u vagrant -H sh -c "bower install -s" > /dev/null 2>&1sudo -u vagrant -H sh -c "gulp" > /dev/null 2>&1sudo -u vagrant -H sh -c "tsc webd/ts/script.ts" > /dev/null 2>&1 echo -e "\n--- Updating css ---\n"gem install compasscd /vagrant/webdcompass compile echo -e "\n--- Creating a symlink for future phpunit use ---\n"ln -fs /vagrant/vendor/bin/phpunit /usr/local/bin/phpunit echo -e "\n--- Add environment variables local ---\n"cat >> /home/vagrant/.bashrc <<EOF# Set envvarsexport APP_ENV=$APPENVexport DB_HOST=$DBHOSTexport DB_NAME=$DBNAMEexport DB_USER=$DBUSERexport DB_PASS=$DBPASSWD EOF