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

improve emails

parent 97f479f2
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ if [[ -f "$stateFile" ]]; then ...@@ -38,6 +38,7 @@ if [[ -f "$stateFile" ]]; then
cd $reverseSSHproxyPath cd $reverseSSHproxyPath
docker-compose down docker-compose down
echo "normal" > "$stateFile" echo "normal" > "$stateFile"
do_sendmail_start root
fi fi
else else
if [[ $state = "normal" ]]; then if [[ $state = "normal" ]]; then
...@@ -45,8 +46,37 @@ if [[ -f "$stateFile" ]]; then ...@@ -45,8 +46,37 @@ if [[ -f "$stateFile" ]]; then
cd $reverseSSHproxyPath cd $reverseSSHproxyPath
docker-compose up -d docker-compose up -d
echo "backup" > "$stateFile" echo "backup" > "$stateFile"
do_sendmail_stop root
fi fi
fi fi
else else
echo "normal" > "$stateFile" echo "normal" > "$stateFile"
fi fi
do_sendmail_start() {
cat <<EOF | sendmail -t root
Subject: [$(hostname)] Serveur Tetrix injoignable
Bonjour,
$(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,
dès que le réseau passera en mode de secours (4G), ce dernier sera joignable à nouveau.
Cordialement,
EOF
}
do_sendmail_stop() {
cat <<EOF | sendmail -t root
Subject: [$(hostname)] Serveur Tetrix injoignable
Bonjour,
$(hostname) viens de detecter que Tetrix est à nouveau joignable par son IP nornale ($tetrixPublicIPOnOVH).
Le système d'accès à distance à Tétrix via $(hostname) (reverseSSHproxyPath) est désactivé,
dès que le réseau repassera en mode de normal (Fibre), ce dernier sera joignable à nouveau.
Cordialement,
EOF
}
net-switch.sh 100644 → 100755
...@@ -32,6 +32,8 @@ stateFile="/opt/net-state" ...@@ -32,6 +32,8 @@ stateFile="/opt/net-state"
currentIP=`curl api.ipify.org` currentIP=`curl api.ipify.org`
reverseSSHProxyPath="/opt/reverseSSHproxy.sh" reverseSSHProxyPath="/opt/reverseSSHproxy.sh"
recipient="all@tetras-libre.fr"
adminemail="sysadmin@tetras-libre.fr"
# check if file exist # check if file exist
if [[ -f "$stateFile" ]]; then if [[ -f "$stateFile" ]]; then
...@@ -46,7 +48,7 @@ if [[ -f "$stateFile" ]]; then ...@@ -46,7 +48,7 @@ if [[ -f "$stateFile" ]]; then
kill $pid kill $pid
change_dns $APIKEY $tetrixPublicIPOnOVH change_dns $APIKEY $tetrixPublicIPOnOVH
echo "normal" > "$stateFile" echo "normal" > "$stateFile"
bash send_maintenance_mail.sh modele-mail-netbascule-stop do_sendmail_start
fi fi
else else
if [[ $state = "normal" ]]; then if [[ $state = "normal" ]]; then
...@@ -54,7 +56,7 @@ if [[ -f "$stateFile" ]]; then ...@@ -54,7 +56,7 @@ if [[ -f "$stateFile" ]]; then
bash $reverseSSHProxyPath & bash $reverseSSHProxyPath &
change_dns $APIKEY $aquilaPublicIPOnOVH change_dns $APIKEY $aquilaPublicIPOnOVH
echo "backup" > "$stateFile" echo "backup" > "$stateFile"
bash send_maintenance_mail.sh modele-mail-netbascule-start do_sendmail_stop
fi fi
fi fi
else else
...@@ -74,3 +76,56 @@ change_dns() { ...@@ -74,3 +76,56 @@ change_dns() {
https://api.gandi.net/v5/livedns/domains/tetras-libre.fr/records/tetrixx/A https://api.gandi.net/v5/livedns/domains/tetras-libre.fr/records/tetrixx/A
} }
do_sendmail_start() {
cat <<EOF | sendmail -t $recipient
Subject: [$(hostname)] Bascule du réseau en $1
Bonjour,
La bascule automatique du réseau viens de s'activer sur $(hostname). Passage en $1.
Pour utiliser gitlab, vous devez ajouter ces lignes dans ~/.ssh/config :
host gitlab.tetras-libre.fr
Port 2223
La bascule se fait via un changement de DNS qui peut mettre un peu de temps à ce propager (3h) max.
Pendant ce temps vous pouvez ajouter les lignes suivantes dans /etc/hosts:
$aquilaPublicIPOnOVH nextcloud.tetras-libre.fr
$aquilaPublicIPOnOVH gitlab.tetras-libre.fr
$aquilaPublicIPOnOVH dolibarr.tetras-libre.fr
$aquilaPublicIPOnOVH passbolt.tetras-libre.fr
En cas de problème, contactez $adminemail
Cordialement,
EOF
}
do_sendmail_stop() {
cat <<EOF | sendmail -t $recipient
Subject: [$(hostname)] Bascule du réseau en $1
Bonjour,
La bascule automatique du réseau viens de s'activer sur $(hostname). Passage en $1.
Pour utiliser gitlab, pensez à 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.
Pendant ce temps vous pouvez ajouter les lignes suivantes dans /etc/hosts:
$tetrixPublicIPOnOVH nextcloud.tetras-libre.fr
$tetrixPublicIPOnOVH gitlab.tetras-libre.fr
$tetrixPublicIPOnOVH dolibarr.tetras-libre.fr
$tetrixPublicIPOnOVH passbolt.tetras-libre.fr
En cas de problème, contactez $adminemail
EOF
}
File mode changed from 100644 to 100755
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment