*** See this post: viewtopic.php?p=2049632#p2049632 ***
I have some conky windows with all my ipcamera's. The camera's store pictures into my pure-ftp server. This ftp server keeps a log on PUT commands. I made a script that watches this log file on modification and if so it will read out the last line of that log and shows an overlay window on the specific camera that stored the pictures (ip adress) and plays a sound. Since the last update a day ago suddenly inotifywait does not react on modification of the log file anymore and i can't find out what the problem could be!? Does anyone know if there has been some changes to inotifywait ??
script
Code: Select all
#!/bin/bash
#
# Enable debugging on part of script = set -xe'
# Disable debugging on part of script= set +xe
#
# Err number = $?
# Script filename = $0
# Script PID = $$
#
#------------------------------------------------------------------------
# This script watches /var/log/pure-ftpd/transfer.log and
# presents an overlay window on ipcam when an event happens
#------------------------------------------------------------------------
#
#set -xe
#
# '--window-id=OVERLAY' MUST BE TE FIRST ARG !!!
#
#
# Use nothing = standard output, -D for debugging, -DD more debugging, -q for no output
args0=""
#
args1="--window-id=OVERLAY -i 15 -a top_right"
args2="--c /home/admin/.conky/MyPanels/ipcam_snapshots/ipcam_overlay_"
log="/var/log/pure-ftpd/transfer.log"
ftpansw="0"
ipcam="0.0.0.0"
lastlogline=""
# Show starting variables
echo -e "\n---------------------------------------------------------------------------------------------------"
echo " Watching Pure-FTP log on events, then start overlay on IP Camera's"
echo -e "---------------------------------------------------------------------------------------------------"
echo " log : $log"
echo " lastlogline : $lastlogline"
echo " args : $args"
echo " ftpansw : $ftpansw"
echo " ipcam : $ipcam"
echo -e "---------------------------------------------------------------------------------------------------\n\nStart watching $log ...\n"
# Function to show ERROR overlays
overlays_error () {
ipcam="ERROR"
ftpansw="Error in FTP log ! "
export FTPANSW=$ftpansw
echo -e "\nconky: message from script: ipcam_overlay.sh \033[31m"
echo -e " Logbestand $log is leeg of laatste regel is corrupt! Controleer het bestand."
echo -e " Programma blijft doordraaien. Let op melding op uw camerabeeld!\033[00m\n"
allargs1=$args1" -x -670 -y -600 "$args2$ipcam".conky &" # Oprit
allargs2=$args1" -x -670 -y -405 "$args2$ipcam".conky &" # Washok
allargs3=$args1" -x -670 -y -213 "$args2$ipcam".conky &" # Aanbouw
allargs4=$args1" -x -670 -y -22 "$args2$ipcam".conky &" # Shelby
echo "conky: -----| Overlays_error Args |-----"
echo "allargs : "$allargs1
echo "allargs : "$allargs2
echo "allargs : "$allargs3
echo "allargs : "$allargs4
echo "-----------------------------------------------"
conky $allargs1; conky $allargs2; conky $allargs3; conky $allargs4 # Start overlays
conkykill=$(sudo pkill -fe "conky --window-id=OVERLAY") # Kill overlays
echo "pkill:" $conkykill
}
# Function to show IPCam overlays
overlays_ipcam () {
ftpansw=$(echo "$lastlogline" | gawk -F " " '{print $8}')
export FTPANSW=$ftpansw
play -q -v 0.2 /home/admin/.conky/MyPanels/ipcam_snapshots/motion.wav pitch 350 speed 1.8
echo -e "ftpansw : $ftpansw\nipcam : $ipcam"
allargs=$args0" "$args1" "$args2$ipcam".conky"
echo "allargs : "$allargs
conky $allargs
conkykill=$(sudo pkill -fe "conky --window-id=OVERLAY")
echo "pkill: "$conkykill
}
sudo inotifywait --quiet --monitor --event modify "$log" | while read; do
echo -e "********* Event is happening in "$log
lastlogline=$(sudo tail -n1 "$log")
lastlogIPLen=$(sudo tail -n1 "$log" | awk -F " " '{print $1}')
if [[ -n "$lastlogline" ]]; then #--- logline NOT EMPTY = GOOD
if [[ ${#lastlogIPLen} -ge 7 ]]; then #--- length IP correct = GOOD
ipcam=$(echo "$lastlogline" | gawk -F " " '{print $1}')
if [[ "$ipcam" =~ ^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then #--- IP is OK!
overlays_ipcam
else #--- else IP seems NOT OK! = BAD
overlays_error
exit
fi
else #--- else length IP not correct = BAD
overlays_error
exit
fi
else #--- else lastlogline EMPTY = BAD
overlays_error
fi
echo -e "conky: Still watching ...\n"
#exit
#break
#kill -n 15 $$
done
unset