From ff60f331fd7bdeda6d31483d2fdc395f42ddf979 Mon Sep 17 00:00:00 2001 From: Xavier Lagraula Date: Fri, 1 May 2026 09:43:36 +0200 Subject: [PATCH] Properly handle the lack of "shot name" parameter. --- nixos-infra/scripts/1 | 22 ++++++++++++++++++++++ nixos-infra/scripts/create-lxc-nixos.sh | 15 ++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 nixos-infra/scripts/1 mode change 100644 => 100755 nixos-infra/scripts/create-lxc-nixos.sh diff --git a/nixos-infra/scripts/1 b/nixos-infra/scripts/1 new file mode 100644 index 0000000..58efb82 --- /dev/null +++ b/nixos-infra/scripts/1 @@ -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' diff --git a/nixos-infra/scripts/create-lxc-nixos.sh b/nixos-infra/scripts/create-lxc-nixos.sh old mode 100644 new mode 100755 index 2dcd517..5a283d4 --- a/nixos-infra/scripts/create-lxc-nixos.sh +++ b/nixos-infra/scripts/create-lxc-nixos.sh @@ -14,6 +14,7 @@ usage="Create and configure an LXC container on a remote Proxmox VE 9 server. Usage: $0 [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/ (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"