summaryrefslogtreecommitdiff
path: root/volinit-samba
blob: d33ad00c4eef6f4d0eac58c39fe6b46d6011006c (plain)
  1. #!/bin/bash
  2. [ -f /etc/local/volumes ] || exit 1
  3. . /etc/local/volumes
  4. [ "x$SDIR" = "x" ] && exit 1
  5. if [ $# -eq 0 ]; then
  6. # echo "$0: directory name(s) required"
  7. echo "Usage: $0 <base directory> <read user/group> <write user/group> [create]"
  8. exit 1
  9. fi
  10. if [ "x$1" = "x" ]; then
  11. echo "$0: base directory missing"
  12. exit 1
  13. fi
  14. VOL=$SDIR/$1
  15. if [ "x$2" = "x" ]; then
  16. echo "$0: read group missing"
  17. exit 1
  18. fi
  19. ALL=$2
  20. if [ "x$3" = "x" ]; then
  21. echo "$0: write group missing"
  22. exit 1
  23. fi
  24. GRP=$3
  25. #GRPUSER="nobody"
  26. GRPUSER="admin"
  27. #if [ "x$4" != "x" ]; then
  28. # GRPUSER=$4
  29. #else
  30. id $GRP >/dev/null && GRPUSER=$GRP
  31. #fi
  32. if [ "x$4" != "x" ]; then
  33. if [ "x$4" == "xcreate" ]; then
  34. mkdir -p $VOL/$ALL/$GRP || exit
  35. else
  36. echo "Usage: $0 <base directory> <read user/group> <write user/group> [create]"
  37. exit 1
  38. fi
  39. fi
  40. test -d $VOL/$ALL/$GRP || exit
  41. chown root.$ALL $VOL/$ALL
  42. chown $GRPUSER.$ALL $VOL/$ALL/$GRP
  43. chmod u=rwX,g=rX,o= $VOL/$ALL
  44. chmod u=rwX,g=rX,o= $VOL/$ALL/$GRP
  45. echo "People in group $GRP has read/write access through SMB networking"
  46. test $GRP = $ALL || echo "People in group $ALL has read access through SMB networking"
  47. echo "Others have no access"
  48. echo -n "Checking permissions..."
  49. chown -R $GRPUSER.$GRP $VOL/$ALL/$GRP \
  50. && chmod -R u=rwX,g=rwX,o=rX $VOL/$ALL/$GRP
  51. echo "."