Add files via upload

This commit is contained in:
YuruC3 2023-12-15 20:05:44 +01:00 committed by GitHub
parent 3d4f443b19
commit d98a22abff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 277 additions and 0 deletions

58
NPM-TEST/KPAVD-VM-1.conf Normal file
View File

@ -0,0 +1,58 @@
vrrp_script track_npm {
script "/etc/keepalived/check_docker_container.sh yuru_app_1"
interval 5
fall 1
rise 30
}
vrrp_instance TEST-NPM-V1 {
state MASTER
interface eth0
virtual_router_id 40
priority 100
advert_int 1
unicast_src_ip 192.168.1.130
unicast_peer {
192.168.1.131
192.168.1.132
}
authentication {
auth_type PASS
auth_pass Loli6969
}
virtual_ipaddress {
192.168.1.125/24
}
track_script {
track_npm
}
}
virtual_server 192.168.1.125 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
protocol TCP
real_server 192.168.1.130 80 {
TCP_CHECK {
connect_timeout 10
}
}
real_server 192.168.1.131 80 {
TCP_CHECK {
connect_timeout 10
}
}
real_server 192.168.1.132 80 {
TCP_CHECK {
connect_timeout 10
}
}
}

58
NPM-TEST/KPAVD-VM-2.conf Normal file
View File

@ -0,0 +1,58 @@
vrrp_script track_npm {
script "/etc/keepalived/check_docker_container.sh npm"
interval 5
fall 1
rise 30
}
vrrp_instance TEST-NPM-V1 {
state BACKUP
interface eth0
virtual_router_id 40
priority 10
advert_int 1
unicast_src_ip 192.168.1.131
unicast_peer {
192.168.1.130
192.168.1.132
}
authentication {
auth_type PASS
auth_pass Loli6969
}
virtual_ipaddress {
192.168.1.125/24
}
track_script {
track_npm
}
}
virtual_server 192.168.1.125 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
protocol TCP
real_server 192.168.1.130 80 {
TCP_CHECK {
connect_timeout 10
}
}
real_server 192.168.1.131 80 {
TCP_CHECK {
connect_timeout 10
}
}
real_server 192.168.1.132 80 {
TCP_CHECK {
connect_timeout 10
}
}
}

58
NPM-TEST/KPAVD-VM-3.conf Normal file
View File

@ -0,0 +1,58 @@
vrrp_script track_npm {
script "/etc/keepalived/check_docker_container.sh npm"
interval 5
fall 1
rise 30
}
vrrp_instance TEST-NPM-V1 {
state BACKUP
interface eth0
virtual_router_id 40
priority 11
advert_int 1
unicast_src_ip 192.168.1.132
unicast_peer {
192.168.1.130
192.168.1.131
}
authentication {
auth_type PASS
auth_pass Loli6969
}
virtual_ipaddress {
192.168.1.125/24
}
track_script {
track_npm
}
}
virtual_server 192.168.1.125 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
protocol TCP
real_server 192.168.1.130 80 {
TCP_CHECK {
connect_timeout 10
}
}
real_server 192.168.1.131 80 {
TCP_CHECK {
connect_timeout 10
}
}
real_server 192.168.1.132 80 {
TCP_CHECK {
connect_timeout 10
}
}
}

View File

@ -0,0 +1,24 @@
virtual_server 192.168.1.125 443 {
delay_loop 6
lb_algo rr
lb_kind NAT
protocol TCP
real_server 192.168.1.130 443 {
TCP_CHECK {
connect_timeout 10
}
}
real_server 192.168.1.131 443 {
TCP_CHECK {
connect_timeout 10
}
}
real_server 192.168.1.132 443 {
TCP_CHECK {
connect_timeout 10
}
}
}

View 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

View File

@ -0,0 +1,57 @@
#!/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-2
rsync -avru /home/$1/npm/ $2@192.168.25.15:/home/$2/npm/
# NODE-3
rsync -avru /home/$1/npm/ $2@192.168.25.17:/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"