Skip to content

AstLinux Record Phone Calls to External USB Flash Drive Part 3

by Jon on August 4th, 2014

In my last post I gave you examples of how to record phone calls using the Asterisk dialplan. This post will make sure those recordings get stored on the external USB drive we formatted.

By default Asterisk will store call recordings to /var/spool/asterisk/monitor which is fine but the directory is on the compact flash card running AstLinux so we don’t want to do that. To redirect the call recordings and mount the USB drive I created a script I run via a cron job in case the system gets restarted.

1. The script will check for the existence of a file stored on the usb drive and if it does not exist then mount the drive. I stored the script on the keydisk at /mnt/kd/call_recording.sh

#!/bin/bash

if [ ! -f /mnt/usb/mount.txt ]; then
rm -f /var/spool/asterisk/monitor/*.wav
e2fsck -y /dev/sdb1
mount -t ext2 /dev/sdb1 /mnt/usb/
rm /var/spool/asterisk/monitor
ln -s /mnt/usb/callrecordings /var/spool/asterisk/monitor
date >> /mnt/usb/mount.txt
fi

2. Next is to schedule the script as a cron job, of course make sure to make the script executable with the chmod +x command. Editing the crontab’s file on Astlinux is done through the web admin. I setup the script to run every 10 minutes since when I tried using the cron @reboot option it did not do anything, so worst case it might take up to 9 minutes and 59 seconds to mount the drive after a reboot For my home system this is an acceptable margin of error.

*/10 * * * * /mnt/kd/call_recording.sh

astlinux-usb-cron-job-1

3. Once the script as run it is very easy to listen to recordings using the Astlinux web admin. Just click on the Monitor tab which will display all the recorded phone calls.

astlinux-usb-listen-recordings-2

Make sure to go back and read each part to do call recording on your AstLinux system.

AstLinux Record Phone Calls to External USB Flash Drive Part 1

AstLinux Record Phone Calls to External USB Flash Drive Part 2

From → Linux, VOIP

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

%d bloggers like this: