diff --git a/auto-start-reverseSSHproxy.sh b/auto-start-reverseSSHproxy.sh index c93adf4ae7fe10bb6060f56c6e5646e4dc4afc6e..33b683133f8ca220747d75ebe68955382358d1be 100755 --- a/auto-start-reverseSSHproxy.sh +++ b/auto-start-reverseSSHproxy.sh @@ -31,40 +31,40 @@ HTTP_STATUS=$(curl -o /dev/null -w "%{http_code}\n" -s -k $URL) do_sendmail_start() { -cat <<EOF | sendmail -t root +cat <<EOF | /usr/sbin/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. +Le systeme d'accès a distance à Tetrix via $(hostname) (reverseSSHproxyPath) est actif, +des que le reseau passera en mode de secours (4G), ce dernier sera joignable a nouveau. Cordialement, EOF } do_sendmail_stop() { -cat <<EOF | sendmail -t root -Subject: [$(hostname)] Serveur Tetrix injoignable +cat <<EOF | /usr/sbin/sendmail -t root +Subject: [$(hostname)] Serveur Tetrix a nouveau joignable 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. +$(hostname) viens de detecter que Tetrix est a nouveau joignable par son IP nornale ($tetrixPublicIPOnOVH). +Le systeme d'accès a distance à Tetrix via $(hostname) (reverseSSHproxyPath) est désactivé, +des que le reseau repassera en mode de normal (Fibre), ce dernier sera joignable a nouveau. Cordialement, EOF } -if [[ -f "$stateFile" ]]; then +if [ -f "$stateFile" ]; then - $state=`cat $stateFile` + state=`cat $stateFile` # check if tetrix is reachable (status code 200) if [ $HTTP_STATUS -eq 200 ]; then - if [[ $state != "normal" ]]; then + if [ $state != "normal" ]; then # Switch on normal mode cd $reverseSSHproxyPath docker-compose down @@ -72,7 +72,7 @@ if [[ -f "$stateFile" ]]; then do_sendmail_start root fi else - if [[ $state == "normal" ]]; then + if [ $state == "normal" ]; then # Switch on back up mode cd $reverseSSHproxyPath docker-compose up -d diff --git a/net-switch.sh b/net-switch.sh index 665cea80b8a34cdb756a32872a9827687d3682da..82a321276d08b808cbe38460a8bd974a6fb657fb 100755 --- a/net-switch.sh +++ b/net-switch.sh @@ -45,18 +45,18 @@ change_dns() { curl -s -X PUT --header "Authorization: Bearer ${APIKEY}" \ --header "Content-Type: application/json" \ -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() { -cat <<EOF | sendmail -t $recipient -Subject: [$(hostname)] Bascule du réseau en $1 +cat <<EOF | /usr/sbin/sendmail -t $recipient +Subject: [$(hostname)] Bascule du reseau en mode secours (4G) 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 : @@ -64,7 +64,7 @@ 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. +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: $aquilaPublicIPOnOVH nextcloud.tetras-libre.fr @@ -72,7 +72,7 @@ $aquilaPublicIPOnOVH gitlab.tetras-libre.fr $aquilaPublicIPOnOVH dolibarr.tetras-libre.fr $aquilaPublicIPOnOVH passbolt.tetras-libre.fr -En cas de problème, contactez $adminemail +En cas de probleme, contactez $adminemail Cordialement, EOF @@ -80,17 +80,17 @@ EOF do_sendmail_stop() { -cat <<EOF | sendmail -t $recipient -Subject: [$(hostname)] Bascule du réseau en $1 +cat <<EOF | /usr/sbin/sendmail -t $recipient +Subject: [$(hostname)] Bascule du reseau en mode normal (Fibre) 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: $tetrixPublicIPOnOVH nextcloud.tetras-libre.fr @@ -98,20 +98,18 @@ $tetrixPublicIPOnOVH gitlab.tetras-libre.fr $tetrixPublicIPOnOVH dolibarr.tetras-libre.fr $tetrixPublicIPOnOVH passbolt.tetras-libre.fr -En cas de problème, contactez $adminemail +En cas de probleme, contactez $adminemail EOF } - - # 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 - if [[ $tetrixPublicIPOnOVH == $currentIP ]]; then - if [[ $state != "normal" ]]; 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 @@ -120,7 +118,7 @@ if [[ -f "$stateFile" ]]; then do_sendmail_start fi else - if [[ $state == "normal" ]]; then + if [ $state == "normal" ]; then # Switch on back up mode bash $reverseSSHProxyPath & change_dns $APIKEY $aquilaPublicIPOnOVH diff --git a/reverseSSHproxy.sh b/reverseSSHproxy.sh index 64d977d529360358b6e53d1d98bafb3ecc25c812..0c9a0f6acc602e715a11485069f76bb5af4494ca 100755 --- a/reverseSSHproxy.sh +++ b/reverseSSHproxy.sh @@ -1,5 +1,5 @@ #!/bin/bash -HTTPS_PORT=8080 +HTTPS_PORT=8443 SSHPORT_INT=2223 SSHPORT=2222 PROXY_HOST=aquila.tetras-libre.fr