Properly handle the lack of "shot name" parameter.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
bridge=
|
||||
cmode=
|
||||
cores=
|
||||
domain=
|
||||
dry_run=false
|
||||
help=false
|
||||
ip=
|
||||
memory=
|
||||
password=
|
||||
pve_host=
|
||||
pve_password=
|
||||
pve_port=
|
||||
pve_ssh_key=
|
||||
pve_user=
|
||||
rootfs_size=
|
||||
ssh_public_keys=
|
||||
swap=
|
||||
tags=
|
||||
template=
|
||||
unprivileged=
|
||||
vlan=
|
||||
short_name='2'
|
||||
Regular → Executable
+6
-9
@@ -14,6 +14,7 @@ usage="Create and configure an LXC container on a remote Proxmox VE 9 server.
|
||||
|
||||
Usage:
|
||||
$0 <short_name> [options]
|
||||
$0 -h|--help
|
||||
|
||||
Options:
|
||||
-h, --help Show this message.
|
||||
@@ -65,19 +66,15 @@ TAGS="${TAGS:-}"
|
||||
SSH_PUBLIC_KEYS="${SSH_PUBLIC_KEYS:-}"
|
||||
|
||||
# --- Parse Arguments with docopts (Lowest Priority) ---
|
||||
|
||||
# This is to prevent set -e from eating the error message from docopts
|
||||
set +e
|
||||
args=$(docopts -h "$usage" : "$@")
|
||||
eval "$args"
|
||||
|
||||
# Short name of the machine (mandatory parameter)
|
||||
SHORT_NAME="${argv[0]:-}"
|
||||
if [ -z "$SHORT_NAME" ]; then
|
||||
echo "❌ Error: The short name of the machine is required." >&2
|
||||
echo "$usage" >&2
|
||||
exit 1
|
||||
fi
|
||||
set -e
|
||||
|
||||
# --- Override with /etc/nixos-infra/hosts/<short_name> (Medium Priority)
|
||||
if [ -f "/etc/nixos-infra/hosts/$SHORT_NAME" ]; then
|
||||
if [ -f "/etc/nixos-infra/hosts/$Short_name" ]; then
|
||||
echo "📄 Applying parameters from /etc/nixos-infra/hosts/$SHORT_NAME..."
|
||||
set -a
|
||||
source "/etc/nixos-infra/hosts/$SHORT_NAME"
|
||||
|
||||
Reference in New Issue
Block a user