This commit is contained in:
2022-04-18 11:21:20 +08:00
commit 45a7af638f
210 changed files with 8997 additions and 0 deletions

56
keepalived/ADD/ccmd Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/bash
##################################################
# Docker #
# - --privileged #
# - --net host #
# Mount dir #
# - /etc/keepalived/ #
# - LOG_DIR #
##################################################
set -euo pipefail
export LANG=en_US.UTF-8
trap Quit EXIT
PIDS=
GOT_SIGTERM=
LOG_DIR='/var/log/keepalived'
function Print {
local file=/dev/null
[ '-f' = "$1" ] && file=$2 && shift && shift
date +"[%F %T] $*" | tee -a $file
}
function Quit {
Print killing keepalived ...
while :; do
pkill -f keepalived && Print killing keepalived ... || break
sleep 1
done
Print Container stopped.
test -n "$GOT_SIGTERM"
}
function StartProc {
Print Start keeplived ...
rm -rf /var/run/keepalived
keepalived -f /etc/keepalived/keepalived.conf -lDGn &>> $LOG_DIR/keepalived.log &
PIDS="$PIDS $!"
}
function Main {
local pid=
StartProc
trap "GOT_SIGTERM=1; Print Got SIGTERM ..." SIGTERM
while [ -z "$GOT_SIGTERM" ] && sleep 1; do
for pid in $PIDS; do
[ ! -e /proc/$pid ] && Print Unexpected error! && exit
done
done
}
# Start here
Main