Tidying
This commit is contained in:
parent
3e14e50d83
commit
3325fb93d8
@ -1,41 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# BACKUP SCRIPT
|
||||
# The backup script is OPTIONAL.
|
||||
# It is used to backup the service on the server.
|
||||
# It is called with:
|
||||
# 1) the path to the server specific env file as the frist argument.
|
||||
# 2) the path to the destination backup file as the second argument.
|
||||
# If the backup file already exists, the script should exit with a message.
|
||||
|
||||
source "$(dirname "$0")/_common.sh"
|
||||
load_env "$1" || die "Failed to load environment variables"
|
||||
|
||||
# Required environment variables
|
||||
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
# Get backup file path from second argument
|
||||
BACKUP_FILE="$2"
|
||||
if [ -z "$BACKUP_FILE" ]; then
|
||||
die "Backup file path not provided"
|
||||
fi
|
||||
|
||||
# Check if backup file already exists
|
||||
if [ -f "$BACKUP_FILE" ]; then
|
||||
die "Backup file $BACKUP_FILE already exists"
|
||||
fi
|
||||
|
||||
# Stop container before backup
|
||||
_stop_container "$CONTAINER_NAME"
|
||||
|
||||
Create backup of data folder
|
||||
echo "Creating backup of $LOCAL_DATA_FOLDER..."
|
||||
if ! tar zcvf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" .; then
|
||||
_start_container "$CONTAINER_NAME"
|
||||
die "Failed to create backup"
|
||||
fi
|
||||
|
||||
# Start container after backup
|
||||
_start_container "$CONTAINER_NAME"
|
||||
|
||||
echo "Backup created successfully: $BACKUP_FILE"
|
33
templates/example-nginx/README.txt
Normal file
33
templates/example-nginx/README.txt
Normal file
@ -0,0 +1,33 @@
|
||||
DropShell Template Example - Nginx simple webserver
|
||||
|
||||
A simple service example, creating a single docker container running nginx, with contant on the host
|
||||
in the configurable LOCAL_DATA_FOLDER directory.
|
||||
|
||||
Shell scripts defined in this folder are run as DropShell commands on the remote server (not locally!).
|
||||
|
||||
When they are run, the following environment variables will be set:
|
||||
- SERVER (server name), SERVICE (service name) and CONFIG_PATH (path to the user's service configuration folder)
|
||||
- everything in _default.env
|
||||
- everything in the server's particular service.env file (defaults in example/service.env)
|
||||
|
||||
The optional backup and restore scripts get a second argument, which is the backup file to create/restore
|
||||
(must be a single tgz file).
|
||||
|
||||
Mandatory scripts are:
|
||||
- install.sh
|
||||
- uninstall.sh
|
||||
|
||||
Optional standard scripts are:
|
||||
- start.sh
|
||||
- stop.sh
|
||||
- backup.sh
|
||||
- restore.sh
|
||||
- status.sh
|
||||
- ports.sh
|
||||
- logs.sh
|
||||
|
||||
|
||||
The example/ folder gets copied to the service's configuration, edited for the particular server settings,
|
||||
then copied onto the server. The location is server-specific, but can be accessed via CONFIG_PATH.
|
||||
|
||||
You can use it to store things like an nginx config file (this example does not).
|
@ -3,16 +3,14 @@
|
||||
# BACKUP SCRIPT
|
||||
# The backup script is OPTIONAL.
|
||||
# It is used to backup the service on the server.
|
||||
# It is called with:
|
||||
# 1) the path to the server specific env file as the frist argument.
|
||||
# 2) the path to the destination backup file as the second argument.
|
||||
# It is called with one argument: the path to the destination backup file.
|
||||
# If the backup file already exists, the script should exit with a message.
|
||||
|
||||
source "$(dirname "$0")/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
# Get backup file path from second argument
|
||||
BACKUP_FILE="$2"
|
||||
# Get backup file path from first argument
|
||||
BACKUP_FILE="$1"
|
||||
if [ -z "$BACKUP_FILE" ]; then
|
||||
die "Backup file path not provided"
|
||||
fi
|
@ -1,5 +1,5 @@
|
||||
# Template to use - always required!
|
||||
TEMPLATE=example
|
||||
TEMPLATE=example-nginx
|
||||
|
||||
# Service settings specific to this server
|
||||
# (can also override anything in the _default.env file in the template to make it specific to this server)
|
37
templates/example-nginx/restore.sh
Normal file
37
templates/example-nginx/restore.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# RESTORE SCRIPT
|
||||
# The restore script is OPTIONAL.
|
||||
# It is used to restore the service on the server from a backup file.
|
||||
# It is called with one argument: the path to the backup file.
|
||||
|
||||
source "$(dirname "$0")/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
# Get backup file path from first argument
|
||||
BACKUP_FILE="$1"
|
||||
if [ -z "$BACKUP_FILE" ]; then
|
||||
die "Backup file path not provided"
|
||||
fi
|
||||
|
||||
# Check if backup file already exists
|
||||
if [ ! -f "$BACKUP_FILE" ]; then
|
||||
die "Backup file $BACKUP_FILE does not exist"
|
||||
fi
|
||||
|
||||
# # Stop container before backup
|
||||
# _stop_container "$CONTAINER_NAME"
|
||||
|
||||
# Create backup of data folder
|
||||
# echo "Creating backup of $LOCAL_DATA_FOLDER..."
|
||||
# if ! tar zcvf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" .; then
|
||||
# _start_container "$CONTAINER_NAME"
|
||||
# die "Failed to create backup"
|
||||
# fi
|
||||
|
||||
# # Start container after backup
|
||||
# _start_container "$CONTAINER_NAME"
|
||||
|
||||
# echo "Backup created successfully: $BACKUP_FILE"
|
||||
|
||||
echo "Backup restored successfully!"
|
@ -1,24 +0,0 @@
|
||||
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
|
||||
|
||||
Optional standard scripts are:
|
||||
- start.sh
|
||||
- stop.sh
|
||||
- backup.sh
|
||||
- restore.sh
|
||||
- status.sh
|
||||
- ports.sh
|
||||
- logs.sh
|
||||
|
Loading…
x
Reference in New Issue
Block a user