bin/swivel

32 lines
787 B
Plaintext
Raw Normal View History

2024-06-26 08:22:59 +02:00
#!/usr/bin/env bash
# swivel - Easily switch between running glances servers.
#
# Usage:
# swivel 10.0.0.10 10.0.0.11 10.0.0.12
set -euo pipefail
# Dependency check
missing_deps=()
command -v gum >/dev/null || missing_deps+=(gum)
command -v glances >/dev/null || missing_deps+=(glances)
if (( "${#missing_deps[@]}" != 0 )); then
echo "Missing dependencies:" "${missing_deps[@]}"
exit 1
fi
# Check number of args supplied at cli
if (( "${#@}" == 0 )); then
echo "At least one IP address or hostname must be supplied."
echo ""
echo "Usage: swivel <ip_addr0> <ip_addr1> ... <ip addrN>"
exit 1
fi
while
selection=$(gum choose "${@}" "Exit" --limit=1 --header="Selection:")
[[ "$selection" != "Exit" ]] && glances -c "@$selection" -p 61209
do true; done