myshellconfig/bin/haproxy-maintenance
2022-06-15 15:18:22 +02:00

59 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
function help() {
cat << EOF
Usage: $(basename $0) <action> <node>
<action> [enable|disable|help]
<node> Nomenklatur ist <svc><cluster><env><node>
<svc> [jra|cnf] 3 characters
<cluster> [0-9] 1 character
<env> [pte] 1 character
<node> [0-9] 1 character
EOF
}
case $1 in
enable)
ACTION=enable
;;
disable)
ACTION=disable
;;
help)
help
exit 0
;;
*)
help
exit 1
;;
esac
shift
UMG=${1:4:1}
CLUSTER=${1:0:4}
NODE=${1:5:1}
LBS=( atlb${UMG}1 atlb${UMG}2 )
BACKENDS=( ${CLUSTER} ${CLUSTER}_direct )
SERVERS=( ${CLUSTER}${NODE} ${CLUSTER}${NODE}d )
HAADMINSOCK=/run/haproxy/admin.sock
i=0
while [ $i -lt ${#BACKENDS[@]} ];do
cat << EOF
Action: $ACTION
Umgebung: $UMG
Cluster: $CLUSTER
Node: $NODE
Loadbalancers: ${LBS[*]}
Backend: ${BACKENDS[$i]}
Server: ${SERVERS[$i]}
------------------------------------
EOF
parallel-ssh -i $(for l in ${LBS[@]};do echo -H $l;done) "echo '$ACTION server ${BACKENDS[$i]}/${SERVERS[$i]}'|socat stdio $HAADMINSOCK"
i=$((i+1))
done