История изменений
Исправление constin, (текущая версия) :
Окончательная версия
#!/bin/bash
monitor() {
inotifywait -m -r -e attrib --format "%w%f" --fromfile /etc/default/inotifywait | while read TARGETFILE
do
TARGETFILE="${TARGETFILE//\ /\\\ }"
#echo $TARGETFILE #for debug
if [[ -f $TARGETFILE ]]; then
[ "$(stat --format=%a $TARGETFILE)" -ne 660 ] && chmod 00660 $TARGETFILE
elif [[ -d $TARGETFILE ]]; then
#[ "$(stat --format=%a $TARGETFILE)" -ne 770 ] && chmod 00770 $TARGETFILE
echo "$(date) ${TARGETFILE} is folder" >> /var/log/monitor.log
else
echo "$(date) Something goes wrong with variable: ${TARGETFILE}" >> /var/log/monitor.log
fi
done
}
monitor &
Исправление constin, :
Окончательная версия
#!/bin/bash
monitor() {
inotifywait -m -r -e attrib --format "%w%f" --fromfile /etc/default/inotifywait | while read TARGETFILE
do
TARGETFILE="${TARGETFILE//\ /\\\ }"
#echo $TARGETFILE #for debug
if [[ -f $TARGETFILE ]]; then
[ "$(stat --format=%a $TARGETFILE)" -ne 660 ] && chmod 00660 $TARGETFILE
elif [[ -d $PASSED ]]; then
#[ "$(stat --format=%a $TARGETFILE)" -ne 770 ] && chmod 00770 $TARGETFILE
echo "$(date) ${TARGETFILE} is folder" >> /var/log/monitor.log
else
echo "$(date) Something goes wrong with variable: ${TARGETFILE}" >> /var/log/monitor.log
fi
done
}
monitor &
Исходная версия constin, :
Окончательная версия
#!/bin/bash
monitor() {
inotifywait -m -r -e attrib --format "%w%f" --fromfile /etc/default/inotifywait | while read TARGETFILE
do
TARGETFILE="${TARGETFILE//\ /\\\ }"
#echo $TARGETFILE #for debug
if [[ -f $TARGETFILE ]]; then
[ "$(stat --format=%a $TARGETFILE)" -ne 660 ] && chmod 00660 $TARGETFILE
elif [[ -d $PASSED ]]; then
#[ "$(stat --format=%a $TARGETFILE)" -ne 770 ] && chmod 00770 $TARGETFILE
echo "$(date) ${TARGETFILE} is folder" >> /var/log/monitor.log
else
echo "$(date) Something goes wrong with variable: ${TARGETFILE}" >> /var/log/monitor.log
fi
done
}
monitor