-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·118 lines (100 loc) · 3.63 KB
/
entrypoint.sh
File metadata and controls
executable file
·118 lines (100 loc) · 3.63 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
keygen() {
cat /dev/urandom | tr -dc '[:print:]' | tr "\\\\" "-" | tr "'" "-" | head -c64;
}
export AUTH_KEY="${WORDPRESS_AUTH_KEY:-$(keygen)}"
export AUTH_SALT="${WORDPRESS_AUTH_SALT:-$(keygen)}"
export LOGGED_IN_KEY="${WORDPRESS_LOGGED_IN_KEY:-$(keygen)}"
export LOGGED_IN_SALT="${WORDPRESS_LOGGED_IN_SALT:-$(keygen)}"
export NONCE_KEY="${WORDPRESS_NONCE_KEY:-$(keygen)}"
export NONCE_SALT="${WORDPRESS_NONCE_SALT:-$(keygen)}"
export SECURE_AUTH_KEY="${WORDPRESS_SECURE_AUTH_KEY:-$(keygen)}"
export SECURE_AUTH_SALT="${WORDPRESS_SECURE_AUTH_SALT:-$(keygen)}"
export WP_DEBUG="${WORDPRESS_DEBUG:-false}"
export WP_DEBUG_LOG="${WORDPRESS_DEBUG_LOG:-false}"
export WP_DEBUG_DISPLAY="${WORDPRESS_DEBUG_DISPLAY:-false}"
if [ "$OPCACHE" = "true" ];
then
inifile="/usr/local/etc/php/conf.d/opcache-recommended.ini" ;
{
echo 'opcache.memory_consumption=128';
echo 'opcache.interned_strings_buffer=8';
echo 'opcache.max_accelerated_files=4000';
echo 'opcache.revalidate_freq=60';
echo 'opcache.fast_shutdown=1';
echo 'opcache.enable_cli=1';
} > $inifile;
unset inifile;
fi
if [ "$WP_DEBUG" = "true" ] && [ "$XDEBUG" != "false" ];
then
inifile="/usr/local/etc/php/conf.d/pecl-xdebug.ini"
extfile="$(find /usr/local/lib/php/extensions/ -name xdebug.so)";
remote_port="${XDEBUG_IDEKEY:-9000}";
idekey="${XDEBUG_IDEKEY:-xdbg}";
if [ -f "$extfile" ] && [ ! -f "$inifile" ];
then
{
echo "[Xdebug]";
echo "zend_extension=${extfile}";
echo "xdebug.idekey=${idekey}";
echo "xdebug.remote_enable=1";
echo "xdebug.remote_connect_back=1";
echo "xdebug.remote_autostart=1";
echo "xdebug.remote_port=${remote_port}";
} > $inifile;
fi
unset extfile remote_port idekey;
fi
#
# Should I respect the owner of mounted volumes
#
volume=$(mount -l | awk '/var\/www\/html/{ print $3; exit; }')
if [ -n "$volume" ];
then
uid=$(stat -c %u "$volume")
gid=$(stat -c %g "$volume")
fi
if [ -n "$uid" ] && [ "$WORDPRESS_DEBUG" = "true" ];
then
user=$(awk -F: "/:$uid:[0-9]+:/{ print \$1}" /etc/passwd)
group=$(awk -F: "/:x:$gid:/{ print \$1}" /etc/group)
if [ -z "$group" ];
then
usermod -g "$gid" www-data
fi
if [ -z "$user" ];
then
usermod -u "$uid" wordpress
fi
else
uid=$(awk -F: '/^www-data/{ print $3 }' /etc/passwd)
fi
php=`which php`;
for f in /docker-entrypoint-extra/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.php) echo "$0: running $f"; "${php}" < "$f" ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done
# Install WordPress
cd /var/www/html
#wp core config --dbhost=$WORDPRESS_DB_HOST --dbname=$WORDPRESS_DB_NAME --dbuser=$WORDPRESS_DB_USER --dbpass=$WORDPRESS_DB_PASSWORD --dbprefix=$WORDPRESS_TABLE_PREFIX
chmod 644 wp-config.php
wp core install --url=$WORDPRESS_SITEURL --title="${WORDPRESS_BLOG_NAME}" --admin_name=$WORDPRESS_USERNAME --admin_password="${WORDPRESS_PASSWORD}" --admin_email="${WORDPRESS_EMAIL}"
wp user update $WORDPRESS_USERNAME --first_name="${WORDPRESS_FIRST_NAME}" --last_name="${WORDPRESS_LAST_NAME}"
# Create uploads folder
cd wp-content
mkdir uploads
chown -R www-data: *
chmod 775 uploads/
# Update WordPress options
wp option update permalink_structure '/%postname%/'
wp option update default_ping_status 'closed'
wp option update default_pingback_flag '0'
# Install some usefull plugins
wp plugin install all-in-one-wp-security-and-firewall w3-total-cache --activate
#wp plugin install jetpack wordpress-seo regenerate-thumbnails cloudflare
exec "$@"