The musiconhold.conf file is located at /etc/asterisk/musiconhold.conf. To start we can move the file to musiconhold.conf.sample and start with a new file. To do this, use the command:
sudo mv /etc/asterisk/musiconhold.conf /etc/asterisk/musiconhold.conf.sample |
Now to create a new file we can use the command:
sudo nano /etc/asterisk/musiconhold.conf |
The original file has a [general] context with no settings applied, as well as a [default] context that sets mode=file and directory=moh. File mode play the audio files in with a directory. The directory moh is located at /usr/share/asterisk/moh. There should already be audio files located in the folder. Add the following data to the musiconhold.conf to recreate the original settings:
[general] |
[default] mode=files directory=moh |
In the previous lessons we created a queue called techteam. If we wanted to change the default music played when the dialing the queue, it can be done by adding a new context to the musiconhold.conf file. In context we can also set how the music files will be selected. If we wanted to sort the files and play they alphabetically we could use sort=alpha, in this example we will sort the file playback randomly using sort=random. Continue editing the file and add the following:
[techteam] mode=files directory=techteam sort=random |
The new [techteam] context is now looking for a folder named techteam. We can create this folder in the /usr/share/asterisk/ directory. To do that use the command:
sudo mkdir /usr/share/asterisk/techteam |
We will want to make sure that the asterisk user account has permissions for this new folder. To do that use the command:
sudo chown asterisk /usr/share/asterisk/techteam |
New audio files will need to be added to this folder that will be used for the music on hold. We also still need to adjust the dialplan and set our extension 300 to use the techteam context within the musiconhold.conf file.
To reload music on hold in the asterisk CLI use the command:
moh reload |
Another helpful command in the CLI is to view the context music on hold classes. To do this use the command:
moh show classes |