#!/bin/bash ############################################################ # Decription: IP change # Author: Gilles Mouchet (gmo@ville-ge.ch) # Creation Date: 20-Jun-2018 # Version: 1.1 # Usage: ./vdg-ip, ./stage-ip. ./home-ip # Changelog: # V2.0 - 19-Jan-2025 - GMo # Changed # - Execute script ansible to change ip # V1.0 - 01-Dec-2021 - GMo # Added # - Creation of script from scratch # ############################################################ # execute this script only from consol (not from ssh connection) if [[ -n "$SSH_CONNECTION" ]]; then echo "This script cannot be run from an SSH session." exit 1 fi prog_name=$(basename $0) case $prog_name in stage-ip) # create inventory file echo -e "[stage]\nlocalhost" > inventory ansible-playbook -l stage -i inventory changeIp.yml rm -f nventory ;; home-ip) # create inventory file echo -e "[home]\nlocalhost" > inventory ansible-playbook -l home -i inventory changeIp.yml rm -f inventory ;; vdg-ip) # check if you are vdg network # ping -c2 proxy.ville-geneve.ch > /dev/null 2>&1 #2>&1 >/dev/null # if [ "$?" -ne "0" ]; then # echo "You are not in VdG network" # exit 1 # fi # create inventory file echo -e "[vdg]\nlocalhost" > inventory ansible-playbook -l vdg -i inventory changeIp.yml rm -f inventory ;; *) echo "Usage: ./vdg-ip, ./stage-ip or ./home-ip" exit 1 ;; esac echo "****************************************" echo "* Le serveur est prêt! *" echo "* Nouveau réseau: $prog_name *" echo "* N'oublier pas de changer de RESEAU ! *" echo "* Déconnectez/reconnectez vous pour *" echo "* être certain que le proxy est *" echo "* On ou Off *" echo "****************************************"