-
Notifications
You must be signed in to change notification settings - Fork 6
/
start.sh
executable file
·85 lines (71 loc) · 2.38 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/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
if [ ! -z "$SSH_KEY" ]; then
echo $SSH_KEY > /root/.ssh/id_rsa.base64
base64 -d /root/.ssh/id_rsa.base64 > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
fi
# Set custom webroot
if [ ! -z "$WEBROOT" ]; then
webroot=$WEBROOT
sed -i "s#root /var/www/html;#root ${webroot};#g" /etc/nginx/sites-available/default.conf
else
webroot=/var/www/html
fi
# 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
# Dont pull code down if the .git folder exists
if [ ! -d "/var/www/html/.git" ]; then
# Pull down code from git for our site!
if [ ! -z "$GIT_REPO" ]; then
# Remove the test index file
rm -Rf /var/www/html/index.php
if [ ! -z "$GIT_BRANCH" ]; then
git clone -b $GIT_BRANCH $GIT_REPO /var/www/html
else
git clone $GIT_REPO /var/www/html
fi
fi
fi
# Display PHP error's or not
if [[ "$ERRORS" != "1" ]] ; then
echo php_flag[display_errors] = off >> /etc/php5/php-fpm.conf
else
echo php_flag[display_errors] = on >> /etc/php5/php-fpm.conf
fi
# Enable PHP short tag or not
if [[ "$SHORT_TAG" != "1" ]] ; then
echo php_flag[short_open_tag] = off >> /etc/php5/php-fpm.conf
else
echo php_flag[short_open_tag] = on >> /etc/php5/php-fpm.conf
fi
# Display Version Details or not
if [[ "$HIDE_NGINX_HEADERS" == "0" ]] ; then
sed -i "s/server_tokens off;/server_tokens on;/g" /etc/nginx/nginx.conf
else
sed -i "s/expose_php = On/expose_php = Off/g" /etc/php5/conf.d/php.ini
fi
# Increase the memory_limit
if [ ! -z "$PHP_MEM_LIMIT" ]; then
sed -i "s/memory_limit = 128M/memory_limit = ${PHP_MEM_LIMIT}M/g" /etc/php5/conf.d/php.ini
fi
# Increase the post_max_size
if [ ! -z "$PHP_POST_MAX_SIZE" ]; then
sed -i "s/post_max_size = 100M/post_max_size = ${PHP_POST_MAX_SIZE}M/g" /etc/php5/conf.d/php.ini
fi
# Increase the upload_max_filesize
if [ ! -z "$PHP_UPLOAD_MAX_FILESIZE" ]; then
sed -i "s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE}M/g" /etc/php5/conf.d/php.ini
fi
# Always chown webroot for better mounting
chown -Rf nginx.nginx /var/www/html
# Start supervisord and services
/usr/bin/supervisord -n -c /etc/supervisord.conf