2025-05-20 15:52:43 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2025-05-27 15:26:28 +02:00
|
|
|
source /opt/scripts/common.sh
|
2025-05-20 15:52:43 +02:00
|
|
|
|
|
|
|
tmout=120
|
2025-05-27 15:26:28 +02:00
|
|
|
while true ; do
|
2025-05-20 15:52:43 +02:00
|
|
|
echo "I'm the primary pod and you are stopping me. Starting sentinel failover"
|
|
|
|
echo "Waiting for failover to finish..."
|
2025-05-27 15:26:28 +02:00
|
|
|
fo=$(getFailOverStatus)
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Primary has been successfully failed over to a different pod."
|
|
|
|
break
|
|
|
|
fi
|
2025-05-20 15:52:43 +02:00
|
|
|
|
|
|
|
sleep 1
|
|
|
|
tmout=$((tmout - 1))
|
|
|
|
if [ "${tmout}" -le 0 ]; then
|
|
|
|
echo "Failover timed out"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
2025-05-27 15:26:28 +02:00
|
|
|
|
2025-05-20 15:52:43 +02:00
|
|
|
echo "Primary has been successfuly failed over to a different pod."
|
2025-05-27 15:26:28 +02:00
|
|
|
|
|
|
|
echo "Removing myself from the sentinel configuration"
|
|
|
|
sentinelReset $(hostname -f)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to remove myself from the sentinel configuration"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2025-05-20 15:52:43 +02:00
|
|
|
exit 0
|