-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·67 lines (49 loc) · 1.6 KB
/
entrypoint.sh
File metadata and controls
executable file
·67 lines (49 loc) · 1.6 KB
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
#!/bin/bash
set -e
if [ "$USER" = "root" ]; then
# set localtime
ln -sf /usr/share/zoneinfo/$LOCALTIME /etc/localtime
# secure path
chmod a-rwx -R $PHP_INI_DIR/conf.d/ /etc/ssmtp
fi
#
# functions
function set_conf {
echo ''>$2; IFSO=$IFS; IFS=$(echo -en "\n\b")
for c in `printenv|grep $1`; do echo "`echo $c|cut -d "=" -f1|awk -F"$1" '{print $2}'` $3 `echo $c|cut -d "=" -f2`" >> $2; done;
IFS=$IFSO
}
#
# PHP
echo "date.timezone = \"${LOCALTIME}\"" >> $PHP_INI_DIR/conf.d/00-default.ini
if [ "$PHP_php5enmod" != "" ]; then docker-php-ext-enable $PHP_php5enmod > /dev/null 2>&1; fi;
if [ "$pecl_install" != "" ]; then pecl install $pecl_install > /dev/null 2>&1; fi;
set_conf "PHP__" "$PHP_INI_DIR/conf.d/40-user.ini" "="
# Set memcached session save handle
if [ -n "$MEMCACHED" ]; then
if [ ! -f $PHP_INI_DIR/conf.d/docker-php-ext-memcached.ini ]; then docker-php-ext-enable memcached > /dev/null; fi
IFSO=$IFS; IFS=' ' read -ra BACKENDS <<< "${MEMCACHED}"
for BACKEND in "${BACKENDS[@]}"; do
SAVE_PATH="${SAVE_PATH}${BACKEND}?${MEMCACHED_CONFIG:-persistent=1&timeout=5&retry_interval=30},"
done; IFS=$IFSO;
cat << EOF >> $PHP_INI_DIR/conf.d/20-memcached.ini
session.save_handler = memcached
session.save_path = "${SAVE_PATH}"
EOF
fi
# Set ssmtp server
if [ -n "$SMTP" ]; then
echo 'sendmail_path = /usr/sbin/ssmtp -t' >> $PHP_INI_DIR/conf.d/00-default.ini
sed -i "s/mailhub=.*/mailhub=${SMTP}/" /etc/ssmtp/ssmtp.conf
fi
#
# Run
if [[ -z "$1" ]]; then
exec php -a
exit
fi
if [[ -f "$1" ]]; then
exec php ${*}
exit
fi
exec "${@}"