default_value_changes
This commit is contained in:
33
KeepAliveD_config/KPAVD-VM-1.conf
Normal file
33
KeepAliveD_config/KPAVD-VM-1.conf
Normal file
@@ -0,0 +1,33 @@
|
||||
vrrp_script track_npm {
|
||||
script "/etc/keepalived/check_docker_container.sh <name_of_your_container>"
|
||||
interval 5
|
||||
fall 1
|
||||
rise 30
|
||||
}
|
||||
|
||||
vrrp_instance NPM-V1 {
|
||||
state MASTER
|
||||
interface eth0
|
||||
virtual_router_id 40
|
||||
priority 100
|
||||
advert_int 1
|
||||
|
||||
unicast_src_ip <NODE_IP>
|
||||
unicast_peer {
|
||||
<PEER_IP>
|
||||
}
|
||||
|
||||
authentication {
|
||||
auth_type PASS
|
||||
auth_pass <CHANGE_TO_8-CHARACTER_PASSWORD>
|
||||
}
|
||||
|
||||
virtual_ipaddress {
|
||||
<VIRTUAL_IP>/<SUBNETMASK>
|
||||
}
|
||||
|
||||
track_script {
|
||||
track_npm
|
||||
}
|
||||
|
||||
}
|
||||
33
KeepAliveD_config/KPAVD-VM-2.conf
Normal file
33
KeepAliveD_config/KPAVD-VM-2.conf
Normal file
@@ -0,0 +1,33 @@
|
||||
vrrp_script track_npm {
|
||||
script "/etc/keepalived/check_docker_container.sh <name_of_your_container>"
|
||||
interval 5
|
||||
fall 1
|
||||
rise 30
|
||||
}
|
||||
|
||||
vrrp_instance NPM-V1 {
|
||||
state BACKUP
|
||||
interface eth0
|
||||
virtual_router_id 40
|
||||
priority 10
|
||||
advert_int 1
|
||||
|
||||
unicast_src_ip <NODE_IP>
|
||||
unicast_peer {
|
||||
<PEER_IP>
|
||||
}
|
||||
|
||||
authentication {
|
||||
auth_type PASS
|
||||
auth_pass <CHANGE_TO_8-CHARACTER_PASSWORD>
|
||||
}
|
||||
|
||||
virtual_ipaddress {
|
||||
<VIRTUAL_IP>/<SUBNETMASK>
|
||||
}
|
||||
|
||||
track_script {
|
||||
track_npm
|
||||
}
|
||||
|
||||
}
|
||||
33
KeepAliveD_config/KPAVD-VM-3.conf
Normal file
33
KeepAliveD_config/KPAVD-VM-3.conf
Normal file
@@ -0,0 +1,33 @@
|
||||
vrrp_script track_npm {
|
||||
script "/etc/keepalived/check_docker_container.sh <name_of_your_container>"
|
||||
interval 5
|
||||
fall 1
|
||||
rise 30
|
||||
}
|
||||
|
||||
vrrp_instance NPM-V1 {
|
||||
state BACKUP
|
||||
interface eth0
|
||||
virtual_router_id 40
|
||||
priority 11
|
||||
advert_int 1
|
||||
|
||||
unicast_src_ip <NODE_IP>
|
||||
unicast_peer {
|
||||
<PEER_IP>
|
||||
}
|
||||
|
||||
authentication {
|
||||
auth_type PASS
|
||||
auth_pass <CHANGE_TO_8-CHARACTER_PASSWORD>
|
||||
}
|
||||
|
||||
virtual_ipaddress {
|
||||
<VIRTUAL_IP>/<SUBNETMASK>
|
||||
}
|
||||
|
||||
track_script {
|
||||
track_npm
|
||||
}
|
||||
|
||||
}
|
||||
22
KeepAliveD_config/check_docker_container.sh
Normal file
22
KeepAliveD_config/check_docker_container.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
container_name=$1
|
||||
|
||||
# Debugging output
|
||||
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)
|
||||
|
||||
# Debugging output
|
||||
echo "Restarting: $state_restarting"
|
||||
echo "Running: $state_running"
|
||||
|
||||
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."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
55
KeepAliveD_config/rsync_between_nodes.sh
Normal file
55
KeepAliveD_config/rsync_between_nodes.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CHECK IF ALL ARGUMENTS HAVE BEEN PASSED
|
||||
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
|
||||
|
||||
echo "You need to pass three arguments."
|
||||
echo "frst argument == container name"
|
||||
echo "scnd argument == local_username"
|
||||
echo "thrd argument == remote_username"
|
||||
|
||||
exit
|
||||
|
||||
fi
|
||||
|
||||
# RSYNC FUNCTION
|
||||
rsync_npmz () {
|
||||
# $1 == local_username input
|
||||
# $2 == remote_username input
|
||||
|
||||
# NODE-1
|
||||
rsync -avru /home/$1/npm/ $2@<NODE_1_IP>:/home/$2/npm/
|
||||
|
||||
# NODE-2
|
||||
rsync -avru /home/$1/npm/ $2@<NODE_2_IP>:/home/$2/npm/
|
||||
|
||||
}
|
||||
|
||||
# DEF VARIABLE NAMES
|
||||
container_name=$1
|
||||
local_username=$2
|
||||
remote_username=$3
|
||||
|
||||
state_restarting=$(sudo docker inspect --format="{{.State.Restarting}}" "$container_name")
|
||||
state_running=$(sudo docker inspect --format="{{.State.Running}}" "$container_name" 2> /dev/null)
|
||||
|
||||
# MAIN CODE
|
||||
if [ "$state_restarting" = "false" ] && [ "$state_running" = "true" ]; then
|
||||
|
||||
echo "Container is up, that's goood."
|
||||
|
||||
sleep 30;
|
||||
|
||||
rsync_npmz $local_username $remote_username
|
||||
|
||||
else
|
||||
echo "Container is down, tho it should not be."
|
||||
|
||||
rsync_npmz $local_username $remote_username
|
||||
fi
|
||||
|
||||
# AFTER RSYNCING
|
||||
sudo docker-compose -f "/home/$local_username/npm/docker-compose.yml" up
|
||||
|
||||
echo "NPM has been started."
|
||||
echo "Bye"
|
||||
Reference in New Issue
Block a user