Skip to content

Commit

Permalink
Sanity check WP_ROOT
Browse files Browse the repository at this point in the history
In a worst case, WP_ROOT="path/to/site/" in the config file. This gets normalised to WP_ROOT="/path to/site"
  • Loading branch information
basilhendroff committed Jan 2, 2021
1 parent 90ea4ed commit 3c5e9ab
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions wordpress-jail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ if [ -n "${FILES_PATH}" ] || [ -n "${DB_PATH}" ]; then
print_err "Configuration error: WP_ROOT replaces FILES_PATH and DB_PATH in newer script versions. Update ${CONFIG_NAME} and run the script again."
exit 1
fi

DB_PATH=${POOL_PATH}${WP_ROOT%/}/db
FILES_PATH=${POOL_PATH}${WP_ROOT%/}/files
if [ ${WP_ROOT:0:1} != "/" ]; then
WP_ROOT="/${WP_ROOT%/}"
fi
# Check that this is a new installation
if [ -e "${POOL_PATH}${WP_ROOT}" ]
then
print_err "This script only works for new installations. The script cannot proceed if WP_ROOT exists."
exit 1
fi

# Extract IP and netmask, sanity check netmask
IP=$(echo ${JAIL_IP} | cut -f1 -d/)
Expand All @@ -105,13 +111,6 @@ then
NETMASK="24"
fi

# Check that this is a new installation
if [ -e "${POOL_PATH}${WP_ROOT}" ]
then
print_err "This script only works for new installations. The script cannot proceed if WP_ROOT exists."
exit 1
fi

# Reuse the password file if it exists and is valid
if ! [ -e "/root/${JAIL_NAME}_db_password.txt" ]; then
DB_PASSWORD=$(rand 24)
Expand Down Expand Up @@ -160,6 +159,9 @@ rm /tmp/pkg.json
#####################################################################
print_msg "Directory Creation and Mounting..."

DB_PATH=${POOL_PATH}${WP_ROOT}/db
FILES_PATH=${POOL_PATH}${WP_ROOT}/files

mkdir -p "${DB_PATH}"
chown -R 88:88 "${DB_PATH}"
iocage fstab -a "${JAIL_NAME}" "${DB_PATH}" /var/db/mysql nullfs rw 0 0
Expand Down

0 comments on commit 3c5e9ab

Please sign in to comment.