{"action":"opened","issue":{"url":"https://api.github.com/repos/openwrt/telephony/issues/369","repository_url":"https://api.github.com/repos/openwrt/telephony","labels_url":"https://api.github.com/repos/openwrt/telephony/issues/369/labels{/name}","comments_url":"https://api.github.com/repos/openwrt/telephony/issues/369/comments","events_url":"https://api.github.com/repos/openwrt/telephony/issues/369/events","html_url":"https://github.com/openwrt/telephony/issues/369","id":359405660,"node_id":"MDU6SXNzdWUzNTk0MDU2NjA=","number":369,"title":"Asterisk: Time to remove the \"flash filling\" config clutter and move it to uci","user":{"login":"LipkeGu","id":2057932,"node_id":"MDQ6VXNlcjIwNTc5MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/2057932?v=4","gravatar_id":"","url":"https://api.github.com/users/LipkeGu","html_url":"https://github.com/LipkeGu","followers_url":"https://api.github.com/users/LipkeGu/followers","following_url":"https://api.github.com/users/LipkeGu/following{/other_user}","gists_url":"https://api.github.com/users/LipkeGu/gists{/gist_id}","starred_url":"https://api.github.com/users/LipkeGu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LipkeGu/subscriptions","organizations_url":"https://api.github.com/users/LipkeGu/orgs","repos_url":"https://api.github.com/users/LipkeGu/repos","events_url":"https://api.github.com/users/LipkeGu/events{/privacy}","received_events_url":"https://api.github.com/users/LipkeGu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-12T10:02:00Z","updated_at":"2018-09-12T10:02:00Z","closed_at":null,"author_association":"NONE","body":"Since a long time we have the problem that asterisk is very unfriendly to configure.\r\nIt contains a lot of config files which are mostly full commented out.\r\n\r\ni decided to write a uci file togehter with an init script to make it easier and flash friendlier.\r\nmy way is to move \"our\" generated config files into ```/tmp/asterisk/```  instead of overwriting the\r\n```/etc/``` this allows us a first step to make configs upgrade persistent.\r\n\r\n```\r\nconfig asterisk\r\n\toption verbose\t\t\t'0'\r\n\toption dontwarn\t\t'yes'\r\n\toption maxcalls\t\t\t'2'\r\n\toption maxload\t\t\t'0.9'\r\n\toption minmemfree\t\t'1'\r\n\toption tansmit_silence\t'yes'\r\n\toption language\t\t'de'\r\n\toption systemname\t\t'10.21.0.1'\r\n\toption autosystemname\t'yes'\r\n\toption mindtmfduration\t'80'\r\n\r\n# modules\r\n\toption autoload\t\t'yes'\r\n\r\n# user\r\n\toption userbase\t\t'6000'\r\n\r\n# sip\r\n\toption port\t\t\t'5060'\r\n\toption bindaddr\t\t'0.0.0.0'\r\n\toption context\t\t\t'default'\r\n\toption srvlookup\t\t'yes'\r\n\toption nat\t\t\t'yes'\r\n\toption allowguest\t\t'no'\r\n\toption transport\t\t'udp'\r\n\tlist networks\t\t\t'10.21.0.0/255.255.255.0'\r\n\tlist networks\t\t\t'10.22.0.0/255.255.255.0'\r\n\tlist networks\t\t\t'10.30.0.0/255.255.255.0'\r\n\tlist networks\t\t\t'10.40.0.0/255.255.255.0'\r\n\r\n# rtp\r\n\toption rtpstart\t\t\t'15000'\r\n\toption rtpend\t\t\t'30000'\r\n\toption dnsmgr\t\t\t'yes'\r\n\toption refreshinterval\t'1200'\r\n\r\nconfig asterisk_user\r\n\toption fullname\t\t'Lipke'\r\n\toption description\t\t'Linksys'\r\n\toption email\t\t\t'lipkegu@fblipke.de'\r\n\toption secret\t\t\t'1234'\r\n\toption vmsecret\t\t'1234'\r\n\toption hasvoicemail\t\t'no'\r\n\toption hassip\t\t\t'yes'\r\n\toption hasiax\t\t\t'no'\r\n\toption hash323\t\t'no'\r\n\toption hasmanager\t\t'no'\r\n\toption callwaiting\t\t'no'\r\n\toption macaddress\t\t'000E083B586F'\r\n\toption autoprov\t\t'yes'\r\n\toption linekeys\t\t\t'1'\r\n\toption linenumber\t\t'1'\r\n\toption cidnumber\t\t'6000'\r\n\toption treewaycalling\t'yes'\r\n\toption callwaitingcallerid\t'yes'\r\n\toption transfer\t\t\t'yes'\r\n\toption canpark\t\t\t'yes'\r\n\toption cancallforward\t'yes'\r\n\toption callreturn\t\t'yes'\r\n\toption callgroup\t\t'1'\r\n\toption pickupgroup\t\t'1'\r\n\r\nconfig asterisk_register\r\n\toption defaultuser\t\t'##########'\r\n\toption password\t\t'##########'\r\n\toption domain\t\t\t'sipgate.de'\r\n\r\nconfig asterisk_peer\r\n\toption number\t\t\t'6000'\r\n\toption type\t\t\t'friend'\r\n\toption secret\t\t\t'1234'\r\n\toption host\t\t\t'dynamic'\r\n\toption qualify\t\t\t'yes'\r\n\toption description\t\t'IP Device'\r\n\toption context\t\t\t'default'\r\n\r\nconfig asterisk_peer\r\n\toption number\t\t\t'sipgate'\r\n\toption context\t\t\t'sipgate-in'\r\n\toption type\t\t\t'peer'\r\n\toption secret\t\t\t'########'\r\n\toption host\t\t\t'sipgate.de'\r\n\toption canreinvite\t\t'no'\r\n\toption fromdomain\t\t'sipgate.de'\r\n\toption defaultuser\t\t'########'\r\n\toption fromuser\t\t'########'\r\n\toption insecure\t\t\t'port,invite'\r\n\toption dtmfmode\t\t'rfc2833'\r\n\toption disallow\t\t\t'all'\r\n\toption allow\t\t\t'alaw&ulaw'\r\n\toption outboundproxy\t'sipgate.de'\r\n\r\nconfig asterisk_dialplan\r\n\toption context\t\t'_default'\r\n\toption pattern\t\t'_[0-9].'\r\n\tlist entries\t\t\t'1,Answer()'\r\n\tlist entries\t\t\t'2,Hangup()'\r\n\r\nconfig asterisk_dialplan\r\n\toption context\t\t'internal'\r\n\toption pattern\t\t'_01.'\r\n\tlist entries\t\t\t'1,Answer()'\r\n\tlist entries\t\t\t'2,Playback(pls-hold-while-try&one-moment-please)'\r\n\tlist entries\t\t\t'3,Wait(1)'\r\n\tlist entries\t\t\t'4,Dial(SIP/${EXTEN:2},30)'\r\n\tlist entries\t\t\t'5,Playback(number-not-answering&please-try-call-later,noanswer)'\r\n\tlist entries\t\t\t'6,Wait(1)'\r\n\tlist entries\t\t\t'7,Hangup()'\r\n\r\nconfig asterisk_dialplan\r\n\toption context\t\t'sipgate-out'\r\n\toption pattern\t\t'_02.'\r\n\toption source\t\t'exten'\r\n\tlist entries\t\t\t'1,Answer()'\r\n\tlist entries\t\t\t'2,Playback(pls-hold-while-try&one-moment-please)'\r\n\tlist entries\t\t\t'3,Wait(1)'\r\n\tlist entries\t\t\t'4,Dial(SIP/${EXTEN:2}@sipgate,30)'\r\n\tlist entries\t\t\t'5,Playback(number-not-answering&please-try-call-later,noanswer)'\r\n\tlist entries\t\t\t'6,Wait(1)'\r\n\tlist entries\t\t\t'7,Hangup()'\r\n\r\nconfig asterisk_dialplan\r\n\toption context\t\t'sipgate-in'\r\n\toption pattern\t\t'########'\r\n\toption source\t\t'exten'\r\n\tlist entries\t\t\t'1,Answer()'\r\n\tlist entries\t\t\t'2,Playback(pls-hold-while-try&one-moment-please)'\r\n\tlist entries\t\t\t'3,Wait(1)'\r\n\tlist entries\t\t\t'4,Dial(SIP/6000,30)'\r\n\tlist entries\t\t\t'5,Playback(number-not-answering&please-try-call-later,noanswer)'\r\n\tlist entries\t\t\t'6,Wait(1)'\r\n\tlist entries\t\t\t'7,Hangup()'\r\n```\r\n\r\n/etc/init.d/asterisk contains so far:\r\n```\r\n#!/bin/sh /etc/rc.common\r\n# Copyright (C) 2018 OpenWrt.org\r\n\r\nSTART=99\r\nAPP=asterisk\r\nOPTIONS=\r\nDEST=\r\nDEFAULT=$DEST/etc/default/$APP\r\nBIN_FILE=$DEST/usr/sbin/$APP\r\nPID_FILE=$DEST/var/run/$APP/$APP.pid\r\n\r\n# creates the config files and its general settings...\r\n\r\nasterisk_set_header() {\r\n\tlocal verbose\r\n\tlocal dontwarn\r\n\tlocal maxcalls\r\n\tlocal maxload\r\n\tlocal minmemfree\r\n\tlocal transmit_silence\r\n\tlocal language\r\n\tlocal systemname\r\n\tlocal autosystemname\r\n\tlocal mindtmfduration\r\n\tlocal autoload\r\n\r\n\t# user template\r\n\tlocal userbase\r\n\r\n\t# sip\r\n\tlocal port\r\n\tlocal bindaddr\r\n\tlocal context\r\n\tlocal srvlookup\r\n\tlocal nat\r\n\tlocal allowguest\r\n\tlocal networks\r\n\r\n\t# rtp\r\n\tlocal rtpstart\r\n\tlocal rtpend\r\n\r\n\t# dnsmgr\r\n\tlocal dnsmgr\r\n\tlocal refreshinterval\r\n\r\n\t# main\r\n\tconfig_get verbose $1 verbose\r\n\tconfig_get dontwarn $1 dontwarn\r\n\tconfig_get maxcalls $1 maxcalls\r\n\tconfig_get maxload $1 maxload\r\n\tconfig_get minmemfree $1 minmemfree\r\n\tconfig_get transmit_silence $1 transmit_silence\r\n\tconfig_get language $1 language\r\n\tconfig_get systemname $1 systemname\r\n\tconfig_get autosystemname $1 autosystemname\r\n\tconfig_get mindtmfduration $1 mindtmfduration\r\n\r\n\t# modules\r\n\tconfig_get autoload $1 autoload\r\n\r\n\t# user template\r\n\tconfig_get userbase $1 userbase\r\n\r\n\t# sip\r\n\tconfig_get port $1 port\r\n\tconfig_get allowguest $1 allowguest\r\n\tconfig_get transport $1 transport\r\n\tconfig_get networks $1 networks\r\n\tconfig_get bindaddr $1 bindaddr\r\n\tconfig_get context $1 context\r\n\tconfig_get srvlookup $1 srvlookup\r\n\tconfig_get nat $1 nat\r\n\r\n\t# rtp\r\n\tconfig_get rtpstart $1 rtpstart\r\n\tconfig_get rtpend $1 rtpend\r\n\r\n\t# dns\r\n\tconfig_get dnsmgr $1 dnsmgr\r\n\tconfig_get refreshinterval $1 refreshinterval\r\n\r\n\techo -e \"[directories](!)\\n\r\n\tastetcdir => /tmp/asterisk\r\n\tastmoddir => /usr/lib/asterisk/modules\r\n\tastvarlibdir => /usr/lib/asterisk\r\n\tastdbdir => /usr/lib/asterisk\r\n\tastkeydir => /usr/lib/asterisk\r\n\tastdatadir => /usr/lib/asterisk\r\n\tastagidir => /usr/lib/asterisk/agi-bin\r\n\tastspooldir => /var/spool/asterisk\r\n\tastrundir => /var/run/asterisk\r\n\tastlogdir => /var/log/asterisk\r\n\tastsbindir => /usr/sbin\" > /etc/asterisk/asterisk.conf\r\n\r\n\tmkdir -p /tmp/asterisk/\r\n\techo -e \"[options]\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$verbose\" ] && echo -e \"verbose=$verbose\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$dontwarn\" ] && echo -e \"dontwarn=$dontwarn\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$maxcalls\" ] && echo -e \"maxcalls=$maxcalls\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$maxload\" ] && echo -e \"maxload=$maxload\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$minmemfree\" ] && echo -e \"minmemfree=$minmemfree\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$transmit_silence\" ] && echo -e \"transmit_silence=$transmit_silence\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$language\" ] && echo -e \"language=$language\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$systemname\" ] && echo -e \"systemname=$systemname\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$autosystemname\" ] && echo -e \"autosystemname=$autosystemname\" >> /tmp/asterisk/asterisk.conf\r\n\t[ -n \"$mindtmfduration\" ] && echo -e \"mindtmfduration=$mindtmfduration\" >> /tmp/asterisk/asterisk.conf\r\n\r\n\t# modules (autoload by default....)\r\n\techo -e \"[modules]\" > /tmp/asterisk/modules.conf\r\n\techo -e \"autoload = yes\" >> /tmp/asterisk/modules.conf\r\n\r\n\t# user template\r\n\techo -e \"[general]\" > /tmp/asterisk/users.conf\r\n\t[ -n \"$userbase\" ] && echo -e \"userbase = $userbase\" >> /tmp/asterisk/users.conf\r\n\r\n\t# sip\r\n\techo -e \"[general]\" > /tmp/asterisk/sip.conf\r\n\t[ -n \"$port\" ] && echo -e \"port = $port\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$allowguest\" ] && echo -e \"allowguest = $allowguest\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$transport\" ] && echo -e \"transport = $transport\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$bindaddr\" ] && echo -e \"bindaddr = $bindaddr\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$context\" ] && echo -e \"context = $context\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$srvlookup\" ] && echo -e \"srvlookup = $srvlookup\" >> /tmp/asterisk/sip.conf\r\n\r\n\tfor network in $networks; do\r\n\t\t[ -n \"$network\" ] && echo -e \"localnet = $network\" >> /tmp/asterisk/sip.conf\r\n\tdone\r\n\r\n\t# rtp\r\n\techo -e \"[general]\" > /tmp/asterisk/rtp.conf\r\n\t[ -n \"$rtpstart\" ] && echo -e \"rtpstart = $rtpstart\" >> /tmp/asterisk/rtp.conf\r\n\t[ -n \"$rtpend\" ] && echo -e \"rtpend = $rtpend\" >> /tmp/asterisk/rtp.conf\r\n\r\n\t# dns\r\n\techo -e \"[general]\" > /tmp/asterisk/dnsmgr.conf\r\n\t[ -n \"$dnsmgr\" ] && echo -e \"enabled = $dnsmgr\" >> /tmp/asterisk/dnsmgr.conf\r\n\t[ -n \"$refreshinterval\" ] && echo -e \"refreshinterval = $refreshinterval\" >> /tmp/asterisk/dnsmgr.conf\r\n\r\n\techo -e \"[general]\" > /tmp/asterisk/extensions.conf\r\n}\r\n\r\nasterisk_adduser() {\r\n\tlocal fullname\r\n\tlocal description\r\n\tlocal email\r\n\tlocal secret\r\n\tlocal vmsecret\r\n\tlocal dahdichan\r\n\tlocal hasvoicemail\r\n\tlocal hassip\r\n\tlocal hasiax\r\n\tlocal hash323\r\n\tlocal hasmanager\r\n\tlocal callwaiting\r\n\tlocal context\r\n\tlocal alternateexts\r\n\tlocal macaddress\r\n\tlocal autoprov\r\n\tlocal linekeys\r\n\tlocal linenumber\r\n\tlocal cidnumber\r\n\tlocal treewaycalling\r\n\tlocal callwaitingcallerid\r\n\tlocal transfer\r\n\tlocal canpark\r\n\tlocal cancallforward\r\n\tlocal callreturn\r\n\tlocal callgroup\r\n\tlocal pickupgroup\r\n\r\n\tconfig_get fullname $1 fullname\r\n\tconfig_get description $1 description\r\n\tconfig_get email $1 email\r\n\tconfig_get secret $1 secret\r\n\tconfig_get vmsecret $1 vmsecret\r\n\tconfig_get dahdichan $1 dahdichan\r\n\tconfig_get hasvoicemail $1 hasvoicemail\r\n\tconfig_get hassip $1 hassip\r\n\tconfig_get hasiax $1 hasiax\r\n\tconfig_get hasmanager $1 hasmanager\r\n\tconfig_get callwaiting $1 callwaiting\r\n\tconfig_get context $1 context\r\n\tconfig_get alternateexts $1 alternateexts\r\n\tconfig_get macaddress $1 macaddress\r\n\tconfig_get autoprov $1 autoprov\r\n\tconfig_get linekeys $1 linekeys\r\n\tconfig_get linenumber $1 linenumber\r\n\tconfig_get cidnumber $1 cidnumber\r\n\tconfig_get threewaycalling $1 threewaycalling\r\n\tconfig_get callwaitingcallerid $1 callwaitingcallerid\r\n\tconfig_get transfer $1 transfer\r\n\tconfig_get canpark $1 canpark\r\n\tconfig_get cancallforward $1 cancallforward\r\n\tconfig_get callreturn $1 callreturn\r\n\tconfig_get callgroup $1 callgroup\r\n\tconfig_get pickupgroup $1 pickupgroup\r\n\r\n\techo -e \"\\n[$cidnumber]\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$fullname\" ] && echo -e \"fullname = $fullname\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$description\" ] && echo -e \"description = $description\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$email\" ] && echo -e \"email = $email\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$secret\" ] && echo -e \"secret = $secret\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$vmsecret\" ] && echo -e \"vmsecret = $vmsecret\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$dahdichan\" ] && echo -e \"dahdichan = $dahdichan\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$hasvoicemail\" ] && echo -e \"hasvoicemail = $hasvoicemail\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$hassip\" ] && echo -e \"hassip = $hassip\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$hasiax\" ] && echo -e \"hasiax = $hasiax\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$hash323\" ] && echo -e \"hash323 = $hash323\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$hasmanager\" ] && echo -e \"hasmanager = $hasmanager\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$callwaiting\" ] && echo -e \"callwaiting = $callwaiting\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$context\" ] && echo -e \"context = $context\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$alternateexts\" ] && echo -e \"alternateexts = $alternateexts\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$macaddress\" ] && echo -e \"macaddress = $macaddress\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$autoprov\" ] && echo -e \"autoprov = $autoprov\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$linekeys\" ] && echo -e \"linekeys = $linekeys\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$linenumber\" ] && echo -e \"linenumber = $linenumber\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$cidnumber\" ] && echo -e \"cidnumber = $cidnumber\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$threewaycalling\" ] && echo -e \"threewaycalling = $threewaycalling\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$callwaitingcallerid\" ] && echo -e \"callwaitingcallerid = $callwaitingcallerid\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$transfer\" ] && echo -e \"transfer = $transfer\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$canpark\" ] && echo -e \"canpark = $canpark\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$cancallforward\" ] && echo -e \"cancallforward = $cancallforward\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$callreturn\" ] && echo -e \"callreturn = $callreturn\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$callgroup\" ] && echo -e \"callgroup = $callgroup\" >> /tmp/asterisk/users.conf\r\n\t[ -n \"$pickupgroup\" ] && echo -e \"pickupgroup = $pickupgroup\" >> /tmp/asterisk/users.conf\r\n}\r\n\r\n# creates the peer sections...\r\nasterisk_addpeer() {\r\n\tlocal number\r\n\tlocal type\r\n\tlocal host\r\n\tlocal fromuser\r\n\tlocal defaultuser\r\n\tlocal secret\r\n\tlocal fromdomain\r\n\tlocal context\r\n\tlocal canreinvite\r\n\tlocal qualify\r\n\tlocal insecure\r\n\tlocal dtmfmode\r\n\tlocal disallow\r\n\tlocal outboundproxy\r\n\r\n\tconfig_get number $1 number\r\n\tconfig_get type $1 type\r\n\tconfig_get host $1 host\r\n\tconfig_get fromuser $1 fromuser\r\n\tconfig_get defaultuser $1 defaultuser\r\n\tconfig_get secret $1 secret\r\n\tconfig_get fromdomain $1 fromdomain\r\n\tconfig_get context $1 context\r\n\tconfig_get canreinvite $1 canreinvite\r\n\tconfig_get qualify $1 qualify\r\n\tconfig_get insecure $1 insecure\r\n\tconfig_get dtmfmode $1 dtmfmode\r\n\tconfig_get disallow $1 disallow\r\n\tconfig_get allow $1 allow\r\n\tconfig_get outboundproxy $1 outboundproxy\r\n\tconfig_get transport $1 transport\r\n\r\n\t[ -n \"$number\" ] && echo -e \"\\n[$number]\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$type\" ] && echo -e \"type = $type\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$host\" ] && echo -e \"host = $host\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$fromuser\" ] && echo -e \"fromuser = $fromuser\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$defaultuser\" ] && echo -e \"defaultuser = $defaultuser\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$secret\" ] && echo -e \"secret = $secret\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$fromdomain\" ] && echo -e \"fromdomain = $fromdomain\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$context\" ] && echo -e \"context = $context\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$canreinvite\" ] && echo -e \"canreinvite = $canreinvite\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$qualify\" ] && echo -e \"qualify = $qualify\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$insecure\" ] && echo -e \"insecure = $insecure\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$dtmfmode\" ] && echo -e \"dtmfmode = $dtmfmode\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$disallow\" ] && echo -e \"disallow = $disallow\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$allow\" ] && echo -e \"allow = $allow\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$outboundproxy\" ] && echo -e \"outboundproxy = $outboundproxy\" >> /tmp/asterisk/sip.conf\r\n\t[ -n \"$transport\" ] && echo -e \"transport = $transport\" >> /tmp/asterisk/sip.conf\r\n}\r\n\r\n# writes out the \"register\" lines in sip.cond -> comes from the equaling uci section\r\nasterisk_dialplan() {\r\n\tlocal context\r\n\tlocal pattern\r\n\tlocal entries\r\n\tlocal preincludes\r\n\tlocal postincludes\r\n\r\n\tconfig_get context $1 context\r\n\tconfig_get pattern $1 pattern\r\n\tconfig_get entries $1 entries\r\n\tconfig_get preincludes $1 preincludes\r\n\tconfig_get postincludes $1 postincludes\r\n\r\n\t[ -n \"$context\" ] && echo -e \"[$context]\" >> /tmp/asterisk/extensions.conf\r\n\tfor include in $preincludes; do\r\n\t\t[ -n \"$context\" ] && echo -e \"include => $include\" >> /tmp/asterisk/extensions.conf\r\n\tdone\r\n\r\n\tfor entrie in $entries; do\r\n\t\t[ -n \"$context\" ] && echo -e \"exten => $pattern,$entrie\" >> /tmp/asterisk/extensions.conf\r\n\tdone\r\n\r\n\tfor include in $postincludes; do\r\n\t\t[ -n \"$context\" ] && echo -e \"include => $include\" >> /tmp/asterisk/extensions.conf\r\n\tdone\r\n\r\n\t[ -n \"$context\" ] && echo -e \"\" >> /tmp/asterisk/extensions.conf\r\n}\r\n\r\nasterisk_register() {\r\n\tlocal defaultuser\r\n\tlocal password\r\n\tlocal domain\r\n\tlocal prefix\r\n\r\n\tconfig_get defaultuser $1 defaultuser\r\n\tconfig_get password $1 password\r\n\tconfig_get domain $1 domain \r\n\tconfig_get prefix $1 prefix \r\n\r\n\t[ -n \"$defaultuser\" ] && echo -e \"register => $defaultuser$prefix:$password@$domain/$defaultuser\" >> /tmp/asterisk/sip.conf\r\n}\r\n\r\nstart() {\r\n\tconfig_load asterisk\r\n\tconfig_foreach asterisk_set_header asterisk\r\n\tconfig_foreach asterisk_register asterisk_register\r\n\tconfig_foreach asterisk_adduser asterisk_user\r\n\tconfig_foreach asterisk_addpeer asterisk_peer\r\n\r\n\tconfig_foreach asterisk_dialplan asterisk_dialplan\r\n\r\n\t[ -f $DEFAULT ] && . $DEFAULT\r\n\t[ -d $DEST/var/run/asterisk ] || mkdir -p $DEST/var/run/asterisk\r\n\t[ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk\r\n\t[ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk\r\n\t[ -d $DEST/var/lib ] || mkdir -p $DEST/var/lib\r\n\t[ -h $DEST/var/lib/asterisk ] || ln -s /usr/lib/asterisk /var/lib/asterisk\r\n\t[ -d $DEST/var/lib/asterisk/keys ] || mkdir -p $DEST/var/lib/asterisk/keys\r\n\t[ -d $DEST/var/log/asterisk/cdr-csv ] || mkdir -p $DEST/var/log/asterisk/cdr-csv\r\n\t[ -d $DEST/var/lib/asterisk/moh ] || mkdir -p $DEST/var/lib/asterisk/moh\r\n\r\n\tSERVICE_PID_FILE=\"/var/run/asterisk/asterisk.pid\" \\\r\n\tservice_start $BIN_FILE $OPTIONS\r\n}\r\n\r\nstop() {\r\n\tSERVICE_PID_FILE=\"/var/run/asterisk/asterisk.pid\" \\\r\n\tservice_stop $BIN_FILE\r\n}\r\n\r\nreload() {\r\n\tSERVICE_PID_FILE=\"/var/run/asterisk/asterisk.pid\" \\\r\n\tservice_reload $BIN_FILE\r\n}\r\n```\r\n\r\nIm currently using it and it makes (except the dialplan patterns) the life of my box alot easier...\r\nAny suggestions?"}}
{"actor":{"display_login":"LipkeGu"}}