#!/bin/bash

set -ex

dirlist="/tank/exports/ERC_PALAEO/ModE-RA"
userlist="ralf joerg veronika rhand@giub.local"

for dir in ${dirlist}; do

   chown -R joerg:palaeo-ra ${dir}
   setfacl -b -R ${dir} ; setfacl -b -R -d ${dir}

   cmd_string="-m o:r-X -m d:o:r-X"

   for user in ${userlist}; do

      cmd_string="${cmd_string} -m u:${user}:rwX -m d:u:${user}:rwX"

   done # user

   setfacl -R ${cmd_string} ${dir}

   find ${dir} -type d -exec chmod g+s {} \;
   
done # dir

exit 0
