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

switch all comments in English

parent a42dbfc5
Branches
No related tags found
No related merge requests found
#!/usr/bin/env bash #!/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 # Si etatCourant != Normal
# etatCourrant = Normal # currentStatre = Normal
# StopperServiceSurAquila # stoppedAquilaService
# Sinon # Sinon
# Si etatCourant != Backup # Si currentStatre != Backup
# etatCourant = Backup # currentStatre = Backup
# DemarrerServiceSurAquila # startAquilaService
# ==============================================
IPPubliqueTetrixChezOVH="109.190.180.230" tetrixPublicIPOnOVH="109.190.180.230"
URL="https://$IPPubliqueTetrixChezOVH" URL="https://$tetrixPublicIPOnOVH"
stateFile="/opt/net-state" stateFile="/opt/net-state"
reverseSSHproxyPath="/home/dockerweb/reverse-ssh-proxy" 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) HTTP_STATUS=$(curl -o /dev/null -w "%{http_code}\n" -s -k $URL)
if [[ -f "$stateFile" ]]; then if [[ -f "$stateFile" ]]; then
$state=`cat $stateFile` $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 [ $HTTP_STATUS -eq 200 ]; then
if [[ $state != "normal" ]]; then if [[ $state != "normal" ]]; then
# Switch on normal mode # Switch on normal mode
......
#!/usr/bin/env bash #!/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 APIKEY="PUT YOUT PERSONAL TOKEN" # Jeton sur passbotl
stateFile="/opt/net-state" stateFile="/opt/net-state"
...@@ -17,19 +39,19 @@ if [[ -f "$stateFile" ]]; then ...@@ -17,19 +39,19 @@ if [[ -f "$stateFile" ]]; then
$state=`cat $stateFile` $state=`cat $stateFile`
# Check if current ip is different of normal ip # Check if current ip is different of normal ip
if [[ $IPPubliqueTetrixChezOVH == $currentIP ]]; then if [[ $tetrixPublicIPOnOVH == $currentIP ]]; then
if [[ $state != "normal" ]]; then if [[ $state != "normal" ]]; then
# Switch on normal mode # Switch on normal mode
pid=`ps aux | grep test.sh | grep -v grep | awk '{print $2}'` pid=`ps aux | grep test.sh | grep -v grep | awk '{print $2}'`
kill $pid kill $pid
change_dns $APIKEY $IPPubliqueTetrixChezOVH change_dns $APIKEY $tetrixPublicIPOnOVH
echo "normal" > "$stateFile" echo "normal" > "$stateFile"
fi fi
else else
if [[ $state = "normal" ]]; then if [[ $state = "normal" ]]; then
# Switch on back up mode # Switch on back up mode
bash $reverseSSHProxyPath & bash $reverseSSHProxyPath &
change_dns $APIKEY $IPPubliqueAquilaChezOVH change_dns $APIKEY $aquilaPublicIPOnOVH
echo "backup" > "$stateFile" echo "backup" > "$stateFile"
fi fi
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment