3 changed files with 61 additions and 28 deletions
-
9README.md
-
53bin/pct-info
-
27install.sh
@ -0,0 +1,53 @@ |
|||||
|
#!/usr/bin/env bash |
||||
|
|
||||
|
# CONSTANTS |
||||
|
|
||||
|
BASEDIR=$(dirname "$0") |
||||
|
|
||||
|
# FUNCTIONS |
||||
|
|
||||
|
function usage { |
||||
|
echo "usage: $(basename "$0") < list-bridges | list-zfs-pools >" |
||||
|
} |
||||
|
|
||||
|
function parse_options { |
||||
|
while [[ $# -gt 0 ]]; do |
||||
|
case "$1" in |
||||
|
'list-bridges'|'list-zfs-pools') |
||||
|
COMMAND=$1 |
||||
|
;; |
||||
|
--help | -h) |
||||
|
usage && exit 0 |
||||
|
;; |
||||
|
*) |
||||
|
echo >&2 "Unknown option: $1" && usage && exit 2 |
||||
|
;; |
||||
|
esac |
||||
|
|
||||
|
shift 1 # Move to the next argument |
||||
|
done |
||||
|
} |
||||
|
|
||||
|
function assert_command { |
||||
|
[[ -z ${COMMAND:-} ]] && usage && exit 3 |
||||
|
true |
||||
|
} |
||||
|
|
||||
|
function perform { |
||||
|
case "$COMMAND" in |
||||
|
'list-bridges') |
||||
|
pvesh get /nodes/$(hostname)/network --output-format json | jq -r '.[] | select(.type == "bridge") | .iface' |
||||
|
;; |
||||
|
'list-zfs-pools') |
||||
|
pvesm status | grep zfspool | cut -d' ' -f1 |
||||
|
;; |
||||
|
esac |
||||
|
} |
||||
|
|
||||
|
|
||||
|
# MAIN |
||||
|
|
||||
|
set -Eue |
||||
|
parse_options $* |
||||
|
assert_command |
||||
|
perform |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue