Add swivel

This commit is contained in:
Jeffrey Serio 2024-06-26 01:22:59 -05:00
parent 662ebf0182
commit fdad459398

31
swivel Executable file
View File

@ -0,0 +1,31 @@
#!/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