Assorted shell and Python scripts

Add swivel

Changed files
+31
+31
swivel
···
+
#!/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