.
This commit is contained in:
23
templates/dropshell-agent/README.txt
Normal file
23
templates/dropshell-agent/README.txt
Normal 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
|
||||
|
60
templates/dropshell-agent/_allservicesstatus.sh
Normal file
60
templates/dropshell-agent/_allservicesstatus.sh
Normal 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
|
||||
|
||||
|
||||
|
||||
|
4
templates/dropshell-agent/example/service.env
Normal file
4
templates/dropshell-agent/example/service.env
Normal file
@ -0,0 +1,4 @@
|
||||
# Template to use - always required!
|
||||
TEMPLATE=dropshell-agent
|
||||
|
||||
|
8
templates/dropshell-agent/install.sh
Normal file
8
templates/dropshell-agent/install.sh
Normal 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"
|
8
templates/dropshell-agent/start.sh
Normal file
8
templates/dropshell-agent/start.sh
Normal 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.
|
||||
|
||||
|
8
templates/dropshell-agent/status.sh
Normal file
8
templates/dropshell-agent/status.sh
Normal 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
|
7
templates/dropshell-agent/stop.sh
Normal file
7
templates/dropshell-agent/stop.sh
Normal 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.
|
||||
|
7
templates/dropshell-agent/uninstall.sh
Normal file
7
templates/dropshell-agent/uninstall.sh
Normal 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.
|
||||
|
Reference in New Issue
Block a user