@PitzKey
Thank you for your help. I have made the recommended changes. In addition, I issued the following commands in my cli:
chmod + x busytimescript.sh
chown asterisk:asterisk busytimescript.sh
I also added a line to the end of the script so I could see if it is working (because it isn’t yet…)
Here is the updated script:
#!/bin/bash
phone_number=“$1”
if [ -z “$phone_number” ]; then
echo “Usage: $0 <phone_number>”
exit 1
fi
Increment the counter for the phone number
value=$(redis-cli INCR “$phone_number”)
Set/refresh expiration to 300 seconds
redis-cli EXPIRE “$phone_number” 300 >/dev/null
Check rate and print action
if [ “$value” -ge 3 ]; then
echo “block”
else
echo “continue”
fi
Uncomment the following to log and troubleshoot
echo “$phone_number” " " “$value” >> /home/asterisk/CustomScripts/busylog.txt
and here is the entire extensions_custom.conf from my GUI:
[from-internal-custom]
exten=> *00001,hint,DAHDI/1
exten=> *00002,hint,DAHDI/2
exten=> *00003,hint,DAHDI/3
exten=> *00004,hint,DAHDI/4
[time-based-block]
exten => s,1,Noop(Check if we need to prevent ${CALLERID(all)} from reaching the queue)
same => n,GotoIf($[“${SHELL(/home/asterisk/CustomScripts/busytimescript.sh ${CALLERID(num)})}”=“block”]?block)
same => n,Return()
same => n(block),Goto(ivr-15,s,1)
When I run the script from the command line it adds to my logfile.
When we receive a call, it does not.
My inbound routes are set to Custom Destinations: Created to redirect spam calls
My Custom Destination Target is: time-based-block,s,1
The Custom Destination returns to my time conditions (in this case, Special Closing).
We receive calls, I just can’t get the incrementer to work. Would you please check to see if I have done this correctly?
Thank you again for your help!