Select server with bash case based on IP subnet

From DevOps Notebook
Revision as of 09:28, 30 August 2022 by MilosZ (talk | contribs) (Created page with "#!/bin/bash server_ip=hostname -I | cut -d' ' -f1 case "$server_ip" in 10.5.15.*) backup_ip=10.5.15.242 ;; 10.8.15.*) backup_ip=10.8.15.242 ;;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
  1. !/bin/bash

server_ip=hostname -I | cut -d' ' -f1


case "$server_ip" in

   10.5.15.*)
   backup_ip=10.5.15.242
   ;;
   10.8.15.*)
   backup_ip=10.8.15.242
   ;;

10.5.12.*)

   backup_ip=10.5.12.142
   ;;

esac

echo "$backup_ip"