check_permissions.sh 563 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. # LGSM check_permissions function
  3. # Author: Daniel Gibbs
  4. # Contributor: UltimateByte
  5. # Website: http://gameservermanagers.com
  6. lgsm_version="150316"
  7. # Description: Checks script, files and folders ownership and permissions.
  8. # Initializing useful variables
  9. currentuser="$(sh -c 'whoami')"
  10. scriptfullpath="${rootdir}/${selfname}"
  11. fn_check_ownership(){
  12. if [ "${currentuser}" != "$(stat -c %U ${scripfullpath})" ] || [ "${currentuser}" != "$(stat -c %G ${scripfullpath})" ]; then
  13. fn_print_fail_nl "Permission denied"
  14. exit 1
  15. fi
  16. }
  17. fn_check_ownership