Files
harmony/examples/opnsense/scripts/harmony-ve-opnsense-img-src
Jérémy Viau-Trudel e80ad70a4f Design learning tools
Provide diagrams for a Virtualized Execution Environment

Propose interfaces for a cli toolkit
2025-11-06 17:17:51 -05:00

92 lines
1.6 KiB
Plaintext
Executable File

#! /bin/bash
harmony-ve-opnsense-img-src()(
set -eu
[ "${1:-}" != "-d" ] || { set -x ; shift ; }
trap '[ "$?" = "0" ] || >&2 echo ABNORMAL TERMINATION' EXIT
SCRIPTS_DIR=$(readlink -f "$(dirname "${BASH_SOURCE}")")
. "${SCRIPTS_DIR}/common"
OPNSENSE_SRC_BASE_URL=https://pkg.opnsense.org/releases/
DEFAULT_KVM_IMG_DIR=/var/lib/libvirt/images
KVM_IMG_DIR=${KVM_IMG_DIR:-$DEFAULT_KVM_IMG_DIR}
[ -d "$KVM_IMG_DIR" ] || mkdir -p "${KVM_IMG_DIR}"
_short_help(){
cat <<-EOM
NAME
harmony-ve-opnsense-img-src
DESCRIPTION
Manage opnsense source images needed by Harmony Virtual Execution Environment
SYNOPSYS
harmony-vee-opnsense-img-src [GLOBAL_OPTIONS] COMMAND [OPTIONS]
harmony-vee-opnsense-img-src list [--remote]
harmony-vee-opnsense-img-src check [VERSION]
harmony-vee-opnsense-img-src download [VERSION]
harmony-vee-opnsense-img-src delete [VERSION]
EOM
}
_extra_help(){
cat <<-EOM
GLOBAL_OPTIONS
-d Debug mode.
WARNINGS
This script is experimetal. Use with caution.
DETAILS
- for 'list', show local images available
- for 'list --remote', show available upstream images
- for 'check' and 'download', when no VERSION is specified, use the latest
- for 'delete', when no VERSION is specified, delete all image
- use the 'nano' flavor
EOM
}
# Implement functions
case "${1:-}" in
"")
_short_help
;;
-h|--help)
_short_help
_extra_help
;;
# Commands entrypoints
*)
_warn "Unknown COMMAND '$1'"
exit 1
;;
esac
)
[ "$0" != "${BASH_SOURCE}" ] || harmony-ve-opnsense-img-src "${@}"