Skip to content

Commit

Permalink
Adding script files
Browse files Browse the repository at this point in the history
  • Loading branch information
tilaks26 committed Jan 25, 2017
1 parent c90ef0e commit e8867f2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
14 changes: 14 additions & 0 deletions appspec.yml
@@ -0,0 +1,14 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/laravel-portal
hooks:
BeforeInstall:
- location: scripts/before-install.sh
timeout: 3600
runas: root
ApplicationStart:
- location: scripts/install.sh
timeout: 3600
runas: root
51 changes: 51 additions & 0 deletions scripts/before-install.sh
@@ -0,0 +1,51 @@
echo 'Update OS'
sudo yum -y update

echo 'Check if PHP is installed'
php --version
if [ "$?" -ne 0 ]; then
sudo yum clean all
sudo yum -y update
sudo yum -y install epel-release
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget https://centos6.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release*.rpm
sudo yum -y update
sudo yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath
fi

echo 'Check if Laravel is installed'
cd /var/www/laravel-develop/
if [ "$?" -ne 0 ]; then
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
wget https://github.com/laravel/laravel/archive/develop.zip
unzip develop.zip
mv laravel-develop /var/www/
sudo rm -rf develop.zip
cd /var/www/laravel-develop/
composer install
fi

echo 'Update Composer'
composer update

echo 'Move back to ec2-user directory'
cd /home/ec2-user

echo 'Check if Docker is installed'
docker -v
if [ "$?" -ne 0 ]; then
sudo yum install -y docker-io
fi

echo 'Starting Docker services'
sudo service docker start

echo 'Remove existing containers if any'
sudo docker ps -a | grep -w "laravel-container" | awk '{print $1}' | xargs --no-run-if-empty docker stop
sudo docker ps -a | grep -w "laravel-container" | awk '{print $1}' | xargs --no-run-if-empty docker rm

echo 'Remove existing images if any'
sudo docker images | grep -w "laravel-image" | awk '{print $3}' | xargs --no-run-if-empty docker rmi -f
5 changes: 5 additions & 0 deletions scripts/install.sh
@@ -0,0 +1,5 @@
echo 'Deploying Laravel Portal'
cd '/home/ec2-user/laravel-portal'

echo 'Run Laravel'
php -S localhost:4000

0 comments on commit e8867f2

Please sign in to comment.