-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-fix-write-permission.sh
62 lines (44 loc) · 1.53 KB
/
wp-fix-write-permission.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
SITE_DIR=/var/www/html/
# =============================================================================
# Functions
# =============================================================================
function is_file() {
local file=$1
[[ -f $file ]]
}
function is_dir() {
local dir=$1
[[ -d $dir ]]
}
function write_permissions {
# Use it only for setup and update Wordfance plugin
sudo chown -R www-data:www-data ${SITE_DIR};
sudo find ${SITE_DIR} -type d -exec chmod 775 {} \;
sudo find ${SITE_DIR} -type f -exec chmod 664 {} \;
if [ -d "${SITE_DIR}/wp-content/wflogs/" ]; then
sudo chmod -Rf 775 ${SITE_DIR}/wp-content/wflogs/;
fi
if [ -f "${SITE_DIR}/wp-config.php" ]; then
sudo chmod 775 ${SITE_DIR}/wp-config.php;
fi
if [ -f "${SITE_DIR}/wordfence-waf.php" ]; then
sudo chmod 775 ${SITE_DIR}/wordfence-waf.php;
fi
if [ -f "${SITE_DIR}/wflogs/config-synced.php" ]; then
sudo chmod 775 ${SITE_DIR}/wflogs/config-synced.php;
fi
if [ -f "${SITE_DIR}/.user.ini" ]; then
sudo chmod 775 ${SITE_DIR}/.user.ini;
fi
}
function default_permissions {
# Understand Bitnami WordPress Filesystem Permissions
# https://docs.bitnami.com/google/apps/wordpress/administration/understand-file-permissions/
sudo chown -R www-data:www-data ${SITE_DIR};
sudo find ${SITE_DIR} -type d -exec chmod 775 {} \;
sudo find ${SITE_DIR} -type f -exec chmod 664 {} \;
sudo chmod 640 ${SITE_DIR}/wp-config.php;
}
#default_permissions;
write_permissions;