#apt-get install unixodbc odbc-postgresql
#cat /etc/odbcini.ini [PostgreSQL ANSI] Description = PostgreSQL ODBC driver (ANSI version) Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so Debug = 0 CommLog = 1 UsageCount = 1 [PostgreSQL Unicode] Description = PostgreSQL ODBC driver (Unicode version) Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so Debug = 0 CommLog = 1 UsageCount = 1
# cat /etc/odbc.ini [config] Description = PostgreSQL connection to 'asterisk' database Driver = PostgreSQL ANSI Database = asterisk Servername = 192.168.204.167 UserName = asterisk Password = Uidj$5tuYF Port = 5432 Protocol = 9.1 KSQO = No ReadOnly = No RowVersioning = No ShowSystemTables = No ShowOidColumn = No FakeOidIndex = No ConnSettings =
isql config
+---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL>
[asterisk] enabled => yes dsn => config username => asterisk password => Uidj$5tuYF pre-connect => yes
CREATE TABLE zones ( def smallint NOT NULL, start integer NOT NULL, finish integer NOT NULL) WITHOUT OIDS;
#!/bin/bash REGION='' echo "COPY zones FROM stdin;" > zones.sql wget -q http://www.rossvyaz.ru/docs/articles/DEF-9x.html -O DEF-9x.html cat DEF-9x.html|iconv -f cp1251 -t utf8|grep -i $REGION|awk '{print($3"\t"$6"\t"$9)}' >> zones.sql rm DEF-9x.html wget -q http://rossvyaz.ru/docs/articles/ABC-3x.html -O ABC-3x.html cat ABC-3x.html |iconv -f cp1251 -t utf8|grep -i $REGION|awk '{print($3"\t"$6"\t"$9)}' >> zones.sql rm ABC-3x.html wget -q http://rossvyaz.ru/docs/articles/ABC-4x.html -O ABC-4x.html cat ABC-4x.html |iconv -f cp1251 -t utf8|grep -i $REGION|awk '{print($3"\t"$6"\t"$9)}' >> zones.sql rm ABC-4x.html wget -q http://rossvyaz.ru/docs/articles/ABC-8x.html -O ABC-8x.html cat ABC-8x.html |iconv -f cp1251 -t utf8|grep -i $REGION|awk '{print($3"\t"$6"\t"$9)}' >> zones.sql rm ABC-8x.html echo "\." >> zones.sql psql -U asterisk -d asterisk -c 'DELETE FROM zones' psql -U asterisk -d asterisk -f zones.sql rm zones.sql
[ZONES] prefix=CHECK dsn=asterisk readhandle=asterisk readsql=SELECT count(*) from zones where def='${ARG1:1:3}' and start<='${ARG1:4}' and finish>='${ARG1:4}'
[zones] include => template
[meggorod] include => template
[template] exten => _8XXXXXXXXXX,1,GotoIf($["${CHECK_ZONES(${EXTEN})}" = "1"]?4) same => 2,GotoIf($["${CONTEXT}" = "meggorod"]?6:error,1) same => 3,Hangup() same => 4,Dial(SIP/prov1/${EXTEN},30,tTS(3600)gxX) same => 5,Hangup() same => 6,Dial(SIP/prov2/${EXTEN},30,tTS(3600)gxX) exten => error,1,Playback(an-error-has-occured) exten => error,n,Hangup()
Source: https://habr.com/ru/post/148401/
All Articles