#!/bin/bash set -e DEPLOY_DIR="${1:-/opt/jrunner}" # Prevent deleting critical system directories case "${DEPLOY_DIR}" in /|/bin|/boot|/dev|/etc|/lib|/lib64|/proc|/root|/run|/sbin|/sys|/usr|/var) echo "Error: Cannot deploy to system directory: ${DEPLOY_DIR}" exit 1 ;; esac if [ ! -d "${DEPLOY_DIR}" ]; then echo "Error: Directory does not exist: ${DEPLOY_DIR}" echo "Create it first: sudo mkdir -p ${DEPLOY_DIR}" exit 1 fi echo "Building jrunner..." ./gradlew build echo "Extracting to temporary location..." sudo rm -rf /tmp/jrunner sudo unzip -q jrunner/build/distributions/jrunner.zip -d /tmp/ echo "Deploying to ${DEPLOY_DIR}..." sudo rm -rf "${DEPLOY_DIR}"/* sudo mv /tmp/jrunner/* "${DEPLOY_DIR}"/ sudo rm -rf /tmp/jrunner # Only create symlink for /opt/jrunner if [ "${DEPLOY_DIR}" = "/opt/jrunner" ]; then echo "Creating symlink..." sudo ln -sf /opt/jrunner/bin/jrunner /usr/local/bin/jrunner fi echo "✅ Deployed to ${DEPLOY_DIR}" echo "Run '${DEPLOY_DIR}/bin/jrunner --help' to test"