mgd's picture

After much frothing around and testing, here is the final script. Note, I just check the permissions on poller-error.log because I found that  if the permissions are wrong on this file, they are wrong on all the files in /var/log/cacti. Also, the -R, recursive may be a little overkill since there are no sub-folders in this directory. Also, for those "scriptors" out there, pay attention to the spaces in the if statement...all are necessary. Also, I set the permissions in /var/log/cacti to be 775 for cacti user and www-data group. Also, for some reason, I had to specify the full path in my script for the executables such as "chmod".

#!/bin/bash
PATH=/var/log/cacti
FILE=/var/log/cacti/poller-error.log
PERM=`/usr/bin/stat -c "%a" $FILE`
if [[ "$PERM" -ne "775" ]];
then
 /bin/chown -R cacti:www-data $PATH
 /bin/chmod -R 775 $PATH
fi