userdoc:tt_wan_failover

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
userdoc:tt_wan_failover [2019/03/31 17:17]
mknill [PPPoE on Failover Interface]
userdoc:tt_wan_failover [2019/10/13 20:55]
abelbeck
Line 94: Line 94:
      
   esac   esac
 +  
 +  exit 0
 +
 +===== Action Exit Script (optional) =====
 +
 +Conditionally test when a Secondary -> Primary WAN link change occurs, by executing a script.
 +
 +If this script has an exit value of 0 the link change occurs, else with any other exit value the failover remains on the Secondary WAN.
 +
 +The script must be found at ''/mnt/kd/wan-failover-exit.script'' and be made executable...
 +
 +  chmod 755 /mnt/kd/wan-failover-exit.script
 +
 +Example: ''/mnt/kd/wan-failover-exit.script''
 +
 +  #!/bin/sh
 +  
 +  ##
 +  ## wan-failover-exit action script
 +  ##
 +  ## Automatically called before any Secondary -> Primary WAN link change
 +  ## and the Primary WAN link is reachable.
 +  ##
 +  ## If this script has an exit value of 0 the link change occurs.
 +  ## Else with any other exit value, the failover remains on the Secondary WAN.
 +  ##
 +  ## Note: Do not 'sleep' in this script, exit promptly.
 +  ##
 +  state="$1"
 +  primary_if="$2"
 +  primary_gw="$3"
 +  secondary_if="$4"
 +  secondary_gw="$5"
 +  secondary_gw_ipv6="$6"
 +  
 +  ## Sanity check, 'state' must be set properly
 +  if [ "$state" != "SECONDARY_EXIT" ]; then
 +    exit 0
 +  fi
 +  
 +  . /etc/rc.conf
 +  
 +  ##
 +  ## Allow Secondary -> Primary WAN link change ?
 +  ##
 +  
 +  ## Custom user.conf variable, if "yes" failover will not return to the Primary WAN link
 +  if [ "$CUSTOM_WAN_FAILOVER_STICKY" = "yes" ]; then
 +    exit 1
 +  fi
 +  
 +  ## Check Asterisk active calls, remain on the Secondary WAN link until no active calls
 +  active_calls="$(asterisk -rx 'core show channels' | sed -n -r -e 's/^([0-9]+) +active +call.*$/\1/p')"
 +  if [ -n "$active_calls" ] && [ $active_calls -gt 0 ]; then
 +    exit 1
 +  fi
      
   exit 0   exit 0
  • userdoc/tt_wan_failover.txt
  • Last modified: 2021/01/19 13:15
  • by mkeuter