access-permissions.sh 777 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. # Apply access permissions
  3. if [ ! -f './constants.php' ] || [ ! -d './cli/' ]; then
  4. echo >&2 '⛔ It does not look like a FreshRSS directory; exiting!'
  5. exit 2
  6. fi
  7. if [ "$(id -u)" -ne 0 ]; then
  8. echo >&2 '⛔ Applying access permissions require running as root or sudo!'
  9. exit 3
  10. fi
  11. # Always fix permissions on the data and extensions directories
  12. # If specified, only fix the data and extensions directories
  13. data_path="${DATA_PATH:-./data}"
  14. if [ "${1:-}" = "--only-userdirs" ]; then
  15. to_update="./extensions"
  16. else
  17. to_update="."
  18. fi
  19. mkdir -p "${data_path}/users/_/"
  20. # Based on group access
  21. chown -R :www-data "$data_path" "$to_update"
  22. # Read files, and directory traversal
  23. chmod -R g+rX "$data_path" "$to_update"
  24. # Write access to data
  25. chmod -R g+w "$data_path"