-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvrrpscript.txt
40 lines (32 loc) · 1.06 KB
/
vrrpscript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
touch /var/log/vrrp.log
echo "`date` Route Check: on $1 using $2 status $3 " >> /var/log/vrrp.log
#Set to LAN Interface (one VRRP is running on)
interface=eth0
#set to group number used on VRRP group
group=100
#use different values for primary and secondary routers.
#inactive on primary should be higher than active of seconary.
#eg) Primary active = 200, Secondary active = 100
# Primary inactive= 150, Secondary inactive = 50
activepriority=200
inactivepriority=100
WLBStatus=$3
echo $WLBStatus
#start config change
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper begin
if [ $WLBStatus = 'inactive' ]
then
newpriority=$inactivepriority
elif [ $WLBStatus = 'active' ]
then
newpriority=$activepriority
fi
echo $newpriority
# change priority
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set interfaces ethernet $interface vrrp vrrp-group $group priority $newpriority
# now commit the changes
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper commit
# finish configuring
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper end
echo "`date` VRRP Priority = $newpriority " >> /var/log/vrrp.log