diff --git a/auto-start-reverseSSHproxy.sh b/auto-start-reverseSSHproxy.sh index 0adfb2e98535d18a64998cd24aefffb9f80af6fc..95279450eb4953639acbf9825476e2c46002618c 100644 --- a/auto-start-reverseSSHproxy.sh +++ b/auto-start-reverseSSHproxy.sh @@ -1,32 +1,37 @@ #!/usr/bin/env bash - -# Si tetrix joingnable +# ============================================== +# +# This is second part of switch network between WAN and 4G +# This script is Aquila part +# +# ============================================== +# if tetrix reachable # Si etatCourant != Normal -# etatCourrant = Normal -# StopperServiceSurAquila +# currentStatre = Normal +# stoppedAquilaService # Sinon -# Si etatCourant != Backup -# etatCourant = Backup -# DemarrerServiceSurAquila - +# Si currentStatre != Backup +# currentStatre = Backup +# startAquilaService +# ============================================== -IPPubliqueTetrixChezOVH="109.190.180.230" +tetrixPublicIPOnOVH="109.190.180.230" -URL="https://$IPPubliqueTetrixChezOVH" +URL="https://$tetrixPublicIPOnOVH" 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 +# Send HTTP request on tetrix to get status code 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) + # check if tetrix is reachable (status code 200) if [ $HTTP_STATUS -eq 200 ]; then if [[ $state != "normal" ]]; then # Switch on normal mode diff --git a/net-switch.sh b/net-switch.sh index c6f8b3ca088760e000905a4f883afc6552004735..a176d2d88e2ac3fd76236bb819ad68cf63fa2230 100644 --- a/net-switch.sh +++ b/net-switch.sh @@ -1,8 +1,30 @@ #!/usr/bin/env bash -IPPubliqueTetrixChezOVH="109.190.180.230" -IPPubliqueAquilaChezOVH="5.135.140.89" +# ============================================== +# +# This is first part of switch network between WAN and 4G +# This script is Tetrix part +# +# ============================================== +# if myPublicIP == tetrixPublicIPOnOVH +# if currentStatre != Normal +# currentStatre = Normal +# stoppedSSHTunnel +# changeTetrixAndWithGandiAPI to tetrixPublicIPOnOVH +# sandMainAtRoot +# Else +# if currentStatre != Backup +# currentStatre = Backup +# startSSHTunnel +# changeTetrixAndWithGandiAPI vers aquilaPublicIPOnOVH +# sandMainAtRoot +# ============================================== + +tetrixPublicIPOnOVH="109.190.180.230" +aquilaPublicIPOnOVH="5.135.140.89" + +# Gandi personal Token APIKEY="PUT YOUT PERSONAL TOKEN" # Jeton sur passbotl stateFile="/opt/net-state" @@ -17,19 +39,19 @@ if [[ -f "$stateFile" ]]; then $state=`cat $stateFile` # Check if current ip is different of normal ip - if [[ $IPPubliqueTetrixChezOVH == $currentIP ]]; then + if [[ $tetrixPublicIPOnOVH == $currentIP ]]; then if [[ $state != "normal" ]]; then # Switch on normal mode pid=`ps aux | grep test.sh | grep -v grep | awk '{print $2}'` kill $pid - change_dns $APIKEY $IPPubliqueTetrixChezOVH + change_dns $APIKEY $tetrixPublicIPOnOVH echo "normal" > "$stateFile" fi else if [[ $state = "normal" ]]; then # Switch on back up mode bash $reverseSSHProxyPath & - change_dns $APIKEY $IPPubliqueAquilaChezOVH + change_dns $APIKEY $aquilaPublicIPOnOVH echo "backup" > "$stateFile" fi fi