diff --git a/Dockerfile b/Dockerfile index 316c8fd..b26abc8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,16 @@ FROM dougbtv/asterisk14 -RUN yum install -y perl-Digest-MD5 perl-libwww-perl perl-LWP-Protocol-https sox mpg123 which python-pip +RUN yum install -y perl-Digest-MD5 perl-libwww-perl perl-LWP-Protocol-https sox mpg123 which python-pip wget unzip RUN pip install pyst2==0.5.0 -RUN curl -L https://github.com/kelseyhightower/confd/releases/download/v0.15.0/confd-0.15.0-linux-amd64 > /usr/local/bin/confd && chmod +x /usr/local/bin/confd +ENV REMCO_VER 0.11.1 +RUN wget https://github.com/HeavyHorst/remco/releases/download/v${REMCO_VER}/remco_${REMCO_VER}_linux_amd64.zip && \ + unzip remco_${REMCO_VER}_linux_amd64.zip && rm remco_${REMCO_VER}_linux_amd64.zip && \ + mv remco_linux /bin/remco COPY conf/*.conf /etc/asterisk/ -COPY conf/*.conf.tmpl /etc/confd/templates/ -COPY conf/*.conf.toml /etc/confd/conf.d/ COPY agi/* /var/lib/asterisk/agi-bin/ -CMD confd -onetime -backend env && asterisk -fvv +COPY remco.config /etc/remco/config +COPY conf/*.conf.tmpl /etc/remco/templates/ + +ENTRYPOINT ["remco"] diff --git a/conf/extensions.conf b/conf/extensions.conf index 85ed73d..ca4209e 100644 --- a/conf/extensions.conf +++ b/conf/extensions.conf @@ -4,3 +4,7 @@ exten => s,1,Answer() same => n,Monitor(wav,rec-${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}-${CALLERID(num)}) same => n,agi(googletts.agi,"This is BGP.WTF abuse phone number. This call will be recorded.",en) same => n,agi(phonetab.agi,/etc/asterisk/phonetab) + +[internal] +exten => s,1,Answer() +same => n,agi(googletts.agi,"Oh shit what up",en) diff --git a/conf/sip.conf.tmpl b/conf/sip.conf.tmpl index ad093ab..c486354 100644 --- a/conf/sip.conf.tmpl +++ b/conf/sip.conf.tmpl @@ -1,7 +1,8 @@ [general] context=sip nat=force_rport,comedia -register => {{getv "/asterisk/trunk/username"}}:{{getv "/asterisk/trunk/secret"}}@sip.2call.pl +allowguest=no +register => {{ getv ("/asterisk/trunk/username") }}:{{ getv ("/asterisk/trunk/secret") }}@sip.2call.pl [trunk-out] type=friend @@ -17,9 +18,16 @@ qualify=no fromdomain=sip.2call.pl host=sip.2call.pl -defaultuser={{getv "/asterisk/trunk/username"}} -fromuser={{getv "/asterisk/trunk/username"}} -username={{getv "/asterisk/trunk/username"}} -user={{getv "/asterisk/trunk/username"}} +defaultuser={{ getv ("/asterisk/trunk/username") }} +fromuser={{ getv ("/asterisk/trunk/username") }} +username={{ getv ("/asterisk/trunk/username") }} +user={{ getv ("/asterisk/trunk/username") }} +secret={{ getv ("/asterisk/trunk/secret") }} -secret={{getv "/asterisk/trunk/secret"}} +{% for client in ls("/peers") %} +[{{ client }}] +type=peer +host=dynamic +secret={{ getv(printf("/peers/%s", client)) }} +context=internal +{% endfor %} diff --git a/conf/sip.conf.toml b/conf/sip.conf.toml deleted file mode 100644 index 8125d1d..0000000 --- a/conf/sip.conf.toml +++ /dev/null @@ -1,6 +0,0 @@ -[template] -src = "sip.conf.tmpl" -dest = "/etc/asterisk/sip.conf" -keys = [ - "/asterisk", -] diff --git a/docker-compose.yml b/docker-compose.yml index 0afe849..07cfc13 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,3 +25,4 @@ services: volumes: - "./phonetab:/etc/asterisk/phonetab" - "./moh:/var/lib/asterisk/moh" + - "./peers.yml:/etc/asterisk/peers.yml:ro" diff --git a/remco.config b/remco.config new file mode 100644 index 0000000..422f8ab --- /dev/null +++ b/remco.config @@ -0,0 +1,27 @@ +log_level = "debug" +log_format = "text" + +[[resource]] +name = "asterisk" + +[resource.exec] + command = "/usr/sbin/asterisk -fvv" + kill_signal = "SIGTERM" + reload_signal = "SIGHUP" + kill_timeout = 10 + splay = 10 + +[[resource.template]] + src = "/etc/remco/templates/sip.conf.tmpl" + dst = "/etc/asterisk/sip.conf" + reload_cmd = "if [[ -e /var/run/asterisk/asterisk.ctl ]]; then asterisk -rx reload ; fi" + + [resource.backend] + [resource.backend.file] + filepath = "/etc/asterisk/peers.yml" + watch = true + interval = 5 + keys = ["/peers", "/asterisk"] + + [resource.backend.env] + keys = ["/asterisk"]