summarylogtreecommitdiffstats
path: root/set-oc-perms.sh
blob: c7507812f69e9b3b4011a63f0c7cc7e109e53040 (plain)
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
#!/usr/bin/env bash
# from https://doc.owncloud.org/server/9.0/admin_manual/installation/installation_wizard.html#strong-perms-label
# run with the argument "runtime" to set the proper runtime permissions
# run with the argument "upgrade" to set the proper upgrade permissions

ocpath='/usr/share/webapps/owncloud'
htuser='http'
htgroup='http'
rootuser='root'

runtime() {
  printf "Creating possible missing Directories\n"
  mkdir -p $ocpath/data
  mkdir -p $ocpath/assets
  mkdir -p $ocpath/updater

  printf "chmod Files and Directories\n"
  find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
  find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

  printf "chown Directories\n"
  chown -R ${rootuser}:${htgroup} ${ocpath}/
  chown -R ${htuser}:${htgroup} ${ocpath}/apps/
  chown -R ${htuser}:${htgroup} ${ocpath}/assets/
  chown -R ${htuser}:${htgroup} ${ocpath}/config/
  chown -R ${htuser}:${htgroup} ${ocpath}/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 0664 ${ocpath}/.htaccess
    chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
  fi
  if [ -f ${ocpath}/data/.htaccess ]
   then
    chmod 0664 ${ocpath}/data/.htaccess
    chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
  fi

  printf "chmod/chown .user.ini\n"
  if [ -f ${ocpath}/.user.ini ]
   then
    chmod 0664 ${ocpath}/.user.ini
    chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
  fi
}

upgrade() {
  printf "Setting upgrade permissions\n"
  chown -R ${htuser}:${htgroup} ${ocpath}
}

$1