From 943ed796419a17ae3c6851e165a869395d3e878c Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 3 May 2025 22:03:53 +1200 Subject: [PATCH] testing! --- templates/test_template.sh | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 templates/test_template.sh diff --git a/templates/test_template.sh b/templates/test_template.sh new file mode 100755 index 0000000..5fb2809 --- /dev/null +++ b/templates/test_template.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# default config should always work for localhost + +SCRIPT_DIR=$(dirname "$0") +TEMPLATE="$1" + +function die() { + echo "$1" + exit 1 +} + +function title() { + echo "----------------------------------------" + echo "$1" + echo "----------------------------------------" +} + +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. + + +HASH1=$(ds hash "$SCRIPT_DIR/$TEMPLATE") +HASH2=$(ds hash "/opt/dropshell/templates/$TEMPLATE") + +if [ "$HASH1" != "$HASH2" ]; then + echo "Template $TEMPLATE is out of date" + echo "Need to run build.sh, and install locally." + exit 1 +fi + +SERVICE_NAME="test-$TEMPLATE" + +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 || 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" + + +