Skip to content
Snippets Groups Projects
Commit a42dbfc5 authored by Elian Loraux's avatar Elian Loraux
Browse files

Scipt de bascule réseau côté aquila

parent f0cb3b4b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
# Si tetrix joingnable
# Si etatCourant != Normal
# etatCourrant = Normal
# StopperServiceSurAquila
# Sinon
# Si etatCourant != Backup
# etatCourant = Backup
# DemarrerServiceSurAquila
IPPubliqueTetrixChezOVH="109.190.180.230"
URL="https://$IPPubliqueTetrixChezOVH"
stateFile="/opt/net-state"
reverseSSHproxyPath="/home/dockerweb/reverse-ssh-proxy"
# Faire une requête HTTP et vérifier le code de statut de la réponse
HTTP_STATUS=$(curl -o /dev/null -w "%{http_code}\n" -s -k $URL)
if [[ -f "$stateFile" ]]; then
$state=`cat $stateFile`
# Vérifier si le service est accessible (code de statut 200)
if [ $HTTP_STATUS -eq 200 ]; then
if [[ $state != "normal" ]]; then
# Switch on normal mode
cd $reverseSSHproxyPath
docker-compose down
echo "normal" > "$stateFile"
fi
else
if [[ $state = "normal" ]]; then
# Switch on back up mode
cd $reverseSSHproxyPath
docker-compose up -d
echo "backup" > "$stateFile"
fi
fi
else
echo "normal" > "$stateFile"
fi
......@@ -20,7 +20,6 @@ if [[ -f "$stateFile" ]]; then
if [[ $IPPubliqueTetrixChezOVH == $currentIP ]]; then
if [[ $state != "normal" ]]; then
# Switch on normal mode
# ssh dockerweb@aquila.tetras-libre.fr 'cd reverse-ssh-proxy && docker-compose down'
pid=`ps aux | grep test.sh | grep -v grep | awk '{print $2}'`
kill $pid
change_dns $APIKEY $IPPubliqueTetrixChezOVH
......@@ -29,7 +28,6 @@ if [[ -f "$stateFile" ]]; then
else
if [[ $state = "normal" ]]; then
# Switch on back up mode
# ssh dockerweb@aquila.tetras-libre.fr 'cd reverse-ssh-proxy && docker-compose up'
bash $reverseSSHProxyPath &
change_dns $APIKEY $IPPubliqueAquilaChezOVH
echo "backup" > "$stateFile"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment