#
# Recursive script for following down a directory tree and changing the permissions of all files found.
#
# ex: suninstchmod
#

OWNER=`grep :0: /etc/group | cut -f4 -d: | cut -f1 -d,`
OWNER=${OWNER:=root}
GROUP=`grep :0: /etc/group | cut -f1 -d:`

for x1 in `ls -1`
do
  if [ -f $x1 ]				#Check for regular file
   then
#   echo `pwd`/$x1			#Display name of file just found
    j1=`echo $x1 | tr '[.]' '[x]'`	#Check for a DOT in file name
    if [ ${x1} = ${j1} ]; then		#If we did not find one, then...
      chown $OWNER $x1			#Change owner to Root
      chgrp $GROUP $x1			#Change gropu to Root also
      chmod 5775 $x1 >/dev/null 2>&1	#Change mode to be executable
    else
      chmod 664 $x1 >/dev/null 2>&1	#Otherwise change to be 'rw-rw-r--'
    fi
#   ls -l $x1				#Display found name
  elif [ -d $x1 ]			#Check for a directory
   then
    cd $x1				#Change to directory
    $0					#Recurse into directory and do again
    cd ..				#Change back to original directory
  fi
done
