diff --git a/auto-start-reverseSSHproxy.sh b/auto-start-reverseSSHproxy.sh new file mode 100644 index 0000000000000000000000000000000000000000..0adfb2e98535d18a64998cd24aefffb9f80af6fc --- /dev/null +++ b/auto-start-reverseSSHproxy.sh @@ -0,0 +1,47 @@ +#!/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 diff --git a/net-switch.sh b/net-switch.sh index 2fad4419c6fd8ac9b80b9e184eae93bdd13bd52b..c6f8b3ca088760e000905a4f883afc6552004735 100644 --- a/net-switch.sh +++ b/net-switch.sh @@ -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"