Tidy up directory structure

This commit is contained in:
Ric Harvey
2016-01-18 22:08:03 +00:00
parent fab810f3f6
commit 5a4ecbcf35
7 changed files with 6 additions and 6 deletions

14
scripts/pull Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
if [ -z "$GIT_EMAIL" ]; then
echo "You need to pass the \$GIT_EMAIL variable to the container for this to work"
exit
fi
if [ -z "$GIT_NAME" ]; then
echo "You need to pass the \$GIT_NAME variable to the container for this to work"
exit
fi
cd /usr/share/nginx/html
git pull

21
scripts/push Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
timestamp() {
date +"%D %T"
}
if [ -z "$GIT_EMAIL" ]; then
echo "You need to pass the \$GIT_EMAIL variable to the container for this to work"
exit
fi
if [ -z "$GIT_NAME" ]; then
echo "You need to pass the \$GIT_NAME variable to the container for this to work"
exit
fi
ts=$(timestamp)
cd /usr/share/nginx/html
git add *
git commit -a -m "push from container $ts"
git push

56
scripts/start.sh Normal file
View File

@@ -0,0 +1,56 @@
#!/bin/bash
# Disable Strict Host checking for non interactive git clones
mkdir -p -m 0700 /root/.ssh
echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
# Setup git variables
if [ ! -z "$GIT_EMAIL" ]; then
git config --global user.email "$GIT_EMAIL"
fi
if [ ! -z "$GIT_NAME" ]; then
git config --global user.name "$GIT_NAME"
git config --global push.default simple
fi
# Pull down code form git for our site!
if [ ! -z "$GIT_REPO" ]; then
rm /usr/share/nginx/html/*
if [ ! -z "$GIT_BRANCH" ]; then
git clone -b $GIT_BRANCH $GIT_REPO /usr/share/nginx/html/
else
git clone $GIT_REPO /usr/share/nginx/html/
fi
chown -Rf nginx.nginx /usr/share/nginx/*
fi
# Display PHP error's or not
if [[ "$ERRORS" != "1" ]] ; then
sed -i -e "s/error_reporting =.*=/error_reporting = E_ALL/g" /etc/php5/fpm/php.ini
sed -i -e "s/display_errors =.*/display_errors = On/g" /etc/php5/fpm/php.ini
fi
# Tweak nginx to match the workers to cpu's
procs=$(cat /proc/cpuinfo |grep processor | wc -l)
sed -i -e "s/worker_processes 5/worker_processes $procs/" /etc/nginx/nginx.conf
# Very dirty hack to replace variables in code with ENVIRONMENT values
if [[ "$TEMPLATE_NGINX_HTML" != "0" ]] ; then
for i in $(env)
do
variable=$(echo "$i" | cut -d'=' -f1)
value=$(echo "$i" | cut -d'=' -f2)
if [[ "$variable" != '%s' ]] ; then
replace='\$\$_'${variable}'_\$\$'
find /usr/share/nginx/html -type f -exec sed -i -e 's/'${replace}'/'${value}'/g' {} \;
fi
done
fi
# Again set the right permissions (needed when mounting from a volume)
chown -Rf www-data.www-data /usr/share/nginx/html/
# Start supervisord and services
/usr/bin/supervisord -n -c /etc/supervisord.conf