summaryrefslogtreecommitdiff
path: root/volinit-netatalk
blob: f81bad8984e439e52abdf77b813d4c384409d387 (plain)
  1. #!/bin/bash
  2. # Reset access rights of a netatalk archive
  3. #
  4. # The archive should be in subfolders named after read/write and readonly groups
  5. # like this: /var/local/netatalk/files_administered_by_admins/admin/users/
  6. #
  7. # Also, the file /etc/local/volumes should contain something like the following
  8. # (indicating the root of all netatalk folders):
  9. #
  10. # NDIR="/var/local/netatalk"
  11. #
  12. [ -f /etc/local/volumes ] || exit 1
  13. . /etc/local/volumes
  14. [ "x$NDIR" = "x" ] && exit 1
  15. if [ $# -eq 0 ]; then
  16. echo "Usage: $0 <base directory> <read user/group> <write user/group> [create]"
  17. exit 1
  18. fi
  19. if [ "x$1" = "x" ]; then
  20. echo "$0: base directory missing"
  21. exit 1
  22. fi
  23. VOL=$NDIR/$1
  24. if [ "x$2" = "x" ]; then
  25. echo "$0: read group missing"
  26. exit 1
  27. fi
  28. ALL=$2
  29. if [ "x$3" = "x" ]; then
  30. echo "$0: write group missing"
  31. exit 1
  32. fi
  33. GRP=$3
  34. GRPUSER="admin"
  35. id $GRP >/dev/null && GRPUSER=$GRP
  36. if [ "x$4" != "x" ]; then
  37. if [ "x$4" == "xcreate" ]; then
  38. mkdir -p $VOL/$ALL/$GRP || exit
  39. else
  40. echo "Usage: $0 <base directory> <read user/group> <write user/group> [create]"
  41. exit 1
  42. fi
  43. fi
  44. test -d $VOL/$ALL/$GRP || exit
  45. test -d $VOL/$ALL/$GRP/.AppleDouble || mkdir $VOL/$ALL/$GRP/.AppleDouble
  46. test -d $VOL/$ALL/$GRP/.AppleDesktop || mkdir $VOL/$ALL/$GRP/.AppleDesktop
  47. chown root:$ALL $VOL/$ALL
  48. chown $GRPUSER:$ALL $VOL/$ALL/$GRP
  49. chmod u=rwX,g=rXs,o= $VOL/$ALL
  50. chmod u=rwX,g=rXs,o= $VOL/$ALL/$GRP
  51. echo "People in group $GRP has read/write access through AppleShare"
  52. test $GRP = $ALL || echo "People in group $ALL has read access through AppleShare"
  53. echo "Others have no access"
  54. echo -n "Checking permissions..."
  55. chown -R :$GRP $VOL/$ALL/$GRP \
  56. && chmod -R u=rwX,g=rwXs,o=rX $VOL/$ALL/$GRP \
  57. && chmod u=rwX,g=rXs,o=rX $VOL/$ALL/$GRP
  58. echo "."