likwid/scripts/demo-reset.sh

59 lines
1.9 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# Demo Reset Script (Linux/macOS)
# Resets the demo instance to a clean state with fresh seed data
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR/.."
ENV_FILE="compose/.env.demo"
COMPOSE_ARGS=("-f" "compose/demo.yml")
if [ -f "$ENV_FILE" ]; then
COMPOSE_ARGS=("--env-file" "$ENV_FILE" "-f" "compose/demo.yml")
elif [ -f "compose/.env.demo.example" ]; then
COMPOSE_ARGS=("--env-file" "compose/.env.demo.example" "-f" "compose/demo.yml")
fi
echo "=== Likwid Demo Reset ==="
if [ "$1" != "--force" ] && [ "$1" != "-f" ]; then
read -p "This will DELETE all demo data and reset to initial state. Continue? (y/N) " confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
echo "Aborted."
exit 0
fi
fi
echo -e "\n[1/3] Stopping demo containers and removing volumes..."
podman-compose "${COMPOSE_ARGS[@]}" down --remove-orphans -v || docker-compose "${COMPOSE_ARGS[@]}" down --remove-orphans -v
echo -e "\n[2/3] Starting fresh demo instance..."
podman-compose "${COMPOSE_ARGS[@]}" up -d || docker-compose "${COMPOSE_ARGS[@]}" up -d
echo -e "\n[3/3] Waiting for services to be ready..."
sleep 5
max_retries=30
retry=0
while [ $retry -lt $max_retries ]; do
if curl -s http://localhost:3001/health > /dev/null 2>&1; then
echo -e "\n=== Demo Reset Complete ==="
echo -e "\nDemo is ready at:"
echo " Frontend: http://localhost:4322"
echo " Backend: http://localhost:3001"
echo -e "\nDemo accounts (password: demo123):"
echo " - contributor (standard member)"
echo " - moderator (can moderate)"
echo " - observer (read-only)"
exit 0
fi
retry=$((retry + 1))
echo -n "."
sleep 1
done
echo -e "\nWarning: Backend health check timed out. Check logs with:"
echo " podman-compose ${COMPOSE_ARGS[*]} logs backend"
echo " docker-compose ${COMPOSE_ARGS[*]} logs backend"