github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/builtin/app/php/data/aws-simple/build/build-php.sh.tpl (about) 1 #!/bin/bash 2 3 set -o nounset -o errexit -o pipefail -o errtrace 4 5 error() { 6 local sourcefile=$1 7 local lineno=$2 8 echo "ERROR at ${sourcefile}:${lineno}; Last logs:" 9 grep otto /var/log/syslog | tail -n 20 10 } 11 trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR 12 13 oe() { "$@" 2>&1 | logger -t otto > /dev/null; } 14 ol() { echo "[otto] $@"; } 15 16 # cloud-config can interfere with apt commands if it's still in progress 17 ol "Waiting for cloud-config to complete..." 18 until [[ -f /var/lib/cloud/instance/boot-finished ]]; do 19 sleep 0.5 20 done 21 22 ol "Adding apt repositories and updating..." 23 export DEBIAN_FRONTEND=noninteractive 24 oe sudo apt-get update -y 25 oe sudo apt-get install -y software-properties-common 26 oe sudo add-apt-repository -y ppa:ondrej/php5-{{ php_version }} 27 # Seems to be required to prevent "unauthenticated packages" 28 # errors out of apt-get install. 29 oe sudo apt-key update 30 oe sudo apt-get update -y 31 32 ol "Installing PHP VCSs, Apache, and other packages..." 33 oe sudo apt-get install -y apache2 php5 libapache2-mod-php5 \ 34 bzr git mercurial build-essential \ 35 curl \ 36 php5-mcrypt php5-mysql php5-fpm php5-gd php5-readline php5-pgsql 37 38 ol "Extracting app..." 39 sudo mkdir -p /srv/otto-app 40 sudo tar zxf /tmp/otto-app.tgz -C /srv/otto-app 41 42 ol "Setting permissions..." 43 oe sudo chown -R www-data: /srv/otto-app 44 45 if [ -f /srv/otto-app/composer.json ]; then 46 ol "Installing Composer..." 47 cd /tmp 48 curl -sS https://getcomposer.org/installer | php 49 oe sudo mv composer.phar /usr/local/bin/composer 50 51 ol "Running composer install..." 52 oe sudo -u www-data /usr/local/bin/composer install --working-dir /srv/otto-app --no-dev --no-interaction 53 fi 54 55 56 ol "Configuring apache..." 57 oe sudo rm /etc/apache2/sites-enabled/000-default.conf 58 59 cat <<APACHECONF | sudo tee /etc/apache2/sites-enabled/otto-app.conf > /dev/null 60 # Generated by Otto 61 <VirtualHost *:80> 62 DocumentRoot /srv/otto-app 63 64 <Directory /srv/otto-app/> 65 Require all granted 66 </Directory> 67 </VirtualHost> 68 APACHECONF 69 70 71 ol "...done!"