#!/bin/bash ######################################################################## # Author: Fred (support@qo-op.com) # Version: 2020.03.18 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ######################################################################## # \\/// # qo-op ############# ########################## ####################################### #################################################### ######################################################################## ######################################################################## # check /tmp/cmd_received_$SOURCEH and /tmp/cmd_SPAM_$SOURCEH within 1mn # Remove older than a minute received COMMAND find /tmp -cmin +1 -type f -name "cmd_received_*" -exec rm -f '{}' \; 2>/dev/null # Filter Acknowlegement if [[ "$CMD" != "ACK" && "$CMD" != "DELIVERED" && "$CMD" != "PENDING" ]]; then # Still less than a minute with same $SOURCEH if [[ -f "/tmp/cmd_received_$SOURCEH" ]]; then # Create SPAM file => Stop answering if [[ ! -f "/tmp/cmd_SPAM_$SOURCEH" ]]; then echo $(date) > "/tmp/cmd_SPAM_$SOURCEH" fi return 1 fi echo "$COMMAND" > "/tmp/cmd_received_$SOURCEH" # Remove SPAM flag older than one day find /tmp -ctime +1 -type f -name "cmd_SPAM_*" -exec rm -f '{}' \; 2>/dev/null else # THIS IS AN AKNOWLEGEMENT return 1 fi # Remove SPAM flag older than one day find /tmp -ctime +1 -type f -name "cmd_SPAM_*" -exec rm -f '{}' \; 2>/dev/null return 0