Hi,
This I can understand:
# Set $GROUP Variable
GROUP=`ls -ld $i | awk '{print $4}'`;
But this seems to be unneeded, it always sets it to a group that it already is:
# Set Project ROOT Group ownership
chgrp $GROUP $i;
The following could do something you didn't think of:
# Set Project ROOT /proj/* to 2751
chmod 2751 $i;
All files and directories in /proj/ (not recursive) will get 2751 as permission. Do you also want this to be true for files??
I don't seem to understand your problem:
it's changing everything under /proj/* to the first group it gets assigned.
If /proj/dirone has internet as group, all dirs and files under /proj/dirone will have internet as group after you run the script.
Code:
Original filestructure:
drwxr-xr-x 5 druuna internet 4096 Oct 12 16:31 dirone
drwxr-xr-x 5 druuna users 4096 Oct 12 16:31 dirthree
drwxr-xr-x 5 druuna visitor 4096 Oct 12 16:31 dirtwo
-rw-r--r-- 1 druuna internet 0 Oct 12 16:31 fileone
-rw-r--r-- 1 druuna users 0 Oct 12 16:31 filethree
-rw-r--r-- 1 druuna visitor 0 Oct 12 16:31 filetwo
dirone:
total 12
drwxr-xr-x 2 druuna internet 4096 Oct 12 16:31 dironeone
drwxr-xr-x 2 druuna users 4096 Oct 12 16:31 dironethree
drwxr-xr-x 2 druuna visitor 4096 Oct 12 16:31 dironetwo
-rw-r--r-- 1 druuna internet 0 Oct 12 16:31 fileone
-rw-r--r-- 1 druuna users 0 Oct 12 16:31 filethree
-rw-r--r-- 1 druuna visitor 0 Oct 12 16:31 filetwo
dirtwo:
total 12
drwxr-xr-x 2 druuna internet 4096 Oct 12 16:31 dirtwoone
drwxr-xr-x 2 druuna users 4096 Oct 12 16:31 dirtwothree
drwxr-xr-x 2 druuna visitor 4096 Oct 12 16:31 dirtwotwo
-rw-r--r-- 1 druuna internet 0 Oct 12 16:31 fileone
-rw-r--r-- 1 druuna users 0 Oct 12 16:31 filethree
-rw-r--r-- 1 druuna visitor 0 Oct 12 16:31 filetwo
Dirstructure after running the script:
drwxr-s--x 5 druuna internet 4096 Oct 12 16:31 dirone
drwxr-s--x 5 druuna users 4096 Oct 12 16:31 dirthree
drwxr-s--x 5 druuna visitor 4096 Oct 12 16:31 dirtwo
-rwxr-s--x 1 druuna internet 0 Oct 12 16:33 fileone
-rwxr-s--x 1 druuna users 0 Oct 12 16:33 filethree
-rwxr-s--x 1 druuna visitor 0 Oct 12 16:33 filetwo
dirone:
total 12
drwxrwxr-x 2 druuna internet 4096 Oct 12 16:31 dironeone
drwxrwxr-x 2 druuna internet 4096 Oct 12 16:31 dironethree
drwxrwxr-x 2 druuna internet 4096 Oct 12 16:31 dironetwo
-rw-rw-r-- 1 druuna internet 0 Oct 12 16:33 fileone
-rw-rw-r-- 1 druuna internet 0 Oct 12 16:33 filethree
-rw-rw-r-- 1 druuna internet 0 Oct 12 16:33 filetwo
dirtwo:
total 12
drwxrwxr-x 2 druuna visitor 4096 Oct 12 16:31 dirtwoone
drwxrwxr-x 2 druuna visitor 4096 Oct 12 16:31 dirtwothree
drwxrwxr-x 2 druuna visitor 4096 Oct 12 16:31 dirtwotwo
-rw-rw-r-- 1 druuna visitor 0 Oct 12 16:33 fileone
-rw-rw-r-- 1 druuna visitor 0 Oct 12 16:33 filethree
-rw-rw-r-- 1 druuna visitor 0 Oct 12 16:33 filetwo
As you can see, all files in dirone have internet as group after running the script and all files and dirs in dirtwo have visitor as group. Script does exactly what it is supposed to do.