entry({"admin", "services", "pbx", "pbx-voip"}, cbi("pbx-voip"), "SIP Accounts", 2)
entry({"admin", "services", "pbx", "pbx-users"}, cbi("pbx-users"), "User Accounts", 3)
entry({"admin", "services", "pbx", "pbx-calls"}, cbi("pbx-calls"), "Call Routing", 4)
- entry({"admin", "services", "pbx", "pbx-advanced"}, cbi("pbx-advanced"), "Advanced Settings", 5)
+ entry({"admin", "services", "pbx", "pbx-advanced"}, cbi("pbx-advanced"), "Advanced Settings", 6)
end
translatef("You can use your SIP devices/softphones with this system from a remote location \
as well, as long as your Internet Service Provider gives you a public IP. \
You will be able to call other local users for free (e.g. other Analog Telephone Adapters (ATAs)) \
- and use your VoIP providers to make calls as if you were at local to the PBX. \
+ and use your VoIP providers to make calls as if you were local to the PBX. \
After configuring this tab, go back to where users are configured and see the new \
- Server and Port setting you need to configure the SIP devices with. Please note that by default \
- %s uses UDP port range %d to %d for RTP traffic (which carries voice), in case you need to configure \
- NAT or QoS on another device.", appname, defaultrtpstart, defaultrtpend))
+ Server and Port setting you need to configure the remote SIP devices with. Please note that if this \
+ PBX is not running on your router/gateway, you will need to configure port forwarding (NAT) on your \
+ router/gateway. Please forward the ports below (SIP port and RTP range) to the IP address of the \
+ device running this PBX."))
s:tab("qos", translate("QoS Settings"),
translate("If you experience jittery or high latency audio during heavy downloads, you may want \
QoS configuration page (Network->QoS) to configure other critical QoS settings like Download \
and Upload speed."))
+ringtime = s:taboption("general", Value, "ringtime", translate("Number of seconds to ring"),
+ translate("Set the number of seconds to ring users upon incoming calls before hanging up \
+ or going to voicemail, if the voicemail is installed and enabled."))
+ringtime.default = 30
+
ua = s:taboption("general", Value, "useragent", translate("User Agent String"),
translate("This is the name that the VoIP server will use to identify itself when \
registering to VoIP (SIP) providers. Some providers require this to a specific \
string matching a hardware SIP device."))
ua.default = appname
-h = s:taboption("remote_usage", Value, "externhost", translate("Domain Name/Dynamic Domain Name"),
- translate("You should either have registered a domain name and have a static IP \
- address, or have configured Dynamic DNS on this router. Enter a \
- domain name which resolves to your external IP address."))
+h = s:taboption("remote_usage", Value, "externhost", translate("Domain/IP Address/Dynamic Domain"),
+ translate("You can enter your domain name, external IP address, or dynamic domain name here \
+ Please keep in mind that if your IP address is dynamic and it changes your configuration \
+ will become invalid. Hence, it's recommended to set up Dynamic DNS in this case."))
h.datatype = "hostname"
p = s:taboption("remote_usage", Value, "bindport", translate("External SIP Port"),
-----------------------------------------------------------------------------------------
s = m:section(NamedSection, "connection_status", "main",
- translate("Service Control and Connection Status"))
+ translate("PBX Service Status"))
s.anonymous = true
s:option (DummyValue, "status", translate("Service Status"))
config 'settings' 'advanced'
+ option 'useragent' 'PBX'
+ option 'ringtime' '30'
ASTDIRS="/usr/lib/asterisk"
TEMPLATEDIR=/etc/${MODULENAME}-asterisk
+VMTEMPLATEDIR=/etc/${MODULENAME}-voicemail
ASTERISKDIR=/etc/asterisk
WORKDIR=/tmp/$MODULENAME.$$
MD5SUMSFILE=/tmp/$MODULENAME-sums.$$
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
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
# 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
# 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.
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"
# 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
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
}
}
+# 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
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
+}
clearglobalvars = no
[globals]
+RINGTIME => |RINGTIME|
[default]
[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
--- /dev/null
+[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)
--- /dev/null
+exten => |DEFAULTUSER|,1,Goto(default-incoming-call-context,s,1)
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|)
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)
+
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)
-exten => |DEFAULTUSER|,1,Dial(SIP/|DEFAULTUSER|,60,r)
+exten => |DEFAULTUSER|,1,Dial(SIP/|DEFAULTUSER|,${RINGTIME},r)
+include => context-voicemail-record-greeting
include => context-catch-all
--- /dev/null
+[context-voicemail-record-greeting]
+
+[context-voicemail]
+exten => s,1,Hangup()
--- /dev/null
+[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)}' &)
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