From 30fa728f9631b6bb1f80306cd1386468a9ef262c Mon Sep 17 00:00:00 2001 From: j Date: Tue, 30 Dec 2025 08:54:11 +1300 Subject: [PATCH] . --- TEMPLATES.md | 15 ++++++--------- source/src/templates.cpp | 29 +++++++++++++---------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/TEMPLATES.md b/TEMPLATES.md index 72705d5..c30ade6 100644 --- a/TEMPLATES.md +++ b/TEMPLATES.md @@ -9,13 +9,13 @@ Every template must follow this directory structure: ``` template-name/ ├── config/ -│ ├── .template_info.env # REQUIRED: Template metadata -│ └── service.env # REQUIRED: Default service configuration -├── install.sh # REQUIRED: Installation script +│ └── service.env # REQUIRED: Default service configuration +├── template_info.env # REQUIRED: Template metadata +├── install.sh # REQUIRED: Installation script ├── uninstall.sh # REQUIRED: Uninstallation script +├── status.sh # REQUIRED: Check service status (needed for 'dropshell list' command) ├── start.sh # OPTIONAL: Start the service ├── stop.sh # OPTIONAL: Stop the service -├── status.sh # REQUIRED: Check service status (needed for 'dropshell list' command) ├── logs.sh # OPTIONAL: View service logs ├── backup.sh # OPTIONAL: Backup service data ├── restore.sh # OPTIONAL: Restore service data @@ -92,20 +92,17 @@ echo "Service and all data destroyed" ## Essential Files -### 1. config/.template_info.env +### 1. template_info.env Template metadata file that defines the template and its requirements. This file is managed by the template author and should NOT be modified by users: ```bash -# Template identifier - MUST match the directory name -TEMPLATE=template-name - # Requirements REQUIRES_HOST_ROOT=false # Whether root access on host is needed REQUIRES_DOCKER=true # Whether Docker is required REQUIRES_DOCKER_ROOT=false # Whether Docker root privileges are needed -# Docker image settings +# Docker image settings (if needed) IMAGE_REGISTRY="docker.io" IMAGE_REPO="vendor/image" IMAGE_TAG="latest" diff --git a/source/src/templates.cpp b/source/src/templates.cpp index 00710e0..ca75c82 100644 --- a/source/src/templates.cpp +++ b/source/src/templates.cpp @@ -800,7 +800,7 @@ For full documentation, see: dropshell help templates ordered_env_vars all_env_vars; std::vector env_files = { "config/" + filenames::service_env, - "config/" + filenames::template_info_env + filenames::template_info_env }; for (const auto& file : env_files) { { // load service.env from the service on this machine. @@ -812,22 +812,19 @@ For full documentation, see: dropshell help templates } } - // determine template name. - auto it = find_var(all_env_vars, "TEMPLATE"); - if (it == all_env_vars.end()) { - error << "TEMPLATE variable not found in " << template_path << std::endl; - return false; - } + std::vector required_vars = { + "REQUIRES_HOST_ROOT", + "REQUIRES_DOCKER", + "REQUIRES_DOCKER_ROOT" + }; - std::string env_template_name = it->second; - if (env_template_name.empty()) { - error << "TEMPLATE variable is empty in " << template_path << std::endl; - return false; - } - - if (env_template_name != template_name) { - error << "TEMPLATE variable is wrong in " << template_path << std::endl; - return false; + for (const auto & required_var : required_vars) + { + auto it = find_var(all_env_vars, required_var); + if (it == all_env_vars.end()) { + error << "Required variable "<< required_var<<" not defined in " << template_path << std::endl; + return false; + } } return true;