.
This commit is contained in:
15
TEMPLATES.md
15
TEMPLATES.md
@@ -9,13 +9,13 @@ Every template must follow this directory structure:
|
|||||||
```
|
```
|
||||||
template-name/
|
template-name/
|
||||||
├── config/
|
├── config/
|
||||||
│ ├── .template_info.env # REQUIRED: Template metadata
|
│ └── service.env # REQUIRED: Default service configuration
|
||||||
│ └── service.env # REQUIRED: Default service configuration
|
├── template_info.env # REQUIRED: Template metadata
|
||||||
├── install.sh # REQUIRED: Installation script
|
├── install.sh # REQUIRED: Installation script
|
||||||
├── uninstall.sh # REQUIRED: Uninstallation script
|
├── uninstall.sh # REQUIRED: Uninstallation script
|
||||||
|
├── status.sh # REQUIRED: Check service status (needed for 'dropshell list' command)
|
||||||
├── start.sh # OPTIONAL: Start the service
|
├── start.sh # OPTIONAL: Start the service
|
||||||
├── stop.sh # OPTIONAL: Stop 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
|
├── logs.sh # OPTIONAL: View service logs
|
||||||
├── backup.sh # OPTIONAL: Backup service data
|
├── backup.sh # OPTIONAL: Backup service data
|
||||||
├── restore.sh # OPTIONAL: Restore service data
|
├── restore.sh # OPTIONAL: Restore service data
|
||||||
@@ -92,20 +92,17 @@ echo "Service and all data destroyed"
|
|||||||
|
|
||||||
## Essential Files
|
## 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:
|
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
|
```bash
|
||||||
# Template identifier - MUST match the directory name
|
|
||||||
TEMPLATE=template-name
|
|
||||||
|
|
||||||
# Requirements
|
# Requirements
|
||||||
REQUIRES_HOST_ROOT=false # Whether root access on host is needed
|
REQUIRES_HOST_ROOT=false # Whether root access on host is needed
|
||||||
REQUIRES_DOCKER=true # Whether Docker is required
|
REQUIRES_DOCKER=true # Whether Docker is required
|
||||||
REQUIRES_DOCKER_ROOT=false # Whether Docker root privileges are needed
|
REQUIRES_DOCKER_ROOT=false # Whether Docker root privileges are needed
|
||||||
|
|
||||||
# Docker image settings
|
# Docker image settings (if needed)
|
||||||
IMAGE_REGISTRY="docker.io"
|
IMAGE_REGISTRY="docker.io"
|
||||||
IMAGE_REPO="vendor/image"
|
IMAGE_REPO="vendor/image"
|
||||||
IMAGE_TAG="latest"
|
IMAGE_TAG="latest"
|
||||||
|
|||||||
@@ -800,7 +800,7 @@ For full documentation, see: dropshell help templates
|
|||||||
ordered_env_vars all_env_vars;
|
ordered_env_vars all_env_vars;
|
||||||
std::vector<std::string> env_files = {
|
std::vector<std::string> env_files = {
|
||||||
"config/" + filenames::service_env,
|
"config/" + filenames::service_env,
|
||||||
"config/" + filenames::template_info_env
|
filenames::template_info_env
|
||||||
};
|
};
|
||||||
for (const auto& file : env_files) {
|
for (const auto& file : env_files) {
|
||||||
{ // load service.env from the service on this machine.
|
{ // load service.env from the service on this machine.
|
||||||
@@ -812,22 +812,19 @@ For full documentation, see: dropshell help templates
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine template name.
|
std::vector<std::string> required_vars = {
|
||||||
auto it = find_var(all_env_vars, "TEMPLATE");
|
"REQUIRES_HOST_ROOT",
|
||||||
if (it == all_env_vars.end()) {
|
"REQUIRES_DOCKER",
|
||||||
error << "TEMPLATE variable not found in " << template_path << std::endl;
|
"REQUIRES_DOCKER_ROOT"
|
||||||
return false;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
std::string env_template_name = it->second;
|
for (const auto & required_var : required_vars)
|
||||||
if (env_template_name.empty()) {
|
{
|
||||||
error << "TEMPLATE variable is empty in " << template_path << std::endl;
|
auto it = find_var(all_env_vars, required_var);
|
||||||
return false;
|
if (it == all_env_vars.end()) {
|
||||||
}
|
error << "Required variable "<< required_var<<" not defined 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user