# You should have received a copy of the GNU General Public License
# along with luci-pbx. If not, see <http://www.gnu.org/licenses/>.
-. /etc/functions.sh
+. /lib/functions.sh
START=60
# Some global variables
MODULENAME=pbx
USERAGENT="PBX"
-DEFAULTOUTCNTXT=default-outgoing-call-context
-HANGUPCNTXT=hangup
+HANGUPCNTXT=hangup-call-context
GTALKUNVL=unavailable
ASTUSER=nobody
ASTGROUP=nogroup
ASTDIRSRECURSIVE="/var/run/asterisk /var/log/asterisk /var/spool/asterisk"
ASTDIRS="/usr/lib/asterisk"
+ASTSOUNDSDIR="/usr/lib/asterisk/sounds"
TEMPLATEDIR=/etc/${MODULENAME}-asterisk
+PBXSOUNDSDIR=$TEMPLATEDIR/sounds
VMTEMPLATEDIR=/etc/${MODULENAME}-voicemail
+VMSOUNDSDIR=$VMTEMPLATEDIR/sounds
ASTERISKDIR=/etc/asterisk
WORKDIR=/tmp/$MODULENAME.$$
MD5SUMSFILE=/tmp/$MODULENAME-sums.$$
sed "s/|RTPEND|/$rtpend/" > $WORKDIR/rtp.conf
}
+# Links any sound files found in $PBXSOUNDSDIR and $VMSOUNDSDIR
+# into $ASTSOUNDSDIR for use by Asterisk. Does not overwrite files.
+pbx_link_sounds()
+{
+ mkdir -p $ASTSOUNDSDIR
+
+ for dir in $PBXSOUNDSDIR $VMSOUNDSDIR ; do
+ if [ -d $dir ] ; then
+ for f in $dir/* ; do
+ ln -s $f $ASTSOUNDSDIR 2>/dev/null
+ done
+ fi
+ done
+}
+
+
# Makes sure the ownership of specified directories is proper.
pbx_fix_ownership()
{
config_get enabled global_voicemail enabled
# First check if voicemail is enabled.
- [ "$enabled" != "yes" ] && exit
+ [ "$enabled" != "yes" ] && return
config_get global_timeout global_voicemail global_timeout
#config_get global_email_addresses global_voicemail global_email_addresses
pbx_cook_sip_template
pbx_cook_rtp_template
- # Prepare sip.conf using settings from the "advanced" section.
+ # Prepare voicemail config.
config_unset
config_load ${MODULENAME}-voicemail
- pbx_configure_voicemail
+ pbx_configure_voicemail
# Assemble the configuration, and copy changed files over.
config_unset
config_load ${MODULENAME}-advanced
pbx_assemble_and_copy_config
+ # Link sound files
+ pbx_link_sounds
+
# Enforce ownership of specified files and directories.
pbx_fix_ownership
}