This repository was archived by the owner on Jan 16, 2024. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 1 file changed +45
-1
lines changed Expand file tree Collapse file tree 1 file changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,12 @@ get_vrouter_password() {
5353    echo  $password 
5454}
5555
56+ get_check_script () {
57+     script=" $VROUTER_KEEPALIVED_CHECK_SCRIPT " 
58+ 
59+     echo  $script 
60+ }
61+ 
5662get_iface_var () {
5763    var_name=" $1 _$2 " 
5864    var=$( eval " echo \"\$ {$var_name }\" " ) 
8187EOT 
8288}
8389
90+ gen_check_script () {
91+     script=" $( get_check_script) " 
92+ 
93+     if  [ -n  " $script " ;  then 
94+         cat << EOT 
95+ vrrp_script chk_script { 
96+   script "$script " 
97+   interval 2 
98+   fall 2 
99+   rise 2 
100+ } 
101+ 
102+ EOT 
103+     fi 
104+ }
105+ 
84106gen_auth () {
85107    password=$( get_vrouter_password) 
86108
94116    fi 
95117}
96118
119+ gen_track () {
120+     script=" $( get_check_script) " 
121+ 
122+     if  [ -n  " $script " ;  then 
123+         cat << EOT 
124+ track_script { 
125+     chk_script 
126+   } 
127+ EOT 
128+     fi 
129+ }
130+ 
131+ gen_preempt () {
132+     script=" $( get_check_script) " 
133+ 
134+     if  [ -z  " $script " ;  then 
135+         echo  nopreempt
136+     fi 
137+ }
138+ 
97139gen_instances () {
98140    for  interface  in  $( get_context_interfaces) ;  do 
99141        vrouter_ip=$( get_iface_var $interface  VROUTER_IP) 
@@ -111,7 +153,8 @@ vrrp_instance $interface {
111153    $vrouter_ip  
112154  } 
113155  $( gen_auth)  
114-   nopreempt 
156+   $( gen_track)  
157+   $( gen_preempt)  
115158} 
116159
117160EOT 
133176(
134177
135178gen_group
179+ gen_check_script
136180gen_instances
137181
138182) >  /etc/keepalived/keepalived.conf
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments