/ swivel
swivel
1 #!/usr/bin/env bash 2 3 # swivel - Easily switch between running glances servers. 4 # 5 # Usage: 6 # swivel 10.0.0.10 10.0.0.11 10.0.0.12 7 8 set -euo pipefail 9 10 # Dependency check 11 missing_deps=() 12 command -v gum >/dev/null || missing_deps+=(gum) 13 command -v glances >/dev/null || missing_deps+=(glances) 14 15 if (( "${#missing_deps[@]}" != 0 )); then 16 echo "Missing dependencies:" "${missing_deps[@]}" 17 exit 1 18 fi 19 20 # Check number of args supplied at cli 21 if (( "${#@}" == 0 )); then 22 echo "At least one IP address or hostname must be supplied." 23 echo "" 24 echo "Usage: swivel <ip_addr0> <ip_addr1> ... <ip addrN>" 25 exit 1 26 fi 27 28 while 29 selection=$(gum choose "${@}" "Exit" --limit=1 --header="Selection:") 30 [[ "$selection" != "Exit" ]] && glances -c "@$selection" -p 61209 31 do true; done