Move templates.

Remove docker stuff.
This commit is contained in:
Your Name 2025-05-13 21:17:30 +12:00
parent 30cfd591a3
commit adcb3567d4
79 changed files with 44 additions and 1066 deletions

View File

@ -1,24 +0,0 @@
FROM debian:bullseye AS builder
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
pkg-config \
bash \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
binutils-aarch64-linux-gnu \
qemu-user-static
WORKDIR /app
COPY . .
COPY --chmod=755 docker/_create_dropshell.sh /scripts/
RUN rm -rf build
ENV CXXFLAGS="-static-libstdc++ -static-libgcc"
ENV LDFLAGS="-static -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
CMD ["/bin/bash","/scripts/_create_dropshell.sh"]

View File

@ -1,10 +0,0 @@
#!/bin/bash
set -x
mkdir -p /app/build
cd /app/build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j4
cp /app/build/dropshell /output/
chown $CHOWN_USER:$CHOWN_GROUP /output/dropshell

View File

@ -1,8 +0,0 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ROOT_DIR=$(dirname $SCRIPT_DIR)
docker build -t gitea.jde.nz/j/dropshell_builder:latest $ROOT_DIR -f $SCRIPT_DIR/Dockerfile.build

View File

@ -1,47 +0,0 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ROOT_DIR=$(dirname $SCRIPT_DIR)
echo "Building dropshell from $ROOT_DIR"
# Build the builder image
#docker build -t dropshell_alpine_builder $ROOT_DIR -f $SCRIPT_DIR/Dockerfile.build
rm -rf $SCRIPT_DIR/output
mkdir -p $SCRIPT_DIR/output
MYUID=$(id -u)
MYGID=$(id -g)
# Build for x86_64
echo "Building for x86_64..."
docker run --rm -tt --env CHOWN_USER=$MYUID --env CHOWN_GROUP=$MYGID \
-v $SCRIPT_DIR/output:/output \
-e TARGET_ARCH=x86_64 \
-e CC=gcc \
-e CXX=g++ \
gitea.jde.nz/j/dropshell_builder:latest
mv $SCRIPT_DIR/output/dropshell $SCRIPT_DIR/output/dropshell_x86_64
$SCRIPT_DIR/output/dropshell_x86_64 version
echo "dropshell built in $SCRIPT_DIR/output/dropshell_x86_64"
# Build for arm64
echo "Building for arm64..."
docker run --rm -tt --env CHOWN_USER=$MYUID --env CHOWN_GROUP=$MYGID \
-v $SCRIPT_DIR/output:/output \
-e TARGET_ARCH=aarch64 \
-e CC=aarch64-linux-gnu-gcc \
-e CXX=aarch64-linux-gnu-g++ \
gitea.jde.nz/j/dropshell_builder:latest
mv $SCRIPT_DIR/output/dropshell $SCRIPT_DIR/output/dropshell_aarch64
echo "dropshell built in $SCRIPT_DIR/output/dropshell_aarch64"

View File

@ -1,3 +0,0 @@
#!/bin/bash
docker push gitea.jde.nz/j/dropshell_builder:latest

View File

@ -1,2 +0,0 @@
#!/bin/bash

View File

@ -31,7 +31,7 @@ namespace dropshell
false, // hidden
false, // requires_config
false, // requires_install
1, // min_args (after command)
0, // min_args (after command)
2, // max_args (after command)
"install SERVER [SERVICE]",
"Install/reinstall service(s). Safe/non-destructive way to update.",
@ -138,7 +138,9 @@ namespace dropshell
return true;
}
// ------------------------------------------------------------------------------------------------
// get_arch : SHARED COMMAND
// ------------------------------------------------------------------------------------------------
std::string get_arch()
{
// determine the architecture of the system
@ -151,6 +153,26 @@ namespace dropshell
return arch;
}
// ------------------------------------------------------------------------------------------------
// update_dropshell
// ------------------------------------------------------------------------------------------------
std::string _exec(const char* cmd) {
char buffer[128];
std::string result = "";
FILE* pipe = popen(cmd, "r");
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != nullptr)
result += buffer;
}
pclose(pipe);
return result;
}
int update_dropshell()
{
// determine path to this executable
@ -189,6 +211,21 @@ namespace dropshell
return 0;
}
std::string runvercmd = (parent_path / "dropshell").string() + " version";
std::string currentver = _exec(runvercmd.c_str());
runvercmd = (parent_path / "dropshell_temp").string() + " version";
std::string newver = _exec(runvercmd.c_str());
if (currentver >= newver)
{
std::cout << "Current dropshell version: " << currentver << ", published version: " << newver << std::endl;
std::cout << "No update needed." << std::endl;
return 0;
}
return 0;
std::string bash_script_2 = "docker run --rm -v " + parent_path.string() + ":/target gitea.jde.nz/public/debian-curl:latest " +
"sh -c \"mv /target/dropshell_temp /target/dropshell\"";
rval = system(bash_script_2.c_str());
@ -212,6 +249,8 @@ namespace dropshell
{
// update dropshell.
// install the local dropshell agent.
return update_dropshell();
}

View File

@ -16,6 +16,7 @@ namespace dropshell {
// defined in install.cpp
bool install_service(const std::string& server, const std::string& service, bool silent);
bool uninstall_service(const std::string& server, const std::string& service, bool silent);
std::string get_arch();
// defined in health.cpp
std::string healthtick(const std::string& server, const std::string& service);
@ -24,6 +25,7 @@ namespace dropshell {
// defined in standard_autocomplete.cpp
void std_autocomplete(const CommandContext& ctx);
void std_autocomplete_allowallservices(const CommandContext& ctx);
} // namespace dropshell
#endif

View File

@ -1,3 +0,0 @@
Caddy!
Edit the static site, and the Caddyfile.

View File

@ -1,8 +0,0 @@
# Service settings specific to this server
# Image settings
IMAGE_REGISTRY="docker.io"
IMAGE_REPO="caddy"
DATA_VOLUME=caddy_data
CONFIG_VOLUME=caddy_config

View File

@ -1,11 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
_stop_container "$CONTAINER_NAME"
autobackup "$1" "$2" "volume=$DATA_VOLUME" "volume=$CONFIG_VOLUME" || _die "Failed to create backup"
_start_container "$CONTAINER_NAME"
echo "Backup created successfully: $BACKUP_FILE"

View File

@ -1,2 +0,0 @@
# Template to use - always required!
TEMPLATE=caddy

View File

@ -1,6 +0,0 @@
# See https://caddyserver.com/docs/caddyfile
localhost {
root * /srv
file_server
}

View File

@ -1,10 +0,0 @@
# 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)
CONTAINER_NAME=caddy
IMAGE_TAG="latest"
# Scripts will have these environment variables set, plus those in _default.env, plus:
# SERVER, SERVICE, CONFIG_PATH
# CONFIG_PATH points to this directory!

View File

@ -1,9 +0,0 @@
<html>
<head>
<title>Static Site</title>
</head>
<body>
<h1>Static Site</h1>
<p>This is a static site.</p>
</body>
</html>

View File

@ -1,17 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "DATA_VOLUME" "CONFIG_VOLUME" "CONFIG_PATH"
autocreate "volume=$DATA_VOLUME" "volume=$CONFIG_VOLUME" || _die "Failed to autocreate volumes $DATA_VOLUME and $CONFIG_VOLUME"
_check_docker_installed || _die "Docker test failed, aborting installation..."
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
[ -f "${CONFIG_PATH}/Caddyfile" ] || _die "Caddyfile not found in ${CONFIG_PATH}!"
bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}"
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}"
echo "Installation of ${CONTAINER_NAME} complete"

View File

@ -1,9 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Main script.
echo "Container ${CONTAINER_NAME} logs:"
_grey_start
docker logs "${CONTAINER_NAME}"
_grey_end

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# NUKE SCRIPT
# This is run after the uninstall.sh script to delete all data.
# dropshell handles the configuration files, so we just need to remove
# any docker volumes and any custom local data folders.
autonuke "volume=$DATA_VOLUME" "volume=$CONFIG_VOLUME" || _die "Failed to nuke"
echo "Nuking of ${CONTAINER_NAME} complete."

View File

@ -1,6 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
echo 80
echo 443

View File

@ -1,17 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# RESTORE SCRIPT
# uninstall container before restore
bash ./uninstall.sh || _die "Failed to uninstall service before restore"
# restore data from backup file
autorestore "$1" "$2" "volume=$DATA_VOLUME" "volume=$CONFIG_VOLUME" || _die "Failed to restore data from backup file"
# reinstall service
bash ./install.sh || _die "Failed to reinstall service after restore"
echo "Restore complete! Service is running again."

View File

@ -1,33 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# START SCRIPT
# The start script is required for all templates.
# It is used to start the service on the server.
DOCKER_RUN_CMD="docker run -d \
--restart unless-stopped \
--name ${CONTAINER_NAME} \
-p 80:80 \
-p 443:443 \
-p 443:443/udp \
-v ${CONFIG_PATH}/Caddyfile:/etc/caddy/Caddyfile \
-v ${DATA_VOLUME}:/data \
-v ${CONFIG_VOLUME}:/config \
-v ${CONFIG_PATH}/static:/srv \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
_die "Failed to start container ${CONTAINER_NAME}"
fi
# Check if the container is running
if ! _is_container_running "$CONTAINER_NAME"; then
_die "Container ${CONTAINER_NAME} is not running"
fi
echo "Container ${CONTAINER_NAME} started"

View File

@ -1,15 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# STATUS SCRIPT
# The status script is OPTIONAL.
# It is used to return the status of the service (0 is healthy, 1 is unhealthy).
# This is an example of a status script that checks if the service is running.
# check if the service is running
_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME."
echo "Service is healthy"
exit 0

View File

@ -1,12 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# STOP SCRIPT
# The stop script is required for all templates.
# It is used to stop the service on the server.
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
echo "Container ${CONTAINER_NAME} stopped"

View File

@ -1,18 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# UNINSTALL SCRIPT
# The uninstall script is required for all templates.
# It is used to uninstall the service from the server.
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
_is_container_running && _die "Couldn't stop existing container"
_is_container_exists && _die "Couldn't remove existing container"
# remove the image
docker rmi "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Failed to remove image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
echo "Uninstallation of ${CONTAINER_NAME} complete."
echo "Local data still in place."

View File

@ -1 +0,0 @@
Caddy

View File

@ -1,5 +0,0 @@
# Service settings specific to this server
# Image settings
IMAGE_REGISTRY="docker.io"
IMAGE_REPO="nginx"

View File

@ -1,10 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR" "CONTAINER_NAME"
# Nginx Example Backup Script
# hot backup is fine for nginx website content.
autobackup "path=${LOCAL_DATA_FOLDER}" || _die "Failed to create backup"
echo "Backup complete for ${CONTAINER_NAME}"

View File

@ -1,2 +0,0 @@
# Template to use - always required!
TEMPLATE=example-nginx

View File

@ -1,12 +0,0 @@
# 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)
HOST_PORT=60123
LOCAL_DATA_FOLDER="/home/dropshell/nginx-example-website"
CONTAINER_NAME="example-nginx"
IMAGE_TAG="latest"
# Scripts will have these environment variables set, plus those in _default.env, plus:
# SERVER, SERVICE, CONFIG_PATH
# CONFIG_PATH points to this directory!

View File

@ -1,23 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "LOCAL_DATA_FOLDER" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "CONTAINER_NAME"
# Nginx Example Install Script
# Ensure local data folder exists
autocreate "path=${LOCAL_DATA_FOLDER}"
echo "Checking Docker installation..."
_check_docker_installed || _die "Docker test failed, aborting installation..."
echo "Pulling image ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}..."
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
echo "Stopping and removing any existing container..."
bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}"
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
echo "Starting container..."
bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}"
echo "Installation complete for service ${CONTAINER_NAME}."

View File

@ -1,10 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
# Nginx Example Logs Script
echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)"
_grey_start
_get_container_logs $CONTAINER_NAME
_grey_end

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "LOCAL_DATA_FOLDER" "CONTAINER_NAME"
# Nginx Example Nuke Script
# Removes container and local data folder.
# Call uninstall script first
./uninstall.sh
autonuke "path=${LOCAL_DATA_FOLDER}" || _die "Failed to nuke ${LOCAL_DATA_FOLDER}"
echo "Nuke complete for service ${CONTAINER_NAME}."

View File

@ -1,7 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "HOST_PORT"
# Nginx Example Ports Script
echo $HOST_PORT

View File

@ -1,15 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR" "CONTAINER_NAME"
# Nginx Example Restore Script
echo "Uninstalling service before restore..."
bash ./uninstall.sh || _die "Failed to uninstall service before restore"
autorestore "path=${LOCAL_DATA_FOLDER}" || _die "Failed to restore data folder from backup"
echo "Restore complete. Reinstalling service..."
bash ./install.sh || _die "Failed to reinstall service after restore"
echo "Service ${CONTAINER_NAME} restored and reinstalled."

View File

@ -1,30 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" "HOST_PORT" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
# 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.
[ -d "${LOCAL_DATA_FOLDER}" ] || _die "Local data folder ${LOCAL_DATA_FOLDER} does not exist."
DOCKER_RUN_CMD="docker run -d \
--restart unless-stopped \
--name ${CONTAINER_NAME} \
-p ${HOST_PORT}:80 \
-v ${LOCAL_DATA_FOLDER}:/usr/share/nginx/html:ro \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
_die "Failed to start container ${CONTAINER_NAME}"
fi
# Check if the container is running
if ! _is_container_running "$CONTAINER_NAME"; then
_die "Container ${CONTAINER_NAME} is not running"
fi
echo "Container ${CONTAINER_NAME} started"

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
# STATUS SCRIPT
# The status script is OPTIONAL.
# It is used to return the status of the service (0 is healthy, 1 is unhealthy).
# check if the service is running
_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME."
echo "Service is healthy"
exit 0

View File

@ -1,7 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
echo "Container ${CONTAINER_NAME} stopped"

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
# Nginx Example Uninstall Script
echo "Uninstalling service ${CONTAINER_NAME}..."
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
if _is_container_running $CONTAINER_NAME; then _die "Couldn't stop existing container"; fi
if _is_container_exists $CONTAINER_NAME; then _die "Couldn't remove existing container"; fi
echo "Service ${CONTAINER_NAME} uninstalled."
echo "Note: This does NOT remove the local data folder. Use nuke.sh for that."

View File

@ -1 +0,0 @@
simple-object-storage

View File

@ -1,12 +0,0 @@
# Service settings specific to this server
# Image settings
IMAGE_REGISTRY="gitea.jde.nz"
IMAGE_REPO="j/simple-object-storage"
IMAGE_TAG="latest"
# Container settings
CONTAINER_NAME="simple-object-storage"
# Volume settings
VOLUME_NAME="simple-object-storage"

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "VOLUME_NAME" "BACKUP_FILE" "TEMP_DIR"
# Simple Object Storage Backup Script
# Creates a backup tarball of the volume contents.
# HOT backup is fine for simple-object-storage
autobackup "volume=${VOLUME_NAME}" || _die "Failed to create backup"
echo "Backup complete: ${BACKUP_FILE}"

View File

@ -1,2 +0,0 @@
# Template to use - always required!
TEMPLATE=simple-object-storage

View File

@ -1,4 +0,0 @@
# note the port and write tokens are not set here, they are set in the sos_config.json file.
CONTAINER_NAME="simple-object-storage"
VOLUME_NAME="simple-object-storage"

View File

@ -1,8 +0,0 @@
{
"write_tokens": [
"fizzle1",
"fizzle2",
"fizzle3"
],
"port": 8123
}

View File

@ -1,25 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Simple Object Storage Install Script
# Pulls image, creates volume/config, starts container.
autocreate "volume=${VOLUME_NAME}"
# check can pull image on remote host and exit if fails
echo "Pulling image ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}..."
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
echo "Stopping and removing any existing container..."
bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}"
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}"
echo "Installation complete for service ${CONTAINER_NAME}."
# determine port.
command -v jq &> /dev/null || _die "jq could not be found, please install it"
[ -f "${CONFIG_PATH}/sos_config.json" ] || _die "sos_config.json does not exist"
PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json")
echo "You can access the service at http://${HOST_NAME}:${PORT}"

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Simple Object Storage Logs Script
# Shows the logs for the running container.
echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)"
_grey_start
_get_container_logs $CONTAINER_NAME
_grey_end

View File

@ -1,11 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Simple Object Storage Nuke Script
# Removes container AND volume.
autonuke "volume=${VOLUME_NAME}" || _die "Failed to nuke volume ${VOLUME_NAME}"
echo "Nuke complete for service ${CONTAINER_NAME}."

View File

@ -1,19 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONFIG_PATH"
# PORT SCRIPT
# The port script is OPTIONAL.
# It is used to return the ports used by the service.
# It is called with the path to the server specific env file as an argument.
# Required environment variables
# determine port.
command -v jq &> /dev/null || _die "jq could not be found, please install it"
[ -f "${CONFIG_PATH}/sos_config.json" ] || _die "sos_config.json does not exist"
PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json")
echo $PORT

View File

@ -1,21 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh" || _die "Failed to source _common.sh"
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR" "VOLUME_NAME" "CONTAINER_NAME"
# Simple Object Storage Restore Script
# Restores data from a backup file.
echo "Uninstalling service before restore..."
bash ./uninstall.sh || _die "Failed to uninstall service before restore"
echo "Restoring data for ${CONTAINER_NAME} from ${BACKUP_FILE}..."
autorestore "volume=${VOLUME_NAME}" || _die "Failed to restore data from backup file"
echo "Restore complete. Reinstalling service..."
bash ./install.sh || _die "Failed to reinstall service after restore"
echo "Service ${CONTAINER_NAME} restored and reinstalled."

View File

@ -1,17 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Simple Object Storage SSH Script
# Opens a shell in the running container.
if ! _is_container_running $CONTAINER_NAME; then
_die "Container ${CONTAINER_NAME} is not running. Can't connect to it."
fi
echo "Connecting to container ${CONTAINER_NAME}..."
docker exec -it "${CONTAINER_NAME}" /bin/bash
echo "Disconnected from ${CONTAINER_NAME}"

View File

@ -1,38 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME" "CONFIG_PATH" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
# Simple Object Storage Start Script
# Creates and starts the container using environment variables.
# check volume exists.
if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then
_die "Docker volume ${VOLUME_NAME} does not exist"
fi
# determine port.
command -v jq &> /dev/null || _die "jq could not be found, please install it"
[ -f "${CONFIG_PATH}/sos_config.json" ] || _die "sos_config.json does not exist"
PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json")
DOCKER_RUN_CMD="docker run -d \
--restart unless-stopped \
--name ${CONTAINER_NAME} \
-p ${PORT}:${PORT} \
-v ${VOLUME_NAME}:/data/storage \
-v ${CONFIG_PATH}/sos_config.json:/data/sos_config.json:ro \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
_die "Failed to start container ${CONTAINER_NAME}"
fi
# Check if the container is running
if ! _is_container_running "$CONTAINER_NAME"; then
_die "Container ${CONTAINER_NAME} is not running"
fi
echo "Container ${CONTAINER_NAME} started"

View File

@ -1,22 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# STATUS SCRIPT
# This is an example of a status script that checks if the service is running.
# check if the service is running
_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME."
# determine port.
command -v jq &> /dev/null || _die "jq could not be found, please install it"
[ -f "${CONFIG_PATH}/sos_config.json" ] || _die "sos_config.json does not exist"
PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json")
# check if the service is healthy
curl -s -X GET http://localhost:${PORT}/status | jq -e '.result == "success"' \
|| _die "Service is not healthy - did not get OK response from /status endpoint."
echo "Service is healthy"
exit 0

View File

@ -1,12 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Simple Object Storage Stop Script
# Stops the running container.
echo "Stopping service ${CONTAINER_NAME}..."
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
echo "Service ${CONTAINER_NAME} stopped."

View File

@ -1,19 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# 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.
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
_is_container_running && _die "Couldn't stop existing container"
_is_container_exists && _die "Couldn't remove existing container"
# remove the image
docker rmi "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Failed to remove image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
echo "Uninstallation of ${CONTAINER_NAME} complete."
echo "Data volume ${VOLUME_NAME} still in place."

View File

@ -1,10 +0,0 @@
# Application settings
CONTAINER_PORT=8181
# Deployment settings
CONTAINER_NAME="squashkiwi"
# Image settings
IMAGE_REGISTRY="gitea.jde.nz"
IMAGE_REPO="squashkiwi/squashkiwi"
IMAGE_TAG="latest"

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR"
# Stop container before backup
_stop_container "$CONTAINER_NAME"
autobackup "path=${LOCAL_DATA_FOLDER}" || _die "Failed to create backup"
# Start container after backup
_start_container "$CONTAINER_NAME"
echo "Backup created successfully"

View File

@ -1,2 +0,0 @@
# Template to use - always required!
TEMPLATE=squashkiwi

View File

@ -1,6 +0,0 @@
# Service settings specific to this server
# (can also override anything in the _basic.env file in the template to make it specific to this server)
HOST_PORT=80
LOCAL_DATA_FOLDER="/home/dropshell/example-squashkiwi"
IMAGE_TAG="latest"

View File

@ -1,18 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
autocreate path=$LOCAL_DATA_FOLDER || _die "Failed to create local data folder"
# Test Docker
_check_docker_installed || _die "Docker test failed, aborting installation..."
# check can pull image on remote host and exit if fails
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
# remove and restart, as the env may have changed.
bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}"
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}"
echo "Installation of ${CONTAINER_NAME} complete"

View File

@ -1,8 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
echo "Container ${CONTAINER_NAME} logs:"
_grey_start
docker logs "${CONTAINER_NAME}"
_grey_end

View File

@ -1,8 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "LOCAL_DATA_FOLDER"
autonuke "path=${LOCAL_DATA_FOLDER}" || _die "Failed to nuke ${LOCAL_DATA_FOLDER}"
echo "Nuke of ${CONTAINER_NAME} complete"

View File

@ -1,5 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "HOST_PORT"
echo $HOST_PORT

View File

@ -1,18 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR"
# 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.
# # Stop container before backup
bash ./uninstall.sh || _die "Failed to uninstall service before restore"
autorestore "path=${LOCAL_DATA_FOLDER}" || _die "Failed to restore data folder from backup"
# reinstall service
bash ./install.sh || _die "Failed to reinstall service after restore"
echo "Restore complete! Service is running again on port $HOST_PORT with restored website."

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
if ! _is_container_running "$CONTAINER_NAME"; then
_die "Container ${CONTAINER_NAME} is not running. Can't connect to it."
fi
echo "Connecting to ${CONTAINER_NAME}..."
docker exec -it ${CONTAINER_NAME} bash
echo "Disconnected from ${CONTAINER_NAME}"

View File

@ -1,24 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "HOST_PORT" "CONTAINER_PORT" "LOCAL_DATA_FOLDER" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
DOCKER_RUN_CMD="docker run -d \
--restart unless-stopped \
--name ${CONTAINER_NAME} \
-p ${HOST_PORT}:${CONTAINER_PORT} \
-v ${LOCAL_DATA_FOLDER}:/skdata \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
echo "${DOCKER_RUN_CMD}"
_die "Failed to start container ${CONTAINER_NAME}"
fi
# Check if the container is running
if ! _is_container_running "$CONTAINER_NAME"; then
_die "Container ${CONTAINER_NAME} is not running"
fi
echo "Container ${CONTAINER_NAME} started, on port ${HOST_PORT}"

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "HOST_PORT"
# check if the service is running
_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME."
# check if the service is healthy
curl -s -X GET http://localhost:${HOST_PORT}/health | grep -q "OK" \
|| _die "Service is not healthy - did not get OK response from /health endpoint."
echo "Service is healthy"
exit 0

View File

@ -1,7 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
echo "Container ${CONTAINER_NAME} stopped"

View File

@ -1,16 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
# 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.
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
_is_container_running && _die "Couldn't stop existing container"
_is_container_exists && _die "Couldn't remove existing container"
echo "Uninstallation of ${CONTAINER_NAME} complete."
echo "Local data folder ${LOCAL_DATA_FOLDER} still in place."

View File

@ -1,96 +0,0 @@
#!/bin/bash
SCRIPT_DIR=$(dirname "$0")
# default config should always work for localhost
function die() {
echo "$1"
exit 1
}
function dashes() {
for ((i=0; i<$1; i++)); do
echo -n "-"
done
echo ""
}
function centerprint() {
# print $1 centered
local width=$2
local padding=$(( (width - ${#1}) / 2 ))
for ((i=0; i<$padding; i++)); do
echo -n " "
done
echo "$1"
}
function title() {
# determine terminal width
TERMINAL_WIDTH=$(tput cols)
echo " "
dashes $TERMINAL_WIDTH
centerprint "$1" $TERMINAL_WIDTH
dashes $TERMINAL_WIDTH
}
# do we have the first argument?
if [ -z "$1" ]; then
echo "Usage: $0 <template>"
exit 1
fi
TEMPLATE=$(basename "$1")
if [ ! -d "$SCRIPT_DIR/$TEMPLATE" ]; then
echo "Local Template $TEMPLATE does not exist"
exit 1
fi
# for now, we need to build and locally install to test the template. Check if it's up to date.
title "Checking template $TEMPLATE"
SERVICE_NAME="test-$TEMPLATE"
title "Nuking old service"
ds fullnuke localhost $SERVICE_NAME || die "Failed to fullnuke old service"
title "Creating service"
ds create-service localhost $TEMPLATE $SERVICE_NAME || die "Failed to create service"
title "Installing service"
ds install localhost $SERVICE_NAME || die "Failed to install service"
title "Stopping service"
ds stop localhost $SERVICE_NAME || die "Failed to stop service"
title "Starting service"
ds start localhost $SERVICE_NAME || die "Failed to start service"
title "Listing services"
ds list localhost || die "Failed to list services"
title "Backing up service"
ds backup localhost $SERVICE_NAME || die "Failed to backup service"
title "Restoring service"
ds restore localhost $SERVICE_NAME latest || die "Failed to restore service"
title "Checking status"
ds status localhost $SERVICE_NAME || die "Failed to check status"
title "Nuking service"
ds nuke localhost $SERVICE_NAME || die "Failed to nuke service"
title "Listing services"
ds list localhost || die "Failed to list services"
# change to green font
echo -e "\033[32m"
title "ALL TESTS PASSED FOR $TEMPLATE"
echo -e "\033[0m"
echo " "

View File

@ -1,11 +0,0 @@
# Service settings
CONTAINER_NAME=watchtower
# Interval in seconds between checks.
# Default is 1800 seconds (30 minutes).
INTERVAL=1800
# Image settings
IMAGE_REGISTRY="docker.io"
IMAGE_REPO="containrrr/watchtower"
IMAGE_TAG="latest"

View File

@ -1,3 +0,0 @@
# Template to use - always required!
TEMPLATE=watchtower

View File

@ -1,5 +0,0 @@
{
"auths": {
}
}

View File

@ -1,6 +0,0 @@
# Service settings specific to this server
# (can also override anything in the _basic.env file in the template to make it specific to this server)
# Interval in seconds between checks.
# Default is 1800 seconds (30 minutes).
INTERVAL=1800

View File

@ -1,21 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
# Watchtower Install Script
echo "Checking Docker installation..."
_check_docker_installed || _die "Docker test failed, aborting installation..."
echo "Pulling image ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}..."
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
echo "Stopping and removing any existing container..."
# No need to check failure, might not exist
_stop_container $CONTAINER_NAME
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
echo "Starting container..."
bash ./start.sh $1 || _die "Failed to start container ${CONTAINER_NAME}"
echo "Installation complete for service ${CONTAINER_NAME}."

View File

@ -1,10 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
# Watchtower Logs Script
echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)"
_grey_start
_get_container_logs $CONTAINER_NAME
_grey_end

View File

@ -1,34 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Watchtower Start Script
# Optional arguments (e.g., --cleanup, --monitor-only)
EXTRA_ARGS=$1
DOCKER_RUN_CMD="docker run -d \
--name ${CONTAINER_NAME} \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG} \
--interval ${INTERVAL} ${EXTRA_ARGS}"
echo "Starting container ${CONTAINER_NAME}..."
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
# If creation/start failed, attempt to display logs if container exists
if _is_container_exists $CONTAINER_NAME; then
echo "Attempting to get logs from failed container..."
_get_container_logs $CONTAINER_NAME
fi
_die "Failed to start container ${CONTAINER_NAME}"
fi
# Check if the container is running after successful start command
if ! _is_container_running "$CONTAINER_NAME"; then
_get_container_logs $CONTAINER_NAME # Show logs if it immediately exited
_die "Container ${CONTAINER_NAME} is not running after start attempt"
fi
echo "Service ${CONTAINER_NAME} started successfully."

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "CONTAINER_NAME"
# Watchtower Status Script
_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME."
# Optional: Add specific health checks for Watchtower if needed.
# For example, check logs for recent activity or errors.
echo "Service ${CONTAINER_NAME} is running."
exit 0

View File

@ -1,9 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Watchtower Stop Script
echo "Stopping service ${CONTAINER_NAME}..."
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
echo "Service ${CONTAINER_NAME} stopped."

View File

@ -1,13 +0,0 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
_check_required_env_vars
# Watchtower Uninstall Script
echo "Uninstalling service ${CONTAINER_NAME}..."
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
echo "Service ${CONTAINER_NAME} uninstalled."
# Note: Watchtower doesn't typically have volumes to nuke.