diff --git a/Makefile b/Makefile index 56827d4..2edda46 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ sd-users: ## Run this after adding new users .PHONY: save-perms save-perms: ## Saves the file permissions to ./acl. Run this after adding new files with correct permissions - getfacl --recursive root > acl + getfacl --recursive root | ./makepac/sort_acl.sh > acl .PHONY: set-perms set-perms: ## Restores permissions of all files from ./acl diff --git a/sort_acl.sh b/sort_acl.sh new file mode 100755 index 0000000..8a40932 --- /dev/null +++ b/sort_acl.sh @@ -0,0 +1,8 @@ +#!/usr/bin/bash +# Sorts the output of getfacl records to stdout +# Assumes filenames don't contain + and | + +awk ' +BEGIN { RS="\n\n"; FS="\n"; ORS="\n"; OFS="|"} +// { $2=$2; print } +' | sort -k 1,1 -t '|' | tr '\n' '+' | sed 's/+/\n\n/g' | sed 's/|/\n/g'