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

bugfix

parent ea7cb827
Branches
No related tags found
No related merge requests found
......@@ -16,7 +16,6 @@
# startAquilaService
# ==============================================
tetrixPublicIPOnOVH="109.190.180.230"
URL="https://$tetrixPublicIPOnOVH"
......@@ -28,30 +27,8 @@ reverseSSHproxyPath="/home/dockerweb/reverse-ssh-proxy"
HTTP_STATUS=$(curl -o /dev/null -w "%{http_code}\n" -s -k $URL)
if [[ -f "$stateFile" ]]; then
# ===== function ===== #
$state=`cat $stateFile`
# check if tetrix is reachable (status code 200)
if [ $HTTP_STATUS -eq 200 ]; then
if [[ $state != "normal" ]]; then
# Switch on normal mode
cd $reverseSSHproxyPath
docker-compose down
echo "normal" > "$stateFile"
do_sendmail_start root
fi
else
if [[ $state = "normal" ]]; then
# Switch on back up mode
cd $reverseSSHproxyPath
docker-compose up -d
echo "backup" > "$stateFile"
do_sendmail_stop root
fi
fi
else
echo "normal" > "$stateFile"
fi
do_sendmail_start() {
cat <<EOF | sendmail -t root
......@@ -80,3 +57,29 @@ dès que le réseau repassera en mode de normal (Fibre), ce dernier sera joignab
Cordialement,
EOF
}
if [[ -f "$stateFile" ]]; then
$state=`cat $stateFile`
# check if tetrix is reachable (status code 200)
if [ $HTTP_STATUS -eq 200 ]; then
if [[ $state != "normal" ]]; then
# Switch on normal mode
cd $reverseSSHproxyPath
docker-compose down
echo "normal" > "$stateFile"
do_sendmail_start root
fi
else
if [[ $state == "normal" ]]; then
# Switch on back up mode
cd $reverseSSHproxyPath
docker-compose up -d
echo "backup" > "$stateFile"
do_sendmail_stop root
fi
fi
else
echo "normal" > "$stateFile"
fi
......@@ -29,41 +29,13 @@ APIKEY="PUT YOUT PERSONAL TOKEN" # Jeton sur passbotl
stateFile="/opt/net-state"
currentIP=`curl api.ipify.org`
currentIP=`curl -s api.ipify.org`
reverseSSHProxyPath="/opt/reverseSSHproxy.sh"
recipient="all@tetras-libre.fr"
adminemail="sysadmin@tetras-libre.fr"
# check if file exist
if [[ -f "$stateFile" ]]; then
$state=`cat $stateFile`
# Check if current ip is different of normal ip
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 $tetrixPublicIPOnOVH
echo "normal" > "$stateFile"
do_sendmail_start
fi
else
if [[ $state = "normal" ]]; then
# Switch on back up mode
bash $reverseSSHProxyPath &
change_dns $APIKEY $aquilaPublicIPOnOVH
echo "backup" > "$stateFile"
do_sendmail_stop
fi
fi
else
echo "normal" > "$stateFile"
fi
# ===== Function ==== #
change_dns() {
APIKEY=$1
......@@ -129,3 +101,33 @@ $tetrixPublicIPOnOVH passbolt.tetras-libre.fr
En cas de problème, contactez $adminemail
EOF
}
# check if file exist
if [[ -f "$stateFile" ]]; then
$state=`cat $stateFile`
# Check if current ip is different of normal ip
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 $tetrixPublicIPOnOVH
echo "normal" > "$stateFile"
do_sendmail_start
fi
else
if [[ $state == "normal" ]]; then
# Switch on back up mode
bash $reverseSSHProxyPath &
change_dns $APIKEY $aquilaPublicIPOnOVH
echo "backup" > "$stateFile"
do_sendmail_stop
fi
fi
else
echo "normal" > "$stateFile"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment