Skip to content

Commit

Permalink
wp: synced with master
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Oct 19, 2024
1 parent 6fa913f commit 602adaa
Showing 1 changed file with 56 additions and 108 deletions.
164 changes: 56 additions & 108 deletions tnpi/wordpress_simerson.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/sh

# shellcheck disable=1091
. mail-toaster.sh || exit
set -e

. mail-toaster.sh

export JAIL_START_EXTRA=""
export JAIL_CONF_EXTRA=""
export JAIL_FSTAB=""

mt6-include php
mt6-include nginx
Expand All @@ -14,105 +16,52 @@ install_wordpress()
assure_jail mysql

install_nginx
install_php 74 "ctype curl ftp gd hash json mysqli session tokenizer xml zip zlib"
install_php 82 "ctype curl exif fileinfo ftp gd mysqli pecl-imagick session tokenizer xml zip zlib"

# stage_pkg_install wordpress
stage_port_install www/wordpress || exit
}

configure_nginx_standalone()
{
if [ -f "$STAGE_MNT/data/etc/nginx-locations.conf" ]; then
tell_status "preserving /data/etc/nginx-locations.conf"
return
fi

tee "$STAGE_MNT/data/etc/nginx-locations.conf" <<'EO_WP_NGINX'
server_name wordpress;
index index.php;
root /usr/local/www;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# include "?$args" so non-default permalinks don't break
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
expires max;
log_not_found off;
}
EO_WP_NGINX

stage_port_install www/wordpress
}

configure_nginx_with_path()
configure_nginx_server()
{
if [ -f "$STAGE_MNT/data/etc/nginx-locations.conf" ]; then
tell_status "preserving /data/etc/nginx-locations.conf"
return
fi

local _uri_path="$1"
if [ -z "$_uri_path" ]; then
tell_status "using /wpn (wordpress network) for WP url path"
_uri_path="/wpn"
fi

tee "$STAGE_MNT/data/etc/nginx-locations.conf" <<'EO_WP_NGINX'
server_name wordpress;
index index.php;
root /usr/local/www/wordpress;
# all PHP scripts, optionally within /wpn/
location ~ ^/(?:wpn/)?(?<script>.+\.php)(?<path_info>.*)$ {
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
fastcgi_pass php;
}
# wordpress served with URL path
location /wpn/ {
alias /usr/local/www/wordpress/;
# say "yes we can" to permalinks
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
expires max;
log_not_found off;
}
EO_WP_NGINX

# shellcheck disable=2089
_NGINX_SERVER='
server_name wordpress;
index index.php;
root /usr/local/www;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# include "?$args" so non-default permalinks do not break
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
expires max;
log_not_found off;
}
'
# shellcheck disable=2090
export _NGINX_SERVER
configure_nginx_server_d wordpress
}

configure_wp_config()
Expand All @@ -121,23 +70,26 @@ configure_wp_config()
local _wp_install="$ZFS_JAIL_MNT/wordpress/usr/local/www/wordpress"
local _wp_stage="$STAGE_MNT/usr/local/www/wordpress"

if [ ! -d "$_local_content" ]; then
if [ -d "$_local_content" ]; then
tell_status "linking wp-content to $_local_content"
rm -r "$STAGE_MNT/usr/local/www/wordpress/wp-content"
stage_exec ln -s /data/content "/usr/local/www/wordpress/wp-content"
else
tell_status "copying wp-content to /data"
cp -r "$_wp_stage/wp-content" "$_local_content"
mv "$_wp_stage/wp-content" "$_local_content"
chown -R 80:80 "$_local_content"
else
chown -R 80:80 "$_wp_stage/wp-content"
fi

if [ ! -d "$_local_content/uploads" ]; then
tell_status "creating $_local_content/uploads"
mkdir "$_local_content/uploads"
chown 80:80 "$_local_content/uploads"
fi

local _installed_config="$_wp_install/wp-config.php"
if [ -f "$_installed_config" ]; then
tell_status "installing local wp-config.php"
cp "$_installed_config" "$STAGE_MNT/usr/local/www/wordpress/" || exit
tell_status "preserving wp-config.php"
cp "$_installed_config" "$STAGE_MNT/usr/local/www/wordpress/"
return
else
tell_status "post-install configuration will be required"
Expand Down Expand Up @@ -170,20 +122,16 @@ define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
EO_WP_NGINX

}

configure_wordpress()
{
configure_php wordpress
configure_nginx wordpress

configure_nginx_standalone
# configure_nginx_with_path /wpn
configure_nginx_server

configure_wp_config

stage_sysrc nginx_flags='-c /data/etc/nginx.conf'
}

start_wordpress()
Expand All @@ -206,4 +154,4 @@ install_wordpress
configure_wordpress
start_wordpress
test_wordpress
promote_staged_jail wordpress_simerson
promote_staged_jail wordpress

0 comments on commit 602adaa

Please sign in to comment.