Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
74 lines (59 loc) · 2.55 KB
/
Copy pathinstall.sh
File metadata and controls
74 lines (59 loc) · 2.55 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
#!/bin/bash
set -euo pipefail
# Enable user-specified Apache modules.
if [ -n "$APACHE_EXTRA_MODULES" ]; then
for mod in $APACHE_EXTRA_MODULES; do
sudo a2enmod "$mod";
done;
fi
/etc/init.d/apache2 reload
cd /var/www/html/
# Check if WordPress is already installed. If it is, exit the script.
# https://developer.wordpress.org/cli/commands/core/is-installed/
wp core is-installed 2>/dev/null && exit 0 || true
# https://developer.wordpress.org/cli/commands/config/create/
echo "require_once __DIR__ . '/.devcontainer/wp-config-extra.php';" | wp config create \
--dbhost=${WORDPRESS_DB_HOST:-db} \
--dbname=${WORDPRESS_DB_NAME:-wordpress} \
--dbuser=${WORDPRESS_DB_USER:-wordpress} \
--dbpass=${WORDPRESS_DB_PASSWORD:-wordpress} \
--dbprefix=${WORDPRESS_DB_PREFIX:-wp_} \
--dbcharset=${WORDPRESS_DB_CHARSET:-utf8} \
--dbcollate=${WORDPRESS_DB_COLLATE:-} \
--locale=${WORDPRESS_LOCALE:-en_US} \
--extra-php
# Check again. If WordPress is installed, `wp rewrite flush` and exit.
if wp core is-installed 2>/dev/null; then
# wp core update-db
wp cache flush
wp transient delete --all
# Requires "wp-cli.yml". See https://github.com/wp-cli/rewrite-command/tree/main#wp-rewrite-flush
# If your site's URL structre has still broken, open http://localhost/wp-admin/options-permalink.php
wp rewrite flush --hard
exit 0
fi
# https://developer.wordpress.org/cli/commands/core/install/
wp core install \
--url=${WORDPRESS_URL:-http://localhost} \
--title=${WORDPRESS_TITLE:-"WordPress in dev container"} \
--admin_user=${WORDPRESS_ADMIN_USER:-admin} \
--admin_password=${WORDPRESS_ADMIN_PASSWORD:-password} \
--admin_email=${WORDPRESS_ADMIN_EMAIL:-admin@wordpress.local} \
--locale=${WORDPRESS_LOCALE:-en_US} \
--skip-email
# Avoid dependency on default themes that are added every year.
# https://wordpress.org/themes/classic/
wp theme install classic
if ! wp theme list --status=active --quiet; then
wp theme activate classic
fi
wp plugin install mcp-adapter --activate
wp plugin install \
query-monitor \
wordpress-beta-tester \
user-switching
# Create and protect the debug.log file.
touch /var/www/html/wp-content/debug.log
curl --fail --location --silent --output /dev/null http://localhost/wp-content/debug.log && echo -e "# Prevent access debug.log\n<FilesMatch \"^debug\.log\">\n RedirectMatch 404 .*\n</FilesMatch>" >> /var/www/html/wp-content/.htaccess
wp eval 'wp_mail("you@example.com", "Installation Complete", "WordPress has been successfully installed.");'
exit 0