Skip to content

Instantly share code, notes, and snippets.

@ShaRose
Created January 3, 2018 06:40
Show Gist options
  • Save ShaRose/2488132934df2daee1f681bd06865011 to your computer and use it in GitHub Desktop.
Save ShaRose/2488132934df2daee1f681bd06865011 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ ! -d "$1" ]; then
echo "Instructions:
./procacls.sh /Path/To/Folder 'user:myuser@domain.path:rwx,group:mygroup@domain.path:rwx'
Outputs * for each record processed."
exit 1
fi
process()
{
setfacl -b "$1"
if [ -f "$1" ]; then
chmod 660 "$1"
setfacl -m "${2//:rwx/:rw}" "$1"
elif [ -d "$1" ]; then
chmod 770 "$1"
setfacl -d -m "$2" "$1"
setfacl -m "$2" "$1"
fi
restorecon "$1"
echo -n "*"
}
export -f process
processstring="process \"{}\" \"$2\"" # Yes, this is a stupid hack. It also works, so fuck it
find "$1" -exec bash -c "$processstring" \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment