#!/bin/bash
#                      /usr/local/bin/executable
# http://crystalfaeries.net/posix/bin/executable
# celeste:crystalfaery EXECUTABLE 2020-08-17 13:19:59+00:00

#	echo "Shall I normalize file ownership and permissions"
#	echo "in the script executable directories"
#	echo -n "/usr/local/bin and /usr/lib/cgi-bin ? (NO/yes):"
#	read answer
#	if [ "X$answer" != "Xyes" ]
#		then exit 0	#	unless user answers "yes" we just quit
#	fi

cd	/usr/local/bin	|| exit 1
user=root
group=root	# default in case following line fails
group=staff
dirs=0775
files=775

sudo find . \! -iname '*.txt' \! -iname '*.htm*'	-type d \! -perm $dirs	-print -exec chmod $dirs	{} \;
sudo find . \! -iname '*.txt' \! -iname '*.htm*'	-type f \! -perm $files	-print -exec chmod $files	{} \;
sudo find . \! -iname '*.txt' \! -iname '*.htm*' \!	-user	$user		-print -exec chown $user:$group	{} \;
sudo find . \! -iname '*.txt' \! -iname '*.htm*' \!	-group	$group		-print -exec chgrp $group	{} \;
sudo chmod $files readme.txt	# unique local hack: an executable text file which displays itself :-)

files=664
sudo find . \( -iname '*.txt' -o -iname '*.htm*' \) \!	-user	$user		-print -exec chown $user:$group {} \;
sudo find . \( -iname '*.txt' -o -iname '*.htm*' \) \!	-group	$group		-print -exec chgrp $group {} \;
sudo find . \( -iname '*.txt' -o -iname '*.htm*' \)	-type f \! -perm $files	-print -exec chmod $files {} \;

exit $?
