-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_permission.sh
60 lines (50 loc) · 1.52 KB
/
fix_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
#!/bin/bash
# the following to be execute inside the DocumentRoot of a SuiteCRM installation
# to fix permissions
# Assure user is root:
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# check SuiteCRM is running under `apache` user
test_apache=`apachectl -S | grep User | awk '{ print $2}' | awk -F '=' '{ print $2}'`
if ! [ $test_apache = '"apache"' ]; then
echo "User running web server is not 'apache', aborting."
exit 1
fi
# Check that we are in a SuiteCRM DocumentRoot by
# checking files presence
FILES='suitecrm_version.php sugar_version.json config.php config_override.php'
for file in $FILES
do
if [[ ! -f $file ]] ; then
echo "This script must be executed in a SuiteCRM DocumentRoot, aborting."
exit 1
fi
done
# and checking directory presence
DIRS='data custom include modules log4php'
for dir in $DIRS
do
if [[ ! -d $dir ]] ; then
echo "This script must be executed in a SuiteCRM DocumentRoot, aborting."
exit 1
fi
done
DIR=`pwd`
echo "This script will fix permission of SuiteCRM DocumentRoot: $DIR"
while true; do
read -p "Proceed?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo "Fixing permission of SuiteCRM DocumentRoot: $DIR"
chown -R apache:apache $DIR
chmod -R 755 $DIR
chmod -R 775 cache custom modules themes data upload
chmod 775 config_override.php
echo "Done!"
echo "not better execute a 'Quick Repair and Rebuild' inside SuiteCRM admin interface"