mirror of
https://github.com/N0rthernL1ghts/wordpress.git
synced 2025-12-09 07:12:41 +01:00
Apply patch during build time
This commit is contained in:
36
rootfs/usr/local/bin/wp-apply-patch
Executable file
36
rootfs/usr/local/bin/wp-apply-patch
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Applies patch for preventing WordPress updates
|
||||
function main() {
|
||||
PATCH_FILE="${1:?PATCH_FILE is required}"
|
||||
TARGET_FILE="${2:?TARGET_FILE is required}"
|
||||
|
||||
if [ ! -f "${PATCH_FILE}" ]; then
|
||||
echo "> No such file [PATCH]: ${PATCH_FILE}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${TARGET_FILE}" ]; then
|
||||
echo "> No such file [TARGET]: ${TARGET_FILE}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "> Loading patch ${PATCH_FILE}"
|
||||
echo " Patching '${TARGET_FILE}'..."
|
||||
patch --verbose "${TARGET_FILE}" <"${PATCH_FILE}"
|
||||
|
||||
MARK_READ_ONLY="${3:-true}"
|
||||
if [ "${MARK_READ_ONLY}" = "true" ]; then
|
||||
# This is done in order to prevent WordPress overwriting the file
|
||||
echo " Marking the patched file read-only..."
|
||||
chmod 0440 "${TARGET_FILE}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Usage: main /etc/wp-mods/wp-admin-update-core.patch /var/www/html/wp-admin/update-core.php ?true|false
|
||||
main "${@}"
|
||||
exit $?
|
||||
Reference in New Issue
Block a user