jrunner/deploy.sh
Paul Trowbridge e9fc745d20 fix deploy script to honor custom directory names
The zip file contains 'jrunner/' as top-level directory, so unzipping
always created /opt/jrunner regardless of custom path. Now the script
renames the directory after unzipping if a custom name was specified.

Example:
  ./deploy.sh /opt/jr_test

Now correctly creates /opt/jr_test (not /opt/jrunner).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:15:33 -05:00

47 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
# Default deployment directory
DEPLOY_DIR="${1:-/opt/jrunner}"
# Safety checks
if [ -z "${DEPLOY_DIR}" ]; then
echo "Error: Deployment directory cannot be empty"
exit 1
fi
# Prevent deleting critical system directories
case "${DEPLOY_DIR}" in
/|/bin|/boot|/dev|/etc|/lib|/lib64|/proc|/root|/run|/sbin|/sys|/usr|/var|/home)
echo "Error: Cannot deploy to system directory: ${DEPLOY_DIR}"
exit 1
;;
esac
echo "Building jrunner..."
./gradlew build
echo "Deploying to ${DEPLOY_DIR}..."
if [ -d "${DEPLOY_DIR}" ]; then
echo "Removing existing deployment..."
sudo rm -rf "${DEPLOY_DIR}"
fi
sudo mkdir -p "$(dirname "${DEPLOY_DIR}")"
sudo unzip -q jrunner/build/distributions/jrunner.zip -d "$(dirname "${DEPLOY_DIR}")"
# Rename if custom directory name was specified
if [ "$(basename "${DEPLOY_DIR}")" != "jrunner" ]; then
sudo mv "$(dirname "${DEPLOY_DIR}")/jrunner" "${DEPLOY_DIR}"
fi
# Only create symlink for default location
if [ "${DEPLOY_DIR}" = "/opt/jrunner" ]; then
echo "Creating symlink..."
sudo ln -sf /opt/jrunner/bin/jrunner /usr/local/bin/jrunner
echo "✅ Deployment complete!"
echo "Run 'jrunner --help' to test"
else
echo "✅ Deployment complete!"
echo "Run '${DEPLOY_DIR}/bin/jrunner --help' to test"
fi