docs: Update 2 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 24s
Build-Test-Publish / build (linux/arm64) (push) Successful in 56s

This commit is contained in:
j
2026-01-03 00:04:10 +13:00
parent 0f76caa0c8
commit 8bff8a739f
2 changed files with 88 additions and 0 deletions

View File

@@ -306,6 +306,60 @@ _check_required_env_vars "CONTAINER_NAME"
docker logs "$CONTAINER_NAME" "$@" docker logs "$CONTAINER_NAME" "$@"
``` ```
### check-config.sh
Validates the service configuration without restarting or modifying the service. **OPTIONAL** - if not provided, `dropshell check-config` reports that the template doesn't support this command.
This is useful for:
- Validating configuration changes before applying them
- Checking syntax errors in config files
- Verifying that required dependencies are available
```bash
#!/bin/bash
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME"
# Example: Validate nginx configuration
docker exec "$CONTAINER_NAME" nginx -t || _die "Configuration validation failed"
echo "Configuration is valid"
```
### reload-config.sh
Hot-reloads the service configuration without restarting the container. **OPTIONAL** - if not provided, `dropshell reload-config` reports that the template doesn't support this command.
This is useful for services that support graceful configuration reloading:
- Web servers (nginx, Caddy, Apache)
- Reverse proxies and load balancers
- Database connection pools
**Note:** Before reload-config.sh runs, Dropshell automatically syncs the latest configuration files to the remote server.
```bash
#!/bin/bash
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME"
# Example: Reload nginx configuration
docker exec "$CONTAINER_NAME" nginx -s reload || _die "Failed to reload configuration"
echo "Configuration reloaded successfully"
```
**Example for Caddy:**
```bash
#!/bin/bash
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME"
# Caddy supports hot-reload via API
docker exec "$CONTAINER_NAME" caddy reload --config /etc/caddy/Caddyfile || _die "Failed to reload Caddy"
echo "Caddy configuration reloaded"
```
### backup.sh ### backup.sh
Backs up persistent data for a service. **OPTIONAL** - if not provided, `dropshell backup` reports "nothing to backup". Backs up persistent data for a service. **OPTIONAL** - if not provided, `dropshell backup` reports "nothing to backup".

View File

@@ -7,6 +7,8 @@
#include "services.hpp" #include "services.hpp"
#include "utils/output.hpp" #include "utils/output.hpp"
#include <filesystem>
namespace dropshell namespace dropshell
{ {
@@ -96,6 +98,22 @@ namespace dropshell
return false; return false;
} }
// Check if the template supports check-config
LocalServiceInfo service_info = get_service_info(server, service);
if (!SIvalid(service_info))
{
error << "Service " << service << " not found on server " << server << std::endl;
return false;
}
std::filesystem::path script_path = std::filesystem::path(service_info.local_template_path) / "check-config.sh";
if (!std::filesystem::exists(script_path))
{
info << "Template '" << service_info.template_name << "' does not support the check-config command." << std::endl;
debug << "To add support, create: " << script_path.filename().string() << std::endl;
return false;
}
// Sync configuration to remote // Sync configuration to remote
info << "Syncing configuration for " << service << " on " << server << "..." << std::endl; info << "Syncing configuration for " << service << " on " << server << "..." << std::endl;
if (!shared_commands::rsync_service_config(server_env, service, false)) if (!shared_commands::rsync_service_config(server_env, service, false))
@@ -156,6 +174,22 @@ namespace dropshell
return false; return false;
} }
// Check if the template supports reload-config
LocalServiceInfo service_info = get_service_info(server, service);
if (!SIvalid(service_info))
{
error << "Service " << service << " not found on server " << server << std::endl;
return false;
}
std::filesystem::path script_path = std::filesystem::path(service_info.local_template_path) / "reload-config.sh";
if (!std::filesystem::exists(script_path))
{
info << "Template '" << service_info.template_name << "' does not support the reload-config command." << std::endl;
debug << "To add support, create: " << script_path.filename().string() << std::endl;
return false;
}
// Sync configuration to remote // Sync configuration to remote
info << "Syncing configuration for " << service << " on " << server << "..." << std::endl; info << "Syncing configuration for " << service << " on " << server << "..." << std::endl;
if (!shared_commands::rsync_service_config(server_env, service, false)) if (!shared_commands::rsync_service_config(server_env, service, false))