Skip to content
Snippets Groups Projects
Verified Commit 9c192559 authored by David Beniamine's avatar David Beniamine
Browse files

Update files after test

parent c51c772b
Branches
No related tags found
No related merge requests found
...@@ -31,40 +31,40 @@ HTTP_STATUS=$(curl -o /dev/null -w "%{http_code}\n" -s -k $URL) ...@@ -31,40 +31,40 @@ HTTP_STATUS=$(curl -o /dev/null -w "%{http_code}\n" -s -k $URL)
do_sendmail_start() { do_sendmail_start() {
cat <<EOF | sendmail -t root cat <<EOF | /usr/sbin/sendmail -t root
Subject: [$(hostname)] Serveur Tetrix injoignable Subject: [$(hostname)] Serveur Tetrix injoignable
Bonjour, Bonjour,
$(hostname) viens de detecter que Tetrix est injoignable par son IP normale ($tetrixPublicIPOnOVH). $(hostname) viens de detecter que Tetrix est injoignable par son IP normale ($tetrixPublicIPOnOVH).
Le système d'accès à distance à Tétrix via $(hostname) (reverseSSHproxyPath) est actif, Le systeme d'accès a distance à Tetrix via $(hostname) (reverseSSHproxyPath) est actif,
dès que le réseau passera en mode de secours (4G), ce dernier sera joignable à nouveau. des que le reseau passera en mode de secours (4G), ce dernier sera joignable a nouveau.
Cordialement, Cordialement,
EOF EOF
} }
do_sendmail_stop() { do_sendmail_stop() {
cat <<EOF | sendmail -t root cat <<EOF | /usr/sbin/sendmail -t root
Subject: [$(hostname)] Serveur Tetrix injoignable Subject: [$(hostname)] Serveur Tetrix a nouveau joignable
Bonjour, Bonjour,
$(hostname) viens de detecter que Tetrix est à nouveau joignable par son IP nornale ($tetrixPublicIPOnOVH). $(hostname) viens de detecter que Tetrix est a nouveau joignable par son IP nornale ($tetrixPublicIPOnOVH).
Le système d'accès à distance à Tétrix via $(hostname) (reverseSSHproxyPath) est désactivé, Le systeme d'accès a distance à Tetrix via $(hostname) (reverseSSHproxyPath) est désactivé,
dès que le réseau repassera en mode de normal (Fibre), ce dernier sera joignable à nouveau. des que le reseau repassera en mode de normal (Fibre), ce dernier sera joignable a nouveau.
Cordialement, Cordialement,
EOF EOF
} }
if [[ -f "$stateFile" ]]; then if [ -f "$stateFile" ]; then
$state=`cat $stateFile` state=`cat $stateFile`
# check if tetrix is reachable (status code 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
cd $reverseSSHproxyPath cd $reverseSSHproxyPath
docker-compose down docker-compose down
...@@ -72,7 +72,7 @@ if [[ -f "$stateFile" ]]; then ...@@ -72,7 +72,7 @@ if [[ -f "$stateFile" ]]; then
do_sendmail_start root do_sendmail_start root
fi fi
else else
if [[ $state == "normal" ]]; then if [ $state == "normal" ]; then
# Switch on back up mode # Switch on back up mode
cd $reverseSSHproxyPath cd $reverseSSHproxyPath
docker-compose up -d docker-compose up -d
......
...@@ -45,18 +45,18 @@ change_dns() { ...@@ -45,18 +45,18 @@ change_dns() {
curl -s -X PUT --header "Authorization: Bearer ${APIKEY}" \ curl -s -X PUT --header "Authorization: Bearer ${APIKEY}" \
--header "Content-Type: application/json" \ --header "Content-Type: application/json" \
-d "{\"rrset_values\": [\"${CURRENTIP}\"], \"rrset_ttl\": "300"}" \ -d "{\"rrset_values\": [\"${CURRENTIP}\"], \"rrset_ttl\": "300"}" \
https://api.gandi.net/v5/livedns/domains/tetras-libre.fr/records/tetrixx/A https://api.gandi.net/v5/livedns/domains/tetras-libre.fr/records/tetrix/A
} }
do_sendmail_start() { do_sendmail_start() {
cat <<EOF | sendmail -t $recipient cat <<EOF | /usr/sbin/sendmail -t $recipient
Subject: [$(hostname)] Bascule du réseau en $1 Subject: [$(hostname)] Bascule du reseau en mode secours (4G)
Bonjour, Bonjour,
La bascule automatique du réseau viens de s'activer sur $(hostname). Passage en $1. La bascule automatique du reseau viens de s'activer sur $(hostname). Passage en mode secours (4G).
Pour utiliser gitlab, vous devez ajouter ces lignes dans ~/.ssh/config : Pour utiliser gitlab, vous devez ajouter ces lignes dans ~/.ssh/config :
...@@ -64,7 +64,7 @@ host gitlab.tetras-libre.fr ...@@ -64,7 +64,7 @@ host gitlab.tetras-libre.fr
Port 2223 Port 2223
La bascule se fait via un changement de DNS qui peut mettre un peu de temps à ce propager (3h) max. La bascule se fait via un changement de DNS qui peut mettre un peu de temps a ce propager (3h) max.
Pendant ce temps vous pouvez ajouter les lignes suivantes dans /etc/hosts: Pendant ce temps vous pouvez ajouter les lignes suivantes dans /etc/hosts:
$aquilaPublicIPOnOVH nextcloud.tetras-libre.fr $aquilaPublicIPOnOVH nextcloud.tetras-libre.fr
...@@ -72,7 +72,7 @@ $aquilaPublicIPOnOVH gitlab.tetras-libre.fr ...@@ -72,7 +72,7 @@ $aquilaPublicIPOnOVH gitlab.tetras-libre.fr
$aquilaPublicIPOnOVH dolibarr.tetras-libre.fr $aquilaPublicIPOnOVH dolibarr.tetras-libre.fr
$aquilaPublicIPOnOVH passbolt.tetras-libre.fr $aquilaPublicIPOnOVH passbolt.tetras-libre.fr
En cas de problème, contactez $adminemail En cas de probleme, contactez $adminemail
Cordialement, Cordialement,
EOF EOF
...@@ -80,17 +80,17 @@ EOF ...@@ -80,17 +80,17 @@ EOF
do_sendmail_stop() { do_sendmail_stop() {
cat <<EOF | sendmail -t $recipient cat <<EOF | /usr/sbin/sendmail -t $recipient
Subject: [$(hostname)] Bascule du réseau en $1 Subject: [$(hostname)] Bascule du reseau en mode normal (Fibre)
Bonjour, Bonjour,
La bascule automatique du réseau viens de s'activer sur $(hostname). Passage en $1. La bascule automatique du reseau viens de s'activer sur $(hostname). Passage en mode normal (Fibre).
Pour utiliser gitlab, pensez à supprimer les lignes concernant gitlab.tetras-libre.fr dans ~/.ssh/config. Pour utiliser gitlab, pensez a supprimer les lignes concernant gitlab.tetras-libre.fr dans ~/.ssh/config.
La bascule se fait via un changement de DNS qui peut mettre un peu de temps à ce propager (3h) max. La bascule se fait via un changement de DNS qui peut mettre un peu de temps a ce propager (3h) max.
Pendant ce temps vous pouvez ajouter les lignes suivantes dans /etc/hosts: Pendant ce temps vous pouvez ajouter les lignes suivantes dans /etc/hosts:
$tetrixPublicIPOnOVH nextcloud.tetras-libre.fr $tetrixPublicIPOnOVH nextcloud.tetras-libre.fr
...@@ -98,20 +98,18 @@ $tetrixPublicIPOnOVH gitlab.tetras-libre.fr ...@@ -98,20 +98,18 @@ $tetrixPublicIPOnOVH gitlab.tetras-libre.fr
$tetrixPublicIPOnOVH dolibarr.tetras-libre.fr $tetrixPublicIPOnOVH dolibarr.tetras-libre.fr
$tetrixPublicIPOnOVH passbolt.tetras-libre.fr $tetrixPublicIPOnOVH passbolt.tetras-libre.fr
En cas de problème, contactez $adminemail En cas de probleme, contactez $adminemail
EOF EOF
} }
# check if file exist # check if file exist
if [[ -f "$stateFile" ]]; then 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 [[ $tetrixPublicIPOnOVH == $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
...@@ -120,7 +118,7 @@ if [[ -f "$stateFile" ]]; then ...@@ -120,7 +118,7 @@ if [[ -f "$stateFile" ]]; then
do_sendmail_start do_sendmail_start
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 $aquilaPublicIPOnOVH change_dns $APIKEY $aquilaPublicIPOnOVH
......
#!/bin/bash #!/bin/bash
HTTPS_PORT=8080 HTTPS_PORT=8443
SSHPORT_INT=2223 SSHPORT_INT=2223
SSHPORT=2222 SSHPORT=2222
PROXY_HOST=aquila.tetras-libre.fr PROXY_HOST=aquila.tetras-libre.fr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment