This commit is contained in:
Your Name
2025-04-25 18:54:31 +12:00
parent bbf2575718
commit d028a4d8c6
15 changed files with 195 additions and 15 deletions

View File

@ -0,0 +1,23 @@
DropShell Template Example
Shell scripts defined in this folder are run as DropShell commands on the remote server (not locally!).
All scripts are passed the directory containing the server-specific service environment (SSSE) as an argument
(the environment file, along with any other server and service-specific files, is then in $1/service.env)
The default SSSE file included when a new service is created is in example/service.env. This must exist,
and must at minimum contain the TEMPLATE=<template_name> variable.
The optional backups script gets a second argument, which is the backup file to create (a single tgz file).
Mandatory scripts are:
- install.sh
- uninstall.sh
- start.sh
- stop.sh
Optional standard scripts are:
- backup.sh
- status.sh
- ports.sh
- logs.sh

View File

@ -0,0 +1,60 @@
#!/bin/bash
# This script checks ALL services on the server and returns a status for each.
# Return format is simple ENV with the following format:
# SERVICE_NAME_HEALTH=healthy|unhealthy|unknown
# SERVICE_NAME_PORTS=port1,port2,port3
# Get all services on the server
SCRIPT_DIR="$(dirname "$0")"
# // DROPSHELL_DIR
# // |-- backups
# // |-- services
# // |-- service name
# // |-- config <-- this is passed as argument to all scripts
# // |-- service.env
# // |-- (user config files)
# // |-- template
# // |-- (script files)
# Get all services on the server
SERVICES_PATH="${SCRIPT_DIR}/../"
# Get all service names
SERVICE_NAMES=$(ls "${SERVICES_PATH}")
# Iterate over all service names
for SERVICE_NAME in ${SERVICE_NAMES}; do
# Get the service health
SERVICE_PATH="${SERVICES_PATH}/${SERVICE_NAME}"
STATUS_FILE="${SERVICE_PATH}/template/status.sh"
if [ -f "${STATUS_FILE}" ]; then
# suppress all output from the status script
if $(bash "${STATUS_FILE}" "${SERVICE_PATH}/config" > /dev/null 2>&1); then
SERVICE_HEALTH="healthy"
else
SERVICE_HEALTH="unhealthy"
fi
else
SERVICE_HEALTH="unknown"
fi
# Get the service ports
PORTS_FILE="${SERVICE_PATH}/template/ports.sh"
if [ -f "${PORTS_FILE}" ]; then
# suppress all output from the ports script
SERVICE_PORTS=$(bash "${PORTS_FILE}" "${SERVICE_PATH}/config" > /dev/null 2>&1)
else
SERVICE_PORTS="unknown"
fi
# return the health and ports
echo "${SERVICE_NAME}_HEALTH=${SERVICE_HEALTH}"
echo "${SERVICE_NAME}_PORTS=${SERVICE_PORTS}"
done

View File

@ -0,0 +1,4 @@
# Template to use - always required!
TEMPLATE=dropshell-agent

View File

@ -0,0 +1,8 @@
#!/bin/bash
# INSTALL SCRIPT
# The install script is required for all templates.
# It is used to install the service on the server.
# It is called with the path to the server specific env file as an argument.
echo "Installation of ${CONTAINER_NAME} complete"

View File

@ -0,0 +1,8 @@
#!/bin/bash
# START SCRIPT
# The start script is required for all templates.
# It is used to start the service on the server.
# It is called with the path to the server specific env file as an argument.

View File

@ -0,0 +1,8 @@
#!/bin/bash
# STATUS SCRIPT
# The status script is OPTIONAL.
# It is used to return the status of the service (0 is healthy, 1 is unhealthy).
# It is called with the path to the server specific env file as an argument.
return 0

View File

@ -0,0 +1,7 @@
#!/bin/bash
# STOP SCRIPT
# The stop script is required for all templates.
# It is used to stop the service on the server.
# It is called with the path to the server specific env file as an argument.

View File

@ -0,0 +1,7 @@
#!/bin/bash
# UNINSTALL SCRIPT
# The uninstall script is required for all templates.
# It is used to uninstall the service from the server.
# It is called with the path to the server specific env file as an argument.