# # $Header: la_to_fs.awk,v 1.1 89/05/20 11:24:53 qjb Exp $ # $Source: /afs/athena.mit.edu/mit/qjb/scripts/RCS/la_to_fs.awk,v $ # $Author: qjb $ # # This awk script converts the output of fs list_acl into a series of # fs commands that will the acls of the directories. It works correctly # when more than one directory is given. # # Usage: fs la [dir dir dir] | awk -f # BEGIN { normal = 1; negative = 2; access = 0; lasterror = -2; acls_printed = 0; } { if (! $NF) { access = 0; if (lasterror != NR - 1) { if (!acls_printed) printf(" -acl system:anyuser none"); printf(" -clear\n"); } } else if ($1 == "fs:") { printf("#\n# %s\n#\n", $0); lasterror = NR; } else if ($1 == "Access") { printf("fs sa -dir %s", $4); acls_printed = 0; } else if ($1 == "Normal") access = normal; else if ($1 == "Negative") { access = negative; printf(" -negative"); } else if (access) { printf(" -acl %s %s", $1, $2); acls_printed = 1; } } END { if (lasterror != NR) { if (!acls_printed) printf(" -acl system:anyuser none"); printf(" -clear\n"); } }