I have a script I periodically run that reapplies FACL and chmod permissions for home directories of gameservers I run.
The script first issues a home-directory wide recursive chmod, and then chmods certain files to specific values (first all files are set to 770, then additional changes are made).
Relevant bit from the script:
for d in */; do
< server verification and type checking >
chmod -R 770 ${d%/}
chmod 771 ${d%/}
chmod 775 ${d%/}/$gamedir
< ... chmodding unrelated game asset directories for webserver access ... >
for k in "${BLOCK_DIRS[@]}"; do
if [ -d "$k" ]; then
echo -e "${CYAN}Checking $(pwd)/$k...${NC}"
echo -e "${RED}Debug: chmod -R 1700 $(pwd)/$k${NC}"
chmod -v 1700 "$(pwd)/$k"
chmod -R 0700 "$(pwd)/$k"
fi
done
done
Sample output:
mode of ‘/home/servers/tf_test/tf/../bin’ changed from 0770 (rwxrwx---) to 1700 (rwx-----T)
However, directory permissions only change for the last server in the first loop. That is, there are 9 servers in the first for loop, and only the last one gets changes by the inner for loop.
Same commands issued manually work absolutely fine. What am I doing wrong?
(also, this is my first question - if I didn't say something important - please correct me, I'll edit the question accordingly)