From da81eb04756a4f22587fd5066c40efbcd709324f Mon Sep 17 00:00:00 2001 From: Basil Hendroff <63370329+basilhendroff@users.noreply.github.com> Date: Fri, 1 Jan 2021 15:45:23 +0800 Subject: [PATCH 1/4] Introduce WP_ROOT DB_PATH and FILES_PATH are no longer configurable parameters. These were dependent on POOL_PATH and, in use, created confusion for users. WP_ROOT is independent of POOL_PATH. Code checks are also simplified as a result of this change. --- wordpress-jail.sh | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/wordpress-jail.sh b/wordpress-jail.sh index 04c9fda..be5ea22 100755 --- a/wordpress-jail.sh +++ b/wordpress-jail.sh @@ -36,9 +36,7 @@ VNET="on" POOL_PATH="" JAIL_NAME="wordpress" TIME_ZONE="" -HOST_NAME="" -DB_PATH="" -FILES_PATH="" +WP_ROOT="/apps/wordpress" CONFIG_NAME="wordpress-config" # Exposed configuration parameters @@ -87,25 +85,8 @@ if [ -z "${TIME_ZONE}" ]; then exit 1 fi -# If DB_PATH and FILES_PATH weren't set in wordpress-config, set them -if [ -z "${DB_PATH}" ]; then - DB_PATH="${POOL_PATH}"/apps/wordpress/db -fi -if [ -z "${FILES_PATH}" ]; then - FILES_PATH="${POOL_PATH}"/apps/wordpress/files -fi - -# Sanity check DB_PATH and FILES_PATH -- they have to be different and can't be the same as POOL_PATH -if [ "${FILES_PATH}" = "${DB_PATH}" ] -then - print_err "FILES_PATH and DB_PATH must be different!" - exit 1 -fi -if [ "${DB_PATH}" = "${POOL_PATH}" ] || [ "${FILES_PATH}" = "${POOL_PATH}" ] -then - print_err "DB_PATH and FILES_PATH must all be different from POOL_PATH!" - exit 1 -fi +DB_PATH=${POOL_PATH}${WP_ROOT%/}/db +FILES_PATH=${POOL_PATH}${WP_ROOT%/}/files # Extract IP and netmask, sanity check netmask IP=$(echo ${JAIL_IP} | cut -f1 -d/) From a4013edaef5bba311025552539bb9b7c19afccdd Mon Sep 17 00:00:00 2001 From: Basil Hendroff <63370329+basilhendroff@users.noreply.github.com> Date: Fri, 1 Jan 2021 16:22:46 +0800 Subject: [PATCH 2/4] WP_ROOT replaces FILES_PATH and DB_PATH This should reduce the level of confusion and error as one config variable replaces two and WP_ROOT is independent of POOL_PATH. --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9fd12d6..fa44d4f 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ If you use either resource, please refer any reverse proxy questions you may hav ### Prerequisites (Other) Although not required, it's recommended to create a Dataset named `apps` with a sub-dataset named `wordpress` on your main storage pool and nested sub-datasets `files` and `db`. Many other jail guides also store their configuration and data in subdirectories of `pool/apps/` -For optimal performance, set the record size of the `db` dataset to 16 KB (under Advanced Settings in the TrueNAS web GUI). It's also recommended to cache only metadata on the `db` dataset; you can do this by running `zfs set primarycache=metadata poolname/apps/wordpress/db`. +For optimal performance, set the record size of the `db` dataset to 16 KB (under Advanced Settings in the TrueNAS web GUI). It's also recommended to cache only metadata on the `db` dataset; you can do this by running `zfs set primarycache=metadata zfs/path/to/db` e.g. `zfs set primarycache=metadata tank/apps/wordpress/db`. -If these datasets are not present, directories `/apps/wordpress/files` and `/apps/wordpress/db` will be created in `$POOL_PATH`. +If these datasets are not present, sub-directories `files` and `db` will be created in `$POOL_PATH` under `WP_ROOT`. ### Installation Download the repository to a convenient directory on your TrueNAS system by changing to that directory and running `git clone https://github.com/basilhendroff/truenas-iocage-wordpress`. Then change into the new `truenas-iocage-wordpress` directory and create a file called `wordpress-config` with your favorite text editor. In its minimal form, it would look something like this: @@ -33,7 +33,7 @@ JAIL_IP="192.168.1.4" DEFAULT_GW_IP="192.168.1.1" TIME_ZONE="Australia/Perth" ``` -Many of the options are self-explanatory, and all should be adjusted to suit your needs, but only a few are mandatory. The mandatory options are: +Many of the options are self-explanatory, and all can be adjusted to suit your needs, but only a few are mandatory. The mandatory options are: * JAIL_IP is the IP address for your jail. You can optionally add the netmask in CIDR notation (e.g., 192.168.1.199/24). If not specified, the netmask defaults to 24 bits. Values of less than 8 bits or more than 30 bits are invalid. * DEFAULT_GW_IP is the address for your default gateway @@ -43,8 +43,7 @@ In addition, there are some other options which have sensible defaults, but can - JAIL_NAME: The name of the jail, defaults to `wordpress`. - POOL_PATH: The path for your data pool. It is set automatically if left blank. -- FILES_PATH: WordPress site data is stored in this path; defaults to `$POOL_PATH/apps/wordpress/files`. -- DB_PATH: MariaDB database files are stored in this path; defaults to `$POOL_PATH/apps/wordpress/db`. +- WP_ROOT: The WordPress root, defaults to `/apps/wordpress'. WordPress data is stored under the root in sub-directories `files` and `db` - INTERFACE: The network interface to use for the jail. Defaults to `vnet0`. - VNET: Whether to use the iocage virtual network stack. Defaults to `on`. @@ -54,8 +53,7 @@ JAIL_IP="192.168.1.4" DEFAULT_GW_IP="192.168.1.1" TIME_ZONE="Australia/Perth" JAIL_NAME="site1" -FILES_PATH="/mnt/tank/apps/wordpress/site1/files" -DB_PATH="/mnt/tank/apps/wordpress/site1/db" +WP_ROOT="/apps/wordpress/site1" ``` ### Execution From 6549c019cb7e8c25d5c3aed29924cceb384d0ca1 Mon Sep 17 00:00:00 2001 From: Basil Hendroff <63370329+basilhendroff@users.noreply.github.com> Date: Fri, 1 Jan 2021 16:25:12 +0800 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa44d4f..0f3018e 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ In addition, there are some other options which have sensible defaults, but can - JAIL_NAME: The name of the jail, defaults to `wordpress`. - POOL_PATH: The path for your data pool. It is set automatically if left blank. -- WP_ROOT: The WordPress root, defaults to `/apps/wordpress'. WordPress data is stored under the root in sub-directories `files` and `db` +- WP_ROOT: The WordPress root, defaults to `/apps/wordpress`. WordPress data is stored under the root in sub-directories `files` and `db`. - INTERFACE: The network interface to use for the jail. Defaults to `vnet0`. - VNET: Whether to use the iocage virtual network stack. Defaults to `on`. From 9feaf26d4e48f0692e24d39905327a2b56a9e536 Mon Sep 17 00:00:00 2001 From: Basil Hendroff <63370329+basilhendroff@users.noreply.github.com> Date: Fri, 1 Jan 2021 16:44:58 +0800 Subject: [PATCH 4/4] Use Caddy 2.3.0 Code changes to streamline use of the latest Caddy version. --- wordpress-jail.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wordpress-jail.sh b/wordpress-jail.sh index be5ea22..75ee049 100755 --- a/wordpress-jail.sh +++ b/wordpress-jail.sh @@ -170,8 +170,10 @@ iocage fstab -a "${JAIL_NAME}" "${INCLUDES_PATH}" /mnt/includes nullfs rw 0 0 ##################################################################### print_msg "Caddy download..." -FILE="caddy_2.2.1_freebsd_amd64.tar.gz" -if ! iocage exec "${JAIL_NAME}" fetch -o /tmp https://github.com/caddyserver/caddy/releases/latest/download/"${FILE}" +CADDY_VERSION="2.3.0" + +FILE="caddy_${CADDY_VERSION}_freebsd_amd64.tar.gz" +if ! iocage exec "${JAIL_NAME}" fetch -o /tmp https://github.com/caddyserver/caddy/releases/download/v"${CADDY_VERSION}"/"${FILE}" then print_err "Failed to download Caddy" exit 1