Hi. I would like to blacklist a few callers and I have been using the *CLI> database put blacklist 1234 "annoying callers". Instead of putting the same command for every user is there any way to have a file? Ideally a file in /opt that I would update the blacklisted numbers (add,remove). Is there anything like that, please?<br>
On Sat, 27 Aug 2016, tux john wrote:> Hi. I would like to blacklist a few callers and I have been using the > *CLI> database put blacklist 1234 "annoying callers". Instead of putting > the same command for every user is there any way to have a file? Ideally > a file in /opt that I would update the blacklisted numbers (add,remove). > Is there anything like that, please?If you are happy with the way blacklisting with the Asterisk database works, how about a shell script that loads all of the entries in your blacklist file? Other alternatives involve modifying your dial plan. If you are comfortable with that then you can consider alternatives like an AGI that reads your text file and sets a channel variable. If you need more 'immediacy' maybe storing the blacklist in a 'real' database is more appropriate -- especially if you want the users to maintain their own black list via a web page. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST https://www.linkedin.com/in/steve-edwards-4244281
Hi. Thanks a lot for the reply. Script seems good, but i am stuck on how to make it. On 27/8/2016 10:48 ??, Steve Edwards wrote:> On Sat, 27 Aug 2016, tux john wrote: > >> Hi. I would like to blacklist a few callers and I have been using the >> *CLI> database put blacklist 1234 "annoying callers". Instead of >> putting the same command for every user is there any way to have a >> file? Ideally a file in /opt that I would update the blacklisted >> numbers (add,remove). Is there anything like that, please? > > If you are happy with the way blacklisting with the Asterisk database > works, how about a shell script that loads all of the entries in your > blacklist file? > > Other alternatives involve modifying your dial plan. If you are > comfortable with that then you can consider alternatives like an AGI > that reads your text file and sets a channel variable. > > If you need more 'immediacy' maybe storing the blacklist in a 'real' > database is more appropriate -- especially if you want the users to > maintain their own black list via a web page. >
Here is a quick and dirty bash script to do it that I wrote you. #!/bin/bash if ( asterisk -rx "database deltree blacklist") then echo "Blacklist Cleared" else err "ERROR Failed to clear Blacklist, Exiting." exit 1; fi while IFS=, read TN REASON do if ( asterisk -rx "database put blacklist \"${TN}\" \"${REASON}\"") then echo "Inserted $TN $REASON to Blacklist" else err "ERROR Insert Failed on $TN." exit 1; fi done < blacklist.csv unset IFS It reads from the file blacklist.csv in the same directory with the format of NUMBER,"DESCRIPTION/REASON" On Sat, Aug 27, 2016 at 8:59 AM, tux john <atux at null.net> wrote:> Hi. I would like to blacklist a few callers and I have been using the > *CLI> database put blacklist 1234 "annoying callers". Instead of putting > the same command for every user is there any way to have a file? Ideally a > file in /opt that I would update the blacklisted numbers (add,remove). Is > there anything like that, please? > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016 > http://www.asterisk.org/community/astricon-user-conference > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. ---Heinlein -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20160829/f3ac8077/attachment.html>
On Sat, 2016-08-27 at 17:59 +0200, tux john wrote:> Hi. I would like to blacklist a few callersExample: callers with CallerID 0123456789, 9876543210 and 7410258963 are sent to tt-monkeys. Callers from area code 555 are also blocked. In "extensions.conf" file add #include "blacklist.conf" In "blacklist.conf" exten => s/0123456789,1,playback(tt-monkeys) exten => s/9876543210,1,playback(tt-monkeys) exten => s/7410258963,1,playback(tt-monkeys) exten => s/_555XXXXXXX,1,playback(tt-monkeys) .... ... .. .