In some cases, it is necessary to save call recordings on a network drive. This example shows how to connect a shared Windows folder to MikoPBX.
mkdir /storage/usbdisk1/mikopbx/custom_modules/shared-folder-script
/cat > /storage/usbdisk1/mikopbx/custom_modules/shared-folder-script/mount-shared-folder.sh
#!/bin/sh
HOST='//172.16.32.38/SharedFolder';
USER='';
PASS='';
REC_DIR='autorecords';
mountPoint='/storage/win-shared';
createLink ()
{
subDir="$(date '+%Y/%m')";
monitorDir="$(/bin/busybox grep monitordir < /etc/inc/mikopbx-settings.json | /bin/busybox cut -f 4 -d '"')";
if [ "${monitorDir}x" = 'x' ];then
echo "Empty monitor dir";
return;
fi;
/bin/busybox mkdir -p "$monitorDir" "$mountPoint/$REC_DIR/$subDir";
if [ ! -L "$monitorDir/$subDir" ] && [ -d "$monitorDir/$subDir" ];then
cp -r "$monitorDir/$subDir/"* "$mountPoint/$REC_DIR/$subDir";
rm -rf "${monitorDir:?}/$subDir/";
ln -s "$mountPoint/$REC_DIR/$subDir" "${monitorDir:?}/$subDir";
fi;
if [ ! -L "$monitorDir/$subDir" ] && [ ! -f "${monitorDir:?}/$subDir" ]; then
ln -s "$mountPoint/$REC_DIR/$subDir" "${monitorDir:?}/$subDir";
fi;
}
/bin/busybox mount | /bin/busybox grep "$HOST";
resGrep="$?";
if [ "$resGrep" = "0" ]; then
echo "Disk is mounted..."
createLink;
exit 2;
fi;
mkdir -p "$mountPoint";
/bin/busybox mount -t cifs "$HOST" "$mountPoint" -o "username=$USER,password=$PASS,vers=2.0"
resMount="$?";
if [ "$resMount" != '0' ];then
echo "Error mount $HOST"
exit 1;
fi;
createLink;
chmod +x /storage/usbdisk1/mikopbx/custom_modules/shared-folder-script/mount-shared-folder.sh
*/1 * * * * /storage/usbdisk1/mikopbx/custom_modules/shared-folder-script/mount-shared-folder.sh > /dev/null 2> /dev/null
Test the PBX operation to ensure that call recordings are being saved to the network drive.