From 743956cf15fddc4315a11986025a7a6200be8caa Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Mon, 13 Feb 2023 18:23:46 -0500 Subject: [PATCH] sort acl file based on filename --- Makefile | 2 +- sort_acl.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100755 sort_acl.sh 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'