Ajout des script pour asterisk
This commit is contained in:
parent
e9bae60ef9
commit
124d4a83e1
12 changed files with 286 additions and 0 deletions
21
sip/limit_call.sh
Executable file
21
sip/limit_call.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
printf -v limit "%q" "$1"
|
||||
printf -v num "%q" "$2"
|
||||
date=`date +"%Y-%m-01"`
|
||||
num_call=`psql -h pgsql.adm.crans.org -U crans django --no-align -c "SELECT count(DISTINCT dst) FROM voip_history WHERE date>'$date' AND dst LIKE '+%'" | tail -n 2 | head -n 1`
|
||||
if [[ $num_call = "" ]]; then
|
||||
echo -n DENY
|
||||
exit -1
|
||||
fi
|
||||
if [[ $num_call -ge $limit ]]; then
|
||||
result=$((`psql -h pgsql.adm.crans.org -U crans django --no-align -c "SELECT dst FROM voip_history WHERE date>'$date' AND dst='$num'" | wc -l` -2))
|
||||
if [[ $result -ge 1 ]]; then
|
||||
echo -n ALLOWED
|
||||
else
|
||||
echo -n DENY
|
||||
fi
|
||||
else
|
||||
echo -n ALLOWED
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue