-
Notifications
You must be signed in to change notification settings - Fork 1
/
permission.sh
executable file
·46 lines (36 loc) · 1.47 KB
/
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
#!/bin/bash
PHPVER=$( grep PHPVER /root/.nextpi.cnf | sed 's|PHPVER=||' )
## CONFIGURE FILE PERMISSIONS
ocpath='/var/www/nextcloud'
tmpdata=$( cd /var/www/nextcloud; sudo -u www-data php occ config:system:get datadirectory )
ocdata=$( dirname "$tmpdata" )
htuser='www-data'
htgroup='www-data'
rootuser='root'
printf "chmod Files and Directories\n"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
find ${ocdata}/ -type f -print0 | xargs -0 chmod 0640
find ${ocdata}/ -type d -print0 | xargs -0 chmod 0750
printf "chown Directories\n"
chown -R ${htuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocdata}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/
chmod +x ${ocpath}/occ
printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]; then
chmod 0644 ${ocpath}/.htaccess
chown ${htuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocdata}/data/.htaccess ]; then
chmod 0644 ${ocdata}/data/.htaccess
chown ${htuser}:${htgroup} ${ocdata}/data/.htaccess
fi
# create and configure opcache dir
OPCACHEDIR=${ocdata}/data/.opcache
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$OPCACHEDIR|" /etc/php/${PHPVER}/mods-available/opcache.ini
mkdir -p $OPCACHEDIR
chown -R www-data:www-data $OPCACHEDIR