diff options
Diffstat (limited to 'applications/luci-pbx/root/etc')
13 files changed, 156 insertions, 37 deletions
diff --git a/applications/luci-pbx/root/etc/config/pbx-advanced b/applications/luci-pbx/root/etc/config/pbx-advanced index e7ac0e221e..58af453f92 100644 --- a/applications/luci-pbx/root/etc/config/pbx-advanced +++ b/applications/luci-pbx/root/etc/config/pbx-advanced @@ -1 +1,3 @@ config 'settings' 'advanced' + option 'useragent' 'PBX' + option 'ringtime' '30' diff --git a/applications/luci-pbx/root/etc/init.d/pbx-asterisk b/applications/luci-pbx/root/etc/init.d/pbx-asterisk index e20c339166..fdd01d76be 100755 --- a/applications/luci-pbx/root/etc/init.d/pbx-asterisk +++ b/applications/luci-pbx/root/etc/init.d/pbx-asterisk @@ -34,6 +34,7 @@ ASTDIRSRECURSIVE="/var/run/asterisk /var/log/asterisk /var/spool/asterisk" ASTDIRS="/usr/lib/asterisk" TEMPLATEDIR=/etc/${MODULENAME}-asterisk +VMTEMPLATEDIR=/etc/${MODULENAME}-voicemail ASTERISKDIR=/etc/asterisk WORKDIR=/tmp/$MODULENAME.$$ MD5SUMSFILE=/tmp/$MODULENAME-sums.$$ @@ -54,10 +55,16 @@ TMPL_EXTCTHRU=$TEMPLATEDIR/extensions_disa.conf.TEMPLATE TMPL_EXTENSIONS=$TEMPLATEDIR/extensions.conf.TEMPLATE +TMPL_EXTVMDISABLED=$TEMPLATEDIR/extensions_voicemail_disabled.conf.TEMPLATE +TMPL_EXTVMENABLED=$TEMPLATEDIR/extensions_voicemail_enabled.conf.TEMPLATE + TMPL_EXTBLKLIST=$TEMPLATEDIR/extensions_blacklist.conf.TEMPLATE TMPL_EXTBLKLISTFTR=$TEMPLATEDIR/extensions_blacklist_footer.conf.TEMPLATE TMPL_EXTBLKLISTHDR=$TEMPLATEDIR/extensions_blacklist_header.conf.TEMPLATE +TMPL_EXTDEFAULT=$TEMPLATEDIR/extensions_default.conf.TEMPLATE +TMPL_EXTDEFAULTUSER=$TEMPLATEDIR/extensions_default_user.conf.TEMPLATE + TMPL_EXTINCNTXTSIP=$TEMPLATEDIR/extensions_incoming_context_sip.conf.TEMPLATE TMPL_EXTINCNTXTGTALKHDR=$TEMPLATEDIR/extensions_incoming_context_gtalk_header.conf.TEMPLATE TMPL_EXTINCNTXTGTALK=$TEMPLATEDIR/extensions_incoming_context_gtalk.conf.TEMPLATE @@ -78,11 +85,18 @@ TMPL_SIPPEER=$TEMPLATEDIR/sip_peer.TEMPLATE TMPL_SIPREG=$TEMPLATEDIR/sip_registration.TEMPLATE TMPL_SIPUSR=$TEMPLATEDIR/sip_user.TEMPLATE +TMPL_MSMTPDEFAULT=$VMTEMPLATEDIR/pbx-msmtprc-defaults.TEMPLATE +TMPL_MSMTPACCOUNT=$VMTEMPLATEDIR/pbx-msmtprc-account.TEMPLATE +TMPL_MSMTPAUTH=$VMTEMPLATEDIR/pbx-msmtprc-account-auth.TEMPLATE +TMPL_MSMTPACCTDFLT=$VMTEMPLATEDIR/pbx-msmtprc-account-default.TEMPLATE + + INCLUDED_FILES="$WORKDIR/extensions_blacklist.conf $WORKDIR/extensions_callthrough.conf\ $WORKDIR/extensions_incoming.conf $WORKDIR/extensions_incoming_gtalk.conf\ $WORKDIR/extensions_user.conf $WORKDIR/jabber_users.conf\ $WORKDIR/sip_peers.conf $WORKDIR/sip_registrations.conf\ - $WORKDIR/sip_users.conf" + $WORKDIR/sip_users.conf $WORKDIR/extensions_voicemail.conf\ + $WORKDIR/extensions_default.conf" # In this string, we concatenate all local users enabled to receive calls @@ -102,12 +116,15 @@ outbound_providers="" # Copies the template files which we don't edit. copy_unedited_templates_over() { - cp $TMPL_ASTERISK $WORKDIR/asterisk.conf - cp $TMPL_GTALK $WORKDIR/gtalk.conf - cp $TMPL_INDICATIONS $WORKDIR/indications.conf - cp $TMPL_LOGGER $WORKDIR/logger.conf - cp $TMPL_MANAGER $WORKDIR/manager.conf - cp $TMPL_MODULES $WORKDIR/modules.conf + cp $TMPL_ASTERISK $WORKDIR/asterisk.conf + cp $TMPL_GTALK $WORKDIR/gtalk.conf + cp $TMPL_INDICATIONS $WORKDIR/indications.conf + cp $TMPL_LOGGER $WORKDIR/logger.conf + cp $TMPL_MANAGER $WORKDIR/manager.conf + cp $TMPL_MODULES $WORKDIR/modules.conf + # If this file isn't present at this stage, voicemail is disabled. + [ ! -f $WORKDIR/extensions_voicemail.conf ] && \ + cp $TMPL_EXTVMDISABLED $WORKDIR/extensions_voicemail.conf } # Touches all the included files, to prevent asterisk from refusing to @@ -120,22 +137,29 @@ create_included_files() # Puts together all the extensions.conf related configuration. pbx_create_extensions_config() { - sed "s/|LOCALUSERS|/$localusers_to_ring/g" $TMPL_EXTENSIONS > $WORKDIR/extensions.conf - mv $WORKDIR/inext.TMP $WORKDIR/extensions_incoming.conf - cp $TMPL_EXTINCNTXTGTALKHDR $WORKDIR/extensions_incoming_gtalk.conf - cat $WORKDIR/outextgtalk.TMP >> $WORKDIR/extensions_incoming_gtalk.conf 2>/dev/null + local ringtime + config_get ringtime advanced ringtime + + sed "s/|RINGTIME|/$ringtime/" $TMPL_EXTENSIONS > $WORKDIR/extensions.conf + mv $WORKDIR/inext.TMP $WORKDIR/extensions_incoming.conf + cp $TMPL_EXTINCNTXTGTALKHDR $WORKDIR/extensions_incoming_gtalk.conf + cat $WORKDIR/outextgtalk.TMP >> $WORKDIR/extensions_incoming_gtalk.conf 2>/dev/null rm -f $WORKDIR/outextgtalk.TMP - mv $WORKDIR/blacklist.TMP $WORKDIR/extensions_blacklist.conf - mv $WORKDIR/userext.TMP $WORKDIR/extensions_user.conf - cp $TMPL_EXTCTHRUHDR $WORKDIR/extensions_callthrough.conf - cat $WORKDIR/callthrough.TMP >> $WORKDIR/extensions_callthrough.conf 2>/dev/null + mv $WORKDIR/blacklist.TMP $WORKDIR/extensions_blacklist.conf + mv $WORKDIR/userext.TMP $WORKDIR/extensions_user.conf + cp $TMPL_EXTCTHRUHDR $WORKDIR/extensions_callthrough.conf + cat $WORKDIR/callthrough.TMP >> $WORKDIR/extensions_callthrough.conf 2>/dev/null rm -f $WORKDIR/callthrough.TMP - cat $TMPL_EXTCTHRUCHECKHDR >> $WORKDIR/extensions_callthrough.conf 2>/dev/null - cat $WORKDIR/callthroughcheck.TMP >> $WORKDIR/extensions_callthrough.conf 2>/dev/null + cat $TMPL_EXTCTHRUCHECKHDR >> $WORKDIR/extensions_callthrough.conf 2>/dev/null + cat $WORKDIR/callthroughcheck.TMP >> $WORKDIR/extensions_callthrough.conf 2>/dev/null rm -f $WORKDIR/callthroughcheck.TMP - cat $TMPL_EXTCTHRUCHECKFTR >> $WORKDIR/extensions_callthrough.conf 2>/dev/null + cat $TMPL_EXTCTHRUCHECKFTR >> $WORKDIR/extensions_callthrough.conf 2>/dev/null rm -f $WORKDIR/outext-*.TMP rm -f $WORKDIR/localext.TMP + sed "s/|LOCALUSERS|/$localusers_to_ring/g" $TMPL_EXTDEFAULT \ + > $WORKDIR/extensions_default.conf + cat $WORKDIR/inextuser.TMP >> $WORKDIR/extensions_default.conf + rm -f $WORKDIR/inextuser.TMP } # Puts together all the sip.conf related configuration. @@ -224,11 +248,11 @@ pbx_add_user() local ring local can_call - config_get fullname $1 fullname + config_get fullname $1 fullname config_get defaultuser $1 defaultuser - config_get secret $1 secret - config_get ring $1 ring - config_get can_call $1 can_call + config_get secret $1 secret + config_get ring $1 ring + config_get can_call $1 can_call [ -z "$defaultuser" -o -z "$secret" ] && return [ -z "$fullname" ] && fullname="$defaultuser" @@ -245,7 +269,7 @@ pbx_add_user() # Add this user's configuration to the temp file containing all user configs. sed "s/|FULLNAME|/$fullname/" $WORKDIR/sip_user.tmp |\ - sed "s/|SECRET|/$secret/g" >> $WORKDIR/sip_users.TMP + sed "s/|SECRET|/$secret/g" >> $WORKDIR/sip_users.TMP if [ "$ring" = "yes" ] ; then if [ -z "$localusers_to_ring" ] ; then @@ -256,7 +280,11 @@ pbx_add_user() fi # Add configuration which allows local users to call each other. - sed "s/|DEFAULTUSER|/$defaultuser/g" $TMPL_EXTOUTLOCAL >> $WORKDIR/localext.TMP + sed "s/|DEFAULTUSER|/$defaultuser/g" $TMPL_EXTOUTLOCAL >> $WORKDIR/localext.TMP + + # Add configuration which puts calls to users through the default + # context, so that blacklists and voicemail take effect for this user. + sed "s/|DEFAULTUSER|/$defaultuser/g" $TMPL_EXTDEFAULTUSER >> $WORKDIR/inextuser.TMP rm -f $WORKDIR/sip_user.tmp } @@ -556,6 +584,57 @@ pbx_fix_ownership() } +# Creates voicemail config if installed and enabled. +pbx_configure_voicemail() +{ + local enabled + local global_timeout + local global_email_addresses + + local smtp_tls + local smtp_server + local smtp_port + local smtp_auth + local smtp_user + local smtp_password + + config_get enabled global_voicemail enabled + + # First check if voicemail is enabled. + [ "$enabled" != "yes" ] && exit + + config_get global_timeout global_voicemail global_timeout + #config_get global_email_addresses global_voicemail global_email_addresses + config_get smtp_auth voicemail_smtp smtp_auth + config_get smtp_tls voicemail_smtp smtp_tls + config_get smtp_server voicemail_smtp smtp_server + config_get smtp_port voicemail_smtp smtp_port + config_get smtp_user voicemail_smtp smtp_user + config_get smtp_password voicemail_smtp smtp_password + + sed "s/|AUTH|/$smtp_auth/" $TMPL_MSMTPDEFAULT |\ + sed "s/|TLS|/$smtp_tls/" > $WORKDIR/pbx-msmtprc + + sed "s/|HOST|/$smtp_server/" $TMPL_MSMTPACCOUNT |\ + sed "s/|PORT|/$smtp_port/" >> $WORKDIR/pbx-msmtprc + + if [ "$smtp_auth" = "on" ] ; then + sed "s/|USER|/$smtp_user/" $TMPL_MSMTPAUTH |\ + sed "s/|PASSWORD|/$smtp_password/" >> $WORKDIR/pbx-msmtprc + fi + + cat $TMPL_MSMTPACCTDFLT >> $WORKDIR/pbx-msmtprc + + [ ! -f /etc/pbx-msmtprc ] && cp $WORKDIR/pbx-msmtprc /etc/pbx-msmtprc + diff -q $WORKDIR/pbx-msmtprc /etc/pbx-msmtprc 1>/dev/null \ + || mv $WORKDIR/pbx-msmtprc /etc/pbx-msmtprc + chmod 600 /etc/pbx-msmtprc + + # Copy over the extensions file which has voicemail enabled. + cp $TMPL_EXTVMENABLED $WORKDIR/extensions_voicemail.conf +} + + start() { mkdir -p $WORKDIR @@ -586,9 +665,16 @@ start() { pbx_cook_sip_template pbx_cook_rtp_template + # Prepare sip.conf using settings from the "advanced" section. + config_unset + config_load ${MODULENAME}-voicemail + pbx_configure_voicemail + # Assemble the configuration, and copy changed files over. + config_unset + config_load ${MODULENAME}-advanced pbx_assemble_and_copy_config # Enforce ownership of specified files and directories. pbx_fix_ownership -}
\ No newline at end of file +} diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions.conf.TEMPLATE index f3edac384b..a01a22fa31 100644 --- a/applications/luci-pbx/root/etc/pbx-asterisk/extensions.conf.TEMPLATE +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions.conf.TEMPLATE @@ -4,6 +4,7 @@ writeprotect = yes clearglobalvars = no [globals] +RINGTIME => |RINGTIME| [default] @@ -14,15 +15,8 @@ exten => _X.,1,Hangup() [context-catch-all] exten => _[!-~].,1,Dial(SIP/${EXTEN},60,r) -[default-incoming-call-context] -exten => s,1,NoOp(${CALLERID}) -exten => s,n,Set(SOURCECONTEXT=default-incoming-call-context) -exten => s,n,Set(SOURCEEXTEN=s) -exten => s,n,Goto(blacklist-call-context,s,1) -exten => s,n(doneblacklist),NoOp() -exten => s,n,Goto(disa-check-call-context,s,1) -exten => s,n(donedisacheck),Dial(|LOCALUSERS|,60,r) - +#include extensions_default.conf +#include extensions_voicemail.conf #include extensions_incoming.conf #include extensions_incoming_gtalk.conf #include extensions_blacklist.conf diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_default.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_default.conf.TEMPLATE new file mode 100644 index 0000000000..8d37ddccb2 --- /dev/null +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_default.conf.TEMPLATE @@ -0,0 +1,9 @@ +[default-incoming-call-context] +exten => s,1,NoOp(${CALLERID}) +exten => s,n,Set(SOURCECONTEXT=default-incoming-call-context) +exten => s,n,Set(SOURCEEXTEN=s) +exten => s,n,Goto(blacklist-call-context,s,1) +exten => s,n(doneblacklist),NoOp() +exten => s,n,Goto(disa-check-call-context,s,1) +exten => s,n(donedisacheck),Dial(|LOCALUSERS|,${RINGTIME},r) +exten => s,n,Goto(context-voicemail,s,1) diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_default_user.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_default_user.conf.TEMPLATE new file mode 100644 index 0000000000..1910ff4d96 --- /dev/null +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_default_user.conf.TEMPLATE @@ -0,0 +1 @@ +exten => |DEFAULTUSER|,1,Goto(default-incoming-call-context,s,1) diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_disa.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_disa.conf.TEMPLATE index e799d52100..3dd8fa35c9 100644 --- a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_disa.conf.TEMPLATE +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_disa.conf.TEMPLATE @@ -1,4 +1,6 @@ exten => |NUMBER|,1,Noop() +exten => |NUMBER|,n,Set(TIMEOUT(digit)=7) +exten => |NUMBER|,n,Set(TIMEOUT(response)=21) exten => |NUMBER|,n,Authenticate(|PIN|) exten => |NUMBER|,n,DISA(no-password,context-user-|DEFAULTUSER|) diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_incoming_context_gtalk.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_incoming_context_gtalk.conf.TEMPLATE index dc0c68addc..f0ca37209e 100644 --- a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_incoming_context_gtalk.conf.TEMPLATE +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_incoming_context_gtalk.conf.TEMPLATE @@ -8,4 +8,6 @@ same => n,Set(SOURCEEXTEN=|USERNAME|) same => n,Goto(blacklist-call-context,s,1) same => n(doneblacklist),NoOp() same => n,Goto(disa-check-call-context,s,1) -same => n(donedisacheck),Dial(|LOCALUSERS|,60,D(:w11111111)) +same => n(donedisacheck),Dial(|LOCALUSERS|,${RINGTIME},D(:w11111111)) +same => n,Goto(context-voicemail,s,1) + diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_incoming_context_sip.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_incoming_context_sip.conf.TEMPLATE index 12ecefc80f..1956007542 100644 --- a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_incoming_context_sip.conf.TEMPLATE +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_incoming_context_sip.conf.TEMPLATE @@ -6,4 +6,5 @@ exten => s,n,Set(SOURCEEXTEN=s) exten => s,n,Goto(blacklist-call-context,s,1) exten => s,n(doneblacklist),NoOp() exten => s,n,Goto(disa-check-call-context,s,1) -exten => s,n(donedisacheck),Dial(|LOCALUSERS|,60,r) +exten => s,n(donedisacheck),Dial(|LOCALUSERS|,${RINGTIME},r) +exten => s,n,Goto(context-voicemail,s,1) diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_outgoing_dial_local_user.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_outgoing_dial_local_user.conf.TEMPLATE index b81da9eab3..45e8758846 100644 --- a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_outgoing_dial_local_user.conf.TEMPLATE +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_outgoing_dial_local_user.conf.TEMPLATE @@ -1 +1 @@ -exten => |DEFAULTUSER|,1,Dial(SIP/|DEFAULTUSER|,60,r) +exten => |DEFAULTUSER|,1,Dial(SIP/|DEFAULTUSER|,${RINGTIME},r) diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_user_context_footer.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_user_context_footer.conf.TEMPLATE index 7ce1060dc2..a2ba28c055 100644 --- a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_user_context_footer.conf.TEMPLATE +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_user_context_footer.conf.TEMPLATE @@ -1 +1,2 @@ +include => context-voicemail-record-greeting include => context-catch-all diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_voicemail_disabled.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_voicemail_disabled.conf.TEMPLATE new file mode 100644 index 0000000000..be23c294df --- /dev/null +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_voicemail_disabled.conf.TEMPLATE @@ -0,0 +1,4 @@ +[context-voicemail-record-greeting] + +[context-voicemail] +exten => s,1,Hangup() diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/extensions_voicemail_enabled.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_voicemail_enabled.conf.TEMPLATE new file mode 100644 index 0000000000..e4b34b5b0d --- /dev/null +++ b/applications/luci-pbx/root/etc/pbx-asterisk/extensions_voicemail_enabled.conf.TEMPLATE @@ -0,0 +1,15 @@ +[context-voicemail-record-greeting] +exten => *789,1,Wait(2) +exten => *789,n,Playback(/etc/pbx-voicemail/greeting) +exten => *789,n,Wait(5) +exten => *789,n,Record(/etc/pbx-voicemail/greeting:WAV,20,90,k) +exten => *789,n,Wait(2) +exten => *789,n,Playback(/etc/pbx-voicemail/greeting) + +[context-voicemail] +exten => s,1,Wait(2) +exten => s,2,Playback(/etc/pbx-voicemail/greeting) +exten => s,3,Wait(2) +exten => s,n,Record(/tmp/voicemail%d:WAV,20,180,k) + +exten => h,1,System(/etc/pbx-voicemail/pbx-send-voicemail '${RECORDED_FILE}.WAV' '${CALLERID(all)}' &) diff --git a/applications/luci-pbx/root/etc/pbx-asterisk/modules.conf.TEMPLATE b/applications/luci-pbx/root/etc/pbx-asterisk/modules.conf.TEMPLATE index 3594dad433..899e330dd1 100644 --- a/applications/luci-pbx/root/etc/pbx-asterisk/modules.conf.TEMPLATE +++ b/applications/luci-pbx/root/etc/pbx-asterisk/modules.conf.TEMPLATE @@ -18,9 +18,11 @@ load => codec_gsm.so ; GSM/PCM16 (signed linear) Codec Translat - Requires N/A load => codec_ulaw.so ; Mu-law Coder/Decoder - Requires N/A load => format_gsm.so ; Raw GSM data - Requires N/A load => format_pcm.so ; Raw uLaw 8khz Audio support (PCM) - Requires N/A +load => format_wav_gsm.so load => app_dial.so ; Dialing Application - Requires res_features.so, res_musiconhold.so load => app_parkandannounce.so ; Call Parking and Announce Application - Requires res_features.so load => app_playback.so ; Sound File Playback Application - Requires N/A +load => app_record.so ; Sound File Record Application - Requires N/A load => app_system.so ; Execute a system command - Requires N/A load => app_disa.so ; Direct Inward System Access load => app_authenticate.so ; Authenticate via pin |