Assorted shell and Python scripts
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
8set -euo pipefail
9
10# Dependency check
11missing_deps=()
12command -v gum >/dev/null || missing_deps+=(gum)
13command -v glances >/dev/null || missing_deps+=(glances)
14
15if (( "${#missing_deps[@]}" != 0 )); then
16 echo "Missing dependencies:" "${missing_deps[@]}"
17 exit 1
18fi
19
20# Check number of args supplied at cli
21if (( "${#@}" == 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
26fi
27
28while
29 selection=$(gum choose "${@}" "Exit" --limit=1 --header="Selection:")
30 [[ "$selection" != "Exit" ]] && glances -c "@$selection" -p 61209
31do true; done