diff --git a/KPAVD-VM-1.conf b/KPAVD-VM-1.conf index dbaa325..7417b25 100644 --- a/KPAVD-VM-1.conf +++ b/KPAVD-VM-1.conf @@ -30,4 +30,11 @@ vrrp_instance { track_npm } + notify_master "/etc/keepalived/add_route.sh" + + notify_backup "/etc/keepalived/rm_route.sh" + + notify_fault "/etc/keepalived/rm_route.sh" + + } diff --git a/KPAVD-VM-2.conf b/KPAVD-VM-2.conf index f8ac8af..66c7ce2 100644 --- a/KPAVD-VM-2.conf +++ b/KPAVD-VM-2.conf @@ -30,4 +30,11 @@ vrrp_instance NPM-V1 { track_npm } + notify_master "/etc/keepalived/add_route.sh" + + notify_backup "/etc/keepalived/rm_route.sh" + + notify_fault "/etc/keepalived/rm_route.sh" + + } diff --git a/KPAVD-VM-3.conf b/KPAVD-VM-3.conf index 1317a1e..7c1f473 100644 --- a/KPAVD-VM-3.conf +++ b/KPAVD-VM-3.conf @@ -30,4 +30,11 @@ vrrp_instance NPM-V1 { track_npm } + notify_master "/etc/keepalived/add_route.sh" + + notify_backup "/etc/keepalived/rm_route.sh" + + notify_fault "/etc/keepalived/rm_route.sh" + + } diff --git a/add_route.sh b/add_route.sh new file mode 100644 index 0000000..d7fc8be --- /dev/null +++ b/add_route.sh @@ -0,0 +1,2 @@ +#!/bin/bash +ip route add via dev \ No newline at end of file diff --git a/check_docker_container.sh b/check_docker_container.sh index 50a2ed1..c5006ff 100644 --- a/check_docker_container.sh +++ b/check_docker_container.sh @@ -16,13 +16,13 @@ container_name=$1 check_container_health() { # Get the health status of the container - health_status=$(sudo docker inspect --format='{{.State.Health.Status}}' "$1") + health_status=$(docker inspect --format='{{.State.Health.Status}}' "$1") # Check the health status and return 0 if healthy, 1 if unhealthy - if [[ "$health_status" = "healthy" > /dev/null 2>&1 ]]; then + if [[ "$health_status" = "healthy" ]]; then return 0 - elif [[ "$health_status" = "starting" > /dev/null 2>&1 ]]; then + elif [[ "$health_status" = "starting" ]]; then echo "Container in starting state" sleep 15 @@ -35,20 +35,20 @@ check_container_health() { } # Debugging output -echo "Checking container: $container_name" +#echo "Checking container: $container_name" -state_restarting=$(sudo docker inspect --format="{{.State.Restarting}}" "$container_name") -state_running=$(sudo docker inspect --format="{{.State.Running}}" "$container_name" 2> /dev/null) +state_restarting=$(docker inspect --format="{{.State.Restarting}}" "$container_name") +state_running=$(docker inspect --format="{{.State.Running}}" "$container_name") # Debugging output -echo "Restarting: $state_restarting" -echo "Running: $state_running" +#echo "Restarting: $state_restarting" +#echo "Running: $state_running" -if [ "$state_restarting" = "false" ] && [ "$state_running" = "true" > /dev/null 2>&1 ]; then - echo "Container is in the expected state. Exiting with status 0." +if [ "$state_restarting" = "false" ] && [ "$state_running" = "true" ]; then + #echo "Container is in the expected state. Exiting with status 0." exit 0 else - echo "Container is not in the expected state. Exiting with status 1." + #echo "Container is not in the expected state. Exiting with status 1." exit 1 fi diff --git a/rm_route.sh b/rm_route.sh new file mode 100644 index 0000000..010b696 --- /dev/null +++ b/rm_route.sh @@ -0,0 +1,2 @@ +#!/bin/bash +ip route del via dev