From adcb3567d437e64e0905decb17757512e1cf1122 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 13 May 2025 21:17:30 +1200 Subject: [PATCH] Move templates. Remove docker stuff. --- docker/Dockerfile.build | 24 ----- docker/_create_dropshell.sh | 10 -- docker/build_builder.sh | 8 -- docker/compile.sh | 47 --------- docker/publish_builder.sh | 3 - docker/publish_dropshell.sh | 2 - src/commands/install.cpp | 43 ++++++++- src/commands/shared_commands.hpp | 4 +- templates/caddy/README.txt | 3 - templates/caddy/_default.env | 8 -- templates/caddy/backup.sh | 11 --- templates/caddy/config/.template_info.env | 2 - templates/caddy/config/Caddyfile | 6 -- templates/caddy/config/service.env | 10 -- templates/caddy/config/static/index.html | 9 -- templates/caddy/install.sh | 17 ---- templates/caddy/logs.sh | 9 -- templates/caddy/nuke.sh | 13 --- templates/caddy/ports.sh | 6 -- templates/caddy/restore.sh | 17 ---- templates/caddy/start.sh | 33 ------- templates/caddy/status.sh | 15 --- templates/caddy/stop.sh | 12 --- templates/caddy/uninstall.sh | 18 ---- templates/example-nginx/README.txt | 1 - templates/example-nginx/_default.env | 5 - templates/example-nginx/backup.sh | 10 -- .../example-nginx/config/.template_info.env | 2 - templates/example-nginx/config/service.env | 12 --- templates/example-nginx/install.sh | 23 ----- templates/example-nginx/logs.sh | 10 -- templates/example-nginx/nuke.sh | 13 --- templates/example-nginx/ports.sh | 7 -- templates/example-nginx/restore.sh | 15 --- templates/example-nginx/start.sh | 30 ------ templates/example-nginx/status.sh | 13 --- templates/example-nginx/stop.sh | 7 -- templates/example-nginx/uninstall.sh | 13 --- templates/simple-object-storage/README.txt | 1 - templates/simple-object-storage/_default.env | 12 --- templates/simple-object-storage/backup.sh | 13 --- .../config/.template_info.env | 2 - .../simple-object-storage/config/service.env | 4 - .../config/sos_config.json | 8 -- templates/simple-object-storage/install.sh | 25 ----- templates/simple-object-storage/logs.sh | 13 --- templates/simple-object-storage/nuke.sh | 11 --- templates/simple-object-storage/ports.sh | 19 ---- templates/simple-object-storage/restore.sh | 21 ---- templates/simple-object-storage/ssh.sh | 17 ---- templates/simple-object-storage/start.sh | 38 -------- templates/simple-object-storage/status.sh | 22 ----- templates/simple-object-storage/stop.sh | 12 --- templates/simple-object-storage/uninstall.sh | 19 ---- templates/squashkiwi/_default.env | 10 -- templates/squashkiwi/backup.sh | 13 --- .../squashkiwi/config/.template_info.env | 2 - templates/squashkiwi/config/service.env | 6 -- templates/squashkiwi/install.sh | 18 ---- templates/squashkiwi/logs.sh | 8 -- templates/squashkiwi/nuke.sh | 8 -- templates/squashkiwi/ports.sh | 5 - templates/squashkiwi/restore.sh | 18 ---- templates/squashkiwi/ssh.sh | 13 --- templates/squashkiwi/start.sh | 24 ----- templates/squashkiwi/status.sh | 13 --- templates/squashkiwi/stop.sh | 7 -- templates/squashkiwi/uninstall.sh | 16 ---- templates/test_template.sh | 96 ------------------- templates/watchtower/_default.env | 11 --- .../watchtower/config/.template_info.env | 3 - templates/watchtower/config/config.json | 5 - templates/watchtower/config/service.env | 6 -- templates/watchtower/install.sh | 21 ---- templates/watchtower/logs.sh | 10 -- templates/watchtower/start.sh | 34 ------- templates/watchtower/status.sh | 13 --- templates/watchtower/stop.sh | 9 -- templates/watchtower/uninstall.sh | 13 --- 79 files changed, 44 insertions(+), 1066 deletions(-) delete mode 100644 docker/Dockerfile.build delete mode 100755 docker/_create_dropshell.sh delete mode 100755 docker/build_builder.sh delete mode 100755 docker/compile.sh delete mode 100755 docker/publish_builder.sh delete mode 100755 docker/publish_dropshell.sh delete mode 100644 templates/caddy/README.txt delete mode 100644 templates/caddy/_default.env delete mode 100644 templates/caddy/backup.sh delete mode 100644 templates/caddy/config/.template_info.env delete mode 100644 templates/caddy/config/Caddyfile delete mode 100644 templates/caddy/config/service.env delete mode 100644 templates/caddy/config/static/index.html delete mode 100644 templates/caddy/install.sh delete mode 100644 templates/caddy/logs.sh delete mode 100644 templates/caddy/nuke.sh delete mode 100644 templates/caddy/ports.sh delete mode 100644 templates/caddy/restore.sh delete mode 100644 templates/caddy/start.sh delete mode 100644 templates/caddy/status.sh delete mode 100644 templates/caddy/stop.sh delete mode 100644 templates/caddy/uninstall.sh delete mode 100644 templates/example-nginx/README.txt delete mode 100644 templates/example-nginx/_default.env delete mode 100644 templates/example-nginx/backup.sh delete mode 100644 templates/example-nginx/config/.template_info.env delete mode 100644 templates/example-nginx/config/service.env delete mode 100644 templates/example-nginx/install.sh delete mode 100644 templates/example-nginx/logs.sh delete mode 100644 templates/example-nginx/nuke.sh delete mode 100644 templates/example-nginx/ports.sh delete mode 100644 templates/example-nginx/restore.sh delete mode 100644 templates/example-nginx/start.sh delete mode 100644 templates/example-nginx/status.sh delete mode 100644 templates/example-nginx/stop.sh delete mode 100644 templates/example-nginx/uninstall.sh delete mode 100644 templates/simple-object-storage/README.txt delete mode 100644 templates/simple-object-storage/_default.env delete mode 100644 templates/simple-object-storage/backup.sh delete mode 100644 templates/simple-object-storage/config/.template_info.env delete mode 100644 templates/simple-object-storage/config/service.env delete mode 100644 templates/simple-object-storage/config/sos_config.json delete mode 100644 templates/simple-object-storage/install.sh delete mode 100644 templates/simple-object-storage/logs.sh delete mode 100644 templates/simple-object-storage/nuke.sh delete mode 100644 templates/simple-object-storage/ports.sh delete mode 100644 templates/simple-object-storage/restore.sh delete mode 100644 templates/simple-object-storage/ssh.sh delete mode 100644 templates/simple-object-storage/start.sh delete mode 100644 templates/simple-object-storage/status.sh delete mode 100644 templates/simple-object-storage/stop.sh delete mode 100644 templates/simple-object-storage/uninstall.sh delete mode 100644 templates/squashkiwi/_default.env delete mode 100755 templates/squashkiwi/backup.sh delete mode 100644 templates/squashkiwi/config/.template_info.env delete mode 100644 templates/squashkiwi/config/service.env delete mode 100755 templates/squashkiwi/install.sh delete mode 100755 templates/squashkiwi/logs.sh delete mode 100755 templates/squashkiwi/nuke.sh delete mode 100755 templates/squashkiwi/ports.sh delete mode 100755 templates/squashkiwi/restore.sh delete mode 100755 templates/squashkiwi/ssh.sh delete mode 100755 templates/squashkiwi/start.sh delete mode 100755 templates/squashkiwi/status.sh delete mode 100755 templates/squashkiwi/stop.sh delete mode 100755 templates/squashkiwi/uninstall.sh delete mode 100755 templates/test_template.sh delete mode 100644 templates/watchtower/_default.env delete mode 100644 templates/watchtower/config/.template_info.env delete mode 100644 templates/watchtower/config/config.json delete mode 100644 templates/watchtower/config/service.env delete mode 100644 templates/watchtower/install.sh delete mode 100644 templates/watchtower/logs.sh delete mode 100644 templates/watchtower/start.sh delete mode 100644 templates/watchtower/status.sh delete mode 100644 templates/watchtower/stop.sh delete mode 100644 templates/watchtower/uninstall.sh diff --git a/docker/Dockerfile.build b/docker/Dockerfile.build deleted file mode 100644 index fb2a79f..0000000 --- a/docker/Dockerfile.build +++ /dev/null @@ -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"] diff --git a/docker/_create_dropshell.sh b/docker/_create_dropshell.sh deleted file mode 100755 index e6282dc..0000000 --- a/docker/_create_dropshell.sh +++ /dev/null @@ -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 diff --git a/docker/build_builder.sh b/docker/build_builder.sh deleted file mode 100755 index 8442104..0000000 --- a/docker/build_builder.sh +++ /dev/null @@ -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 - diff --git a/docker/compile.sh b/docker/compile.sh deleted file mode 100755 index 6167ec2..0000000 --- a/docker/compile.sh +++ /dev/null @@ -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" - diff --git a/docker/publish_builder.sh b/docker/publish_builder.sh deleted file mode 100755 index 4bfb0ef..0000000 --- a/docker/publish_builder.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker push gitea.jde.nz/j/dropshell_builder:latest diff --git a/docker/publish_dropshell.sh b/docker/publish_dropshell.sh deleted file mode 100755 index 05a7907..0000000 --- a/docker/publish_dropshell.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash - diff --git a/src/commands/install.cpp b/src/commands/install.cpp index 694d4ec..d3cdf97 100644 --- a/src/commands/install.cpp +++ b/src/commands/install.cpp @@ -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(); } diff --git a/src/commands/shared_commands.hpp b/src/commands/shared_commands.hpp index 77b7107..07355cc 100644 --- a/src/commands/shared_commands.hpp +++ b/src/commands/shared_commands.hpp @@ -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 diff --git a/templates/caddy/README.txt b/templates/caddy/README.txt deleted file mode 100644 index 43c0a65..0000000 --- a/templates/caddy/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -Caddy! - -Edit the static site, and the Caddyfile. diff --git a/templates/caddy/_default.env b/templates/caddy/_default.env deleted file mode 100644 index 1473fca..0000000 --- a/templates/caddy/_default.env +++ /dev/null @@ -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 diff --git a/templates/caddy/backup.sh b/templates/caddy/backup.sh deleted file mode 100644 index 810b024..0000000 --- a/templates/caddy/backup.sh +++ /dev/null @@ -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" diff --git a/templates/caddy/config/.template_info.env b/templates/caddy/config/.template_info.env deleted file mode 100644 index ee61c54..0000000 --- a/templates/caddy/config/.template_info.env +++ /dev/null @@ -1,2 +0,0 @@ -# Template to use - always required! -TEMPLATE=caddy diff --git a/templates/caddy/config/Caddyfile b/templates/caddy/config/Caddyfile deleted file mode 100644 index 9bd0b7a..0000000 --- a/templates/caddy/config/Caddyfile +++ /dev/null @@ -1,6 +0,0 @@ -# See https://caddyserver.com/docs/caddyfile - -localhost { -root * /srv -file_server -} diff --git a/templates/caddy/config/service.env b/templates/caddy/config/service.env deleted file mode 100644 index c4f3976..0000000 --- a/templates/caddy/config/service.env +++ /dev/null @@ -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! - - diff --git a/templates/caddy/config/static/index.html b/templates/caddy/config/static/index.html deleted file mode 100644 index cd8f430..0000000 --- a/templates/caddy/config/static/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - Static Site - - -

Static Site

-

This is a static site.

- - \ No newline at end of file diff --git a/templates/caddy/install.sh b/templates/caddy/install.sh deleted file mode 100644 index 1ad9eba..0000000 --- a/templates/caddy/install.sh +++ /dev/null @@ -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" diff --git a/templates/caddy/logs.sh b/templates/caddy/logs.sh deleted file mode 100644 index c1b820f..0000000 --- a/templates/caddy/logs.sh +++ /dev/null @@ -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 diff --git a/templates/caddy/nuke.sh b/templates/caddy/nuke.sh deleted file mode 100644 index 5495b27..0000000 --- a/templates/caddy/nuke.sh +++ /dev/null @@ -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." diff --git a/templates/caddy/ports.sh b/templates/caddy/ports.sh deleted file mode 100644 index aa08d2d..0000000 --- a/templates/caddy/ports.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -source "${AGENT_PATH}/_common.sh" - - -echo 80 -echo 443 diff --git a/templates/caddy/restore.sh b/templates/caddy/restore.sh deleted file mode 100644 index e5c7993..0000000 --- a/templates/caddy/restore.sh +++ /dev/null @@ -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." diff --git a/templates/caddy/start.sh b/templates/caddy/start.sh deleted file mode 100644 index 5f2ec6f..0000000 --- a/templates/caddy/start.sh +++ /dev/null @@ -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" diff --git a/templates/caddy/status.sh b/templates/caddy/status.sh deleted file mode 100644 index 85d3e27..0000000 --- a/templates/caddy/status.sh +++ /dev/null @@ -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 diff --git a/templates/caddy/stop.sh b/templates/caddy/stop.sh deleted file mode 100644 index 9b83cc5..0000000 --- a/templates/caddy/stop.sh +++ /dev/null @@ -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" diff --git a/templates/caddy/uninstall.sh b/templates/caddy/uninstall.sh deleted file mode 100644 index 6163001..0000000 --- a/templates/caddy/uninstall.sh +++ /dev/null @@ -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." diff --git a/templates/example-nginx/README.txt b/templates/example-nginx/README.txt deleted file mode 100644 index 4cbd8ba..0000000 --- a/templates/example-nginx/README.txt +++ /dev/null @@ -1 +0,0 @@ -Caddy diff --git a/templates/example-nginx/_default.env b/templates/example-nginx/_default.env deleted file mode 100644 index a5e0c2d..0000000 --- a/templates/example-nginx/_default.env +++ /dev/null @@ -1,5 +0,0 @@ -# Service settings specific to this server - -# Image settings -IMAGE_REGISTRY="docker.io" -IMAGE_REPO="nginx" diff --git a/templates/example-nginx/backup.sh b/templates/example-nginx/backup.sh deleted file mode 100644 index 5a97acd..0000000 --- a/templates/example-nginx/backup.sh +++ /dev/null @@ -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}" diff --git a/templates/example-nginx/config/.template_info.env b/templates/example-nginx/config/.template_info.env deleted file mode 100644 index ca4a270..0000000 --- a/templates/example-nginx/config/.template_info.env +++ /dev/null @@ -1,2 +0,0 @@ -# Template to use - always required! -TEMPLATE=example-nginx diff --git a/templates/example-nginx/config/service.env b/templates/example-nginx/config/service.env deleted file mode 100644 index 08ab81d..0000000 --- a/templates/example-nginx/config/service.env +++ /dev/null @@ -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! - - diff --git a/templates/example-nginx/install.sh b/templates/example-nginx/install.sh deleted file mode 100644 index d0270a9..0000000 --- a/templates/example-nginx/install.sh +++ /dev/null @@ -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}." diff --git a/templates/example-nginx/logs.sh b/templates/example-nginx/logs.sh deleted file mode 100644 index 085f83a..0000000 --- a/templates/example-nginx/logs.sh +++ /dev/null @@ -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 diff --git a/templates/example-nginx/nuke.sh b/templates/example-nginx/nuke.sh deleted file mode 100644 index 09ae539..0000000 --- a/templates/example-nginx/nuke.sh +++ /dev/null @@ -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}." diff --git a/templates/example-nginx/ports.sh b/templates/example-nginx/ports.sh deleted file mode 100644 index edb1534..0000000 --- a/templates/example-nginx/ports.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -source "${AGENT_PATH}/_common.sh" -_check_required_env_vars "HOST_PORT" - -# Nginx Example Ports Script - -echo $HOST_PORT diff --git a/templates/example-nginx/restore.sh b/templates/example-nginx/restore.sh deleted file mode 100644 index 1f5a0c3..0000000 --- a/templates/example-nginx/restore.sh +++ /dev/null @@ -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." diff --git a/templates/example-nginx/start.sh b/templates/example-nginx/start.sh deleted file mode 100644 index 40438ac..0000000 --- a/templates/example-nginx/start.sh +++ /dev/null @@ -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" diff --git a/templates/example-nginx/status.sh b/templates/example-nginx/status.sh deleted file mode 100644 index 86ba20f..0000000 --- a/templates/example-nginx/status.sh +++ /dev/null @@ -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 diff --git a/templates/example-nginx/stop.sh b/templates/example-nginx/stop.sh deleted file mode 100644 index f908886..0000000 --- a/templates/example-nginx/stop.sh +++ /dev/null @@ -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" diff --git a/templates/example-nginx/uninstall.sh b/templates/example-nginx/uninstall.sh deleted file mode 100644 index 4507a0d..0000000 --- a/templates/example-nginx/uninstall.sh +++ /dev/null @@ -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." diff --git a/templates/simple-object-storage/README.txt b/templates/simple-object-storage/README.txt deleted file mode 100644 index 7041ee9..0000000 --- a/templates/simple-object-storage/README.txt +++ /dev/null @@ -1 +0,0 @@ -simple-object-storage diff --git a/templates/simple-object-storage/_default.env b/templates/simple-object-storage/_default.env deleted file mode 100644 index a214437..0000000 --- a/templates/simple-object-storage/_default.env +++ /dev/null @@ -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" diff --git a/templates/simple-object-storage/backup.sh b/templates/simple-object-storage/backup.sh deleted file mode 100644 index 330afce..0000000 --- a/templates/simple-object-storage/backup.sh +++ /dev/null @@ -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}" diff --git a/templates/simple-object-storage/config/.template_info.env b/templates/simple-object-storage/config/.template_info.env deleted file mode 100644 index 1c2ba83..0000000 --- a/templates/simple-object-storage/config/.template_info.env +++ /dev/null @@ -1,2 +0,0 @@ -# Template to use - always required! -TEMPLATE=simple-object-storage diff --git a/templates/simple-object-storage/config/service.env b/templates/simple-object-storage/config/service.env deleted file mode 100644 index dd27f69..0000000 --- a/templates/simple-object-storage/config/service.env +++ /dev/null @@ -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" diff --git a/templates/simple-object-storage/config/sos_config.json b/templates/simple-object-storage/config/sos_config.json deleted file mode 100644 index 42d55d7..0000000 --- a/templates/simple-object-storage/config/sos_config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "write_tokens": [ - "fizzle1", - "fizzle2", - "fizzle3" - ], - "port": 8123 -} diff --git a/templates/simple-object-storage/install.sh b/templates/simple-object-storage/install.sh deleted file mode 100644 index f0fc364..0000000 --- a/templates/simple-object-storage/install.sh +++ /dev/null @@ -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}" diff --git a/templates/simple-object-storage/logs.sh b/templates/simple-object-storage/logs.sh deleted file mode 100644 index 71945d6..0000000 --- a/templates/simple-object-storage/logs.sh +++ /dev/null @@ -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 diff --git a/templates/simple-object-storage/nuke.sh b/templates/simple-object-storage/nuke.sh deleted file mode 100644 index 9caebee..0000000 --- a/templates/simple-object-storage/nuke.sh +++ /dev/null @@ -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}." diff --git a/templates/simple-object-storage/ports.sh b/templates/simple-object-storage/ports.sh deleted file mode 100644 index b3dbbc2..0000000 --- a/templates/simple-object-storage/ports.sh +++ /dev/null @@ -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 - diff --git a/templates/simple-object-storage/restore.sh b/templates/simple-object-storage/restore.sh deleted file mode 100644 index 4cf61e4..0000000 --- a/templates/simple-object-storage/restore.sh +++ /dev/null @@ -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." diff --git a/templates/simple-object-storage/ssh.sh b/templates/simple-object-storage/ssh.sh deleted file mode 100644 index b99e9cb..0000000 --- a/templates/simple-object-storage/ssh.sh +++ /dev/null @@ -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}" diff --git a/templates/simple-object-storage/start.sh b/templates/simple-object-storage/start.sh deleted file mode 100644 index fc3b8f6..0000000 --- a/templates/simple-object-storage/start.sh +++ /dev/null @@ -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" diff --git a/templates/simple-object-storage/status.sh b/templates/simple-object-storage/status.sh deleted file mode 100644 index 26e96c5..0000000 --- a/templates/simple-object-storage/status.sh +++ /dev/null @@ -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 diff --git a/templates/simple-object-storage/stop.sh b/templates/simple-object-storage/stop.sh deleted file mode 100644 index 98b8169..0000000 --- a/templates/simple-object-storage/stop.sh +++ /dev/null @@ -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." diff --git a/templates/simple-object-storage/uninstall.sh b/templates/simple-object-storage/uninstall.sh deleted file mode 100644 index 31fad56..0000000 --- a/templates/simple-object-storage/uninstall.sh +++ /dev/null @@ -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." diff --git a/templates/squashkiwi/_default.env b/templates/squashkiwi/_default.env deleted file mode 100644 index d1c0279..0000000 --- a/templates/squashkiwi/_default.env +++ /dev/null @@ -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" diff --git a/templates/squashkiwi/backup.sh b/templates/squashkiwi/backup.sh deleted file mode 100755 index cede869..0000000 --- a/templates/squashkiwi/backup.sh +++ /dev/null @@ -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" diff --git a/templates/squashkiwi/config/.template_info.env b/templates/squashkiwi/config/.template_info.env deleted file mode 100644 index ab4665d..0000000 --- a/templates/squashkiwi/config/.template_info.env +++ /dev/null @@ -1,2 +0,0 @@ -# Template to use - always required! -TEMPLATE=squashkiwi diff --git a/templates/squashkiwi/config/service.env b/templates/squashkiwi/config/service.env deleted file mode 100644 index e9a710a..0000000 --- a/templates/squashkiwi/config/service.env +++ /dev/null @@ -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" diff --git a/templates/squashkiwi/install.sh b/templates/squashkiwi/install.sh deleted file mode 100755 index 561148b..0000000 --- a/templates/squashkiwi/install.sh +++ /dev/null @@ -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" diff --git a/templates/squashkiwi/logs.sh b/templates/squashkiwi/logs.sh deleted file mode 100755 index 2efa469..0000000 --- a/templates/squashkiwi/logs.sh +++ /dev/null @@ -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 diff --git a/templates/squashkiwi/nuke.sh b/templates/squashkiwi/nuke.sh deleted file mode 100755 index d3e4cc0..0000000 --- a/templates/squashkiwi/nuke.sh +++ /dev/null @@ -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" - diff --git a/templates/squashkiwi/ports.sh b/templates/squashkiwi/ports.sh deleted file mode 100755 index 8178ba0..0000000 --- a/templates/squashkiwi/ports.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -source "${AGENT_PATH}/_common.sh" -_check_required_env_vars "HOST_PORT" - -echo $HOST_PORT diff --git a/templates/squashkiwi/restore.sh b/templates/squashkiwi/restore.sh deleted file mode 100755 index 5d59bf9..0000000 --- a/templates/squashkiwi/restore.sh +++ /dev/null @@ -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." diff --git a/templates/squashkiwi/ssh.sh b/templates/squashkiwi/ssh.sh deleted file mode 100755 index 3357154..0000000 --- a/templates/squashkiwi/ssh.sh +++ /dev/null @@ -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}" diff --git a/templates/squashkiwi/start.sh b/templates/squashkiwi/start.sh deleted file mode 100755 index 54a6bac..0000000 --- a/templates/squashkiwi/start.sh +++ /dev/null @@ -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}" diff --git a/templates/squashkiwi/status.sh b/templates/squashkiwi/status.sh deleted file mode 100755 index d02d18f..0000000 --- a/templates/squashkiwi/status.sh +++ /dev/null @@ -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 diff --git a/templates/squashkiwi/stop.sh b/templates/squashkiwi/stop.sh deleted file mode 100755 index f908886..0000000 --- a/templates/squashkiwi/stop.sh +++ /dev/null @@ -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" diff --git a/templates/squashkiwi/uninstall.sh b/templates/squashkiwi/uninstall.sh deleted file mode 100755 index f324a25..0000000 --- a/templates/squashkiwi/uninstall.sh +++ /dev/null @@ -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." diff --git a/templates/test_template.sh b/templates/test_template.sh deleted file mode 100755 index a760952..0000000 --- a/templates/test_template.sh +++ /dev/null @@ -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