Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install php as part of the setup.sh script #6

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions setup

This file was deleted.

48 changes: 37 additions & 11 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
#!/bin/bash

echo "Attempting to install ansible, java and docker"
echo "Attempting to install ansible, java, docker, php and composer"

#Check if using apt-get
if [ -n "$(command -v apt-get)" ];
#This function comes from https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
install_composer() {
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"

if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
RESULT=$?
rm composer-setup.php
if [ $RESULT -ne 0 ];
then
echo "Failed to install composer. Return code: $RESULT"
exit 1
else
echo "Composer installed successfully"
fi
}

#Check if using apt
if [ -n "$(command -v apt)" ];
then
sudo apt-get -y -qq install ansible
sudo apt-get -y -qq install docker-ce
sudo apt -y -qq install ansible php php-xml php-mbstring zip unzip
sudo apt -y -qq install docker-ce
if [ $? -ne 0 ];
then
echo "Please set up the repository for docker-ce. See https://docs.docker.com/engine/installation/linux/docker-ce/$(. /etc/os-release; echo "$ID")/"
Expand All @@ -18,7 +43,10 @@ fi
if [ -n "$(command -v yum)" ];
then
sudo yum -y -q install epel-release
sudo yum -y -q install ansible docker composer
sudo yum -y -q install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager -y -q --enable remi-php73
sudo yum -y -q clean all
sudo yum -y -q install ansible docker composer php php-xml php-mbstring zip unzip
fi

# Add user to docker group so that they can run docker commands
Expand All @@ -43,17 +71,15 @@ fi
# Check if composer is installed. If it isn't, direct user to instructions
if [ -z "$(command -v composer)" ];
then
echo "Please download and install composer. See https://getcomposer.org/download/"
exit 1
install_composer
fi

sudo systemctl enable docker
sudo systemctl restart docker

cd tests
composer require phpunit/phpunit
composer require guzzlehttp/guzzle
composer update
composer -q install
composer -q update
cd ..

echo "Setup complete."