From 6ec4a26e089606bf72e71b3dd02560c3377e0d50 Mon Sep 17 00:00:00 2001 From: Keith Whyte Date: Wed, 6 Mar 2019 10:03:10 +0000 Subject: [PATCH] Script: Don't restart freeswitch, just profiles --- .../files/bin/monitor_freeswitch.sh | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/rhizo_base/files/bin/monitor_freeswitch.sh b/modules/rhizo_base/files/bin/monitor_freeswitch.sh index ccf055b..5cf12d5 100755 --- a/modules/rhizo_base/files/bin/monitor_freeswitch.sh +++ b/modules/rhizo_base/files/bin/monitor_freeswitch.sh @@ -7,14 +7,26 @@ RHIZO_SCRIPT="/home/rhizomatica/bin" LOGFILE="/var/log/monitor_fs.log" -FS_STATUS=`fs_cli -x "sofia status"` +IFS= +FS_STATUS="$(fs_cli -x 'sofia status')" + +if !(echo $FS_STATUS | egrep -q "internal.*172.16.0.1"); then + logc "Missing internal profile! Restarting Profile"; + fs_cli -x "sofia profile internal stop" + sleep 10 + fs_cli -x "sofia profile internal start" +fi if !(echo $FS_STATUS | grep -q "external::provider") && (ping -qc 5 8.8.8.8 > /dev/null); then - logc "Missing external provider! Restarting FreeSWITCH"; - sv restart freeswitch; + logc "Missing external provider! Restarting Profile"; + fs_cli -x "sofia profile external stop" + sleep 10 + fs_cli -x "sofia profile external start" fi -if !(echo $FS_STATUS | grep -q "internalvpn") && (ping -qc 5 10.23.0.2); then - logc "Missing internal VPN! Restarting FreeSWITCH"; - sv restart freeswitch; +if !(echo $FS_STATUS | grep -q "internalvpn") && (ping -qc 5 10.23.0.2 > /dev/null); then + logc "Missing internal VPN. Restarting FreeSWITCH profile"; + fs_cli -x "sofia profile internalvpn stop" + sleep 10 + fs_cli -x "sofia profile internalvpn start" fi