📜 ⬆️ ⬇️

Asterisk Conference - create through mail


A conference cola is a very convenient and necessary service. It’s easy to collect participants (they dial up and connect themselves), the number of subscribers is almost unlimited (until the channel ends), telephone lines are free (if you have conferences on a separate sip number with an unlimited number of sessions.) application. And if the admin has applications for the sea, and even got sick (fell asleep, got drunk, died), then the creation of a conference stake is being dragged out. In addition, the password for regular conferences is also permanent. And in this case, the former participant will always be able to connect to it, or even gather a rally there, which is good. These are the thoughts that were spinning in my head after the pompous announcement of the company about the launch of conference stakes. And it was decided to automate the creation of newsgroups.

But! We will do this through the mail. The scheme is as follows. The user writes a letter with a specific topic to a specific address. After some time, he returns the answer with the data of the newsgroup.
Characters and performers:
Crontab - Chronogolic. Constantly feels the need to keep track of time, runs the bash script and related commands.
Fetchmail - An unhappy proletarian who is constantly being chased to the post office and, if found to be the poor fellow, is forced to drag very heavy messages to the server with the help of the MTA.
Sendmail is the same MTA with which fetchmail drags letters to the server.
Sendemail is a frivolous profurset, who, thinking that she sends love notes to users, in fact, being cruelly deceived by the bash script, sends a response with the conference settings.
Bash script - the malicious exploiter of all the above characters. Nevertheless, it also does not roll in oil, processes received letters, analyzes them and creates conferences.

First you need to install and configure fetchmail. And sendmail can be simply installed, configured for our purposes is optional. I was guided by this article (http://www.opennet.ru/base/net/fetchmail_setup.txt.html) which I wish for you. For those who have no time: in the user profile, which has rights to / etc / asterisk, you need to create a .fetchmailrc file in which to set the settings for connecting to the server:

Example.
poll address.mail.server port 995 proto POP3 user 'account' pass 'password' ssl 

You can check the connection with the command fetchmail -k. In the case of correct settings at / var / spool / mail / username, the sent letter will appear.
')
Further. Crontab runs a script every 10 minutes. And around 12 at night, it erases the conference counter and the file with temporary conferences.

* / 10 * * * * cd / opt / bbb / meetings / && ./mkmeet
59 23 * * * cat / dev / null> /etc/asterisk/meetme_additional.conf && cat / dev / null> / opt / neoflex / metings / meetcount

Well, our cruel exploiter:

 #!/bin/bash #       fetchmail -F #  ,      echo | sed -n '/From:/p; /Subject:/p' /var/spool/mail/username | sed s'/From/from/'g | sed s'/Subject/subject/'g | sed 's/ *(.*)//; s/>.*//; s/.*[:<] *//' | sed s'/\:/ /'g >> tmp.file #    bdpath=/opt/bbb/meetings #  num=(`cat $bdpath/tmp.file`) #   meetc=(`cat $bdpath/meetcount`) #     ,  tmpconf = 5000,    if [[ "$meetc" -le "0" ]]; then tmpconf="5000" echo "${tmpconf[$c]}" > meetcount else tmpconf=$meetc fi #   a=0 b=`expr $a + 1` c=0 #  while [ ${num[$a]} ] do #  FLOOR=10000 pass=0 while [ "$pass" -le $FLOOR ] do pass=$RANDOM done #   mail=${num[$a]} subj="${num[$b]}" cut=`echo ${num[$a]} | sed 's/^.*@//'` #     "",    . if [[ "$cut" != "firma.ru" ]]; then subj="khuy" fi    meetme,      . if [[ "$subj" == "meetme" ]]; then echo "conf => ${tmpconf[$c]},$pass" >> /etc/asterisk/meetme_additional.conf /usr/sbin/asterisk -rx "reload" sendemail -f asterisk@firma.ru -t $mail -o message-charset=utf-8 -o message-content-type=html -u "Conference call was successfully created" -m "<p> \ </p><p>   - 8(XXX)XXX-XXXX<br>   - 550<br>  - ${tmpconf[$c]}<br> - $pass<br>  \ https://wiki.firma.ru/pages/viewpage.action?pageId=28066722<p><b>!!!     23:59  .</b></p>" -s mail.firma.ru -xu asterisk@firma.ru -xp "password" echo `date` $mail ${tmpconf[$c]} >> /var/log/tmpmeetings.log tmpconf=`expr ${tmpconf[$c]} + 1` fi a=`expr $a + 2` b=`expr $b + 2` done rm tmp.file echo "$tmpconf" > meetcount cat /dev/null > /var/spool/mail/root 


That's all. Now we are sending at least a pompous statement about the creation of temporary teleconferences and ... To your taste :))

Source: https://habr.com/ru/post/182270/


All Articles