mirror of
https://codeberg.org/hyperreal/bin
synced 2024-11-01 08:33:06 +01:00
Add swivel
This commit is contained in:
parent
662ebf0182
commit
fdad459398
31
swivel
Executable file
31
swivel
Executable 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
|
Loading…
Reference in New Issue
Block a user