#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: http://mirrors.slickstack.io/bash/ss-perms-wordpress-mu-plugins.txt ################### #### path: /var/www/ss-perms-wordpress-mu-plugins ################################################## #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Resets file and user permissions for WordPress MU plugins files and folders ########## #### module version: WordPress 5.5.x ############################################################### #### sourced by: ss-perms, ss-install-wordpress-mu-plugins ######################################### #### bash aliases: ss perms wordpress [wp] mu plugins, ss perms mu plugins ######################### #################################################################################################### ## include SlickStack configuration ## source /var/www/ss-config ## include SlickStack functions ## source /var/www/ss-functions #################################################################################################### #### SS-Perms-WordPress-MU-Plugins: Message (Begin Script) ######################################### #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be noticed by sudo users who manually call ss core bash scripts ## ## echo message ## echo -e "${PURPLE}Running ss-perms-wordpress-mu-plugins: Resets file and user permissions for WordPress MU plugins files and folders... ${NOCOLOR}" sleep "$SLEEP_MESSAGE_BEGIN" #################################################################################################### #### SS-Perms-WordPress-MU-Plugins: Reset Permissions (WordPress MU Plugins) ####################### #################################################################################################### ## here we reset permissions for MU plugins and certain other SlickStack bundled files ## ## functions.php might be edited via SFTP so we must keep that in mind here ## ## ensure files exist (production only because ss-sync will copy to staging) ## if [ ! -f "/var/www/html/wp-content/blacklist.txt" ]; then touch "/var/www/html/wp-content/blacklist.txt"; fi if [ ! -f "/var/www/html/wp-content/functions.php" ]; then touch "/var/www/html/wp-content/functions.php"; fi ## reset MU plugins permissions (production) ## chown -R www-data:wordpress /var/www/html/wp-content/mu-plugins chown $SFTP_USER:wordpress /var/www/html/wp-content/functions.php ## allows for editing via SFTP chown www-data:wordpress /var/www/html/wp-content/blacklist.txt find /var/www/html/wp-content/mu-plugins/ -type d -exec chmod 0755 {} \; ## 0755 is enough find /var/www/html/wp-content/mu-plugins/ -type f -exec chmod 0644 {} \; ## 0644 is enough chmod 0440 /var/www/html/wp-content/mu-plugins/autoloader.php ## 0440 (read-only) chmod 0440 /var/www/html/wp-content/mu-plugins/xxx-common.php ## 0440 (read-only) chmod 0664 /var/www/html/wp-content/object-cache.php ## 0644 is enough chmod 0664 /var/www/html/wp-content/functions.php ## 0664 to allow WP edit files chmod 0440 /var/www/html/wp-content/blacklist.txt ## 0440 (read-only) ## reset MU plugins permissions (staging) ## if [[ "$STAGING_SITE" != "false" ]]; then chown -R www-data:wordpress /var/www/html/staging/wp-content/mu-plugins chown $SFTP_USER:wordpress /var/www/html/staging/wp-content/functions.php ## allows for editing via SFTP chown www-data:wordpress /var/www/html/staging/wp-content/blacklist.txt find /var/www/html/staging/wp-content/mu-plugins/ -type d -exec chmod 0755 {} \; ## 0755 is enough find /var/www/html/staging/wp-content/mu-plugins/ -type f -exec chmod 0644 {} \; ## 0644 is enough chmod 0440 /var/www/html/staging/wp-content/mu-plugins/autoloader.php ## 0440 (read-only) chmod 0440 /var/www/html/staging/wp-content/mu-plugins/xxx-common.php ## 0440 (read-only) chmod 0644 /var/www/html/staging/wp-content/object-cache.php ## 0644 is enough chmod 0664 /var/www/html/staging/wp-content/functions.php ## 0664 to allow WP edit files chmod 0440 /var/www/html/staging/wp-content/blacklist.txt ## 0440 (read-only) fi ## reset MU plugins permissions (dev) ## if [[ "$DEV_SITE" != "false" ]]; then chown -R www-data:wordpress /var/www/html/dev/wp-content/mu-plugins chown $SFTP_USER:wordpress /var/www/html/dev/wp-content/functions.php ## allows for editing via SFTP chown www-data:wordpress /var/www/html/dev/wp-content/blacklist.txt find /var/www/html/dev/wp-content/mu-plugins/ -type d -exec chmod 0755 {} \; ## 0755 is enough find /var/www/html/dev/wp-content/mu-plugins/ -type f -exec chmod 0644 {} \; ## 0644 is enough chmod 0440 /var/www/html/dev/wp-content/mu-plugins/autoloader.php ## 0440 (read-only) chmod 0440 /var/www/html/dev/wp-content/mu-plugins/xxx-common.php ## 0440 (read-only) chmod 0644 /var/www/html/dev/wp-content/object-cache.php ## 0644 is enough chmod 0664 /var/www/html/dev/wp-content/functions.php ## 0664 to allow WP edit files chmod 0440 /var/www/html/dev/wp-content/blacklist.txt ## 0440 (read-only) fi ## NULL blacklist.txt if ss-config false (allows default SS MU plugin to be installed while still being able to disable plugin blacklist) ## if [[ "$SS_PLUGIN_BLACKLIST" == "false" ]]; then cat /dev/null > /var/www/html/wp-content/blacklist.txt cat /dev/null > /var/www/html/dev/wp-content/blacklist.txt cat /dev/null > /var/www/html/staging/wp-content/blacklist.txt fi #################################################################################################### #### SS-Perms-WordPress-MU-Plugins: Touch Timestamp File (End Script) ############################## #################################################################################################### ## this is a dummy timestamp file that will remember the last time this script was run ## ## it can be useful for developer reference and is sometimes used by SlickStack ## ## script timestamp ## touch /var/www/meta/.timestamp-ss-perms-wordpress-mu-plugins #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: ## SS_EOF