You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
861 B
53 lines
861 B
#!/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
|