Make deploy script interactive with local/global/custom options
- Option 1: Local install (uses gradlew installDist) - Option 2: Global install to /opt/jrunner with symlink - Option 3: Custom directory (mandatory user input) - Removed default directory, now requires explicit choice Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1717c7ee2c
commit
1ca507d1dd
89
deploy.sh
89
deploy.sh
@ -1,7 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
DEPLOY_DIR="${1:-/opt/jrunner}"
|
echo "jrunner deployment script"
|
||||||
|
echo "========================="
|
||||||
|
echo ""
|
||||||
|
echo "Select deployment option:"
|
||||||
|
echo " 1) Local install (./jrunner/build/install)"
|
||||||
|
echo " 2) Global install (/opt/jrunner)"
|
||||||
|
echo " 3) Custom directory"
|
||||||
|
echo ""
|
||||||
|
read -p "Enter choice [1-3]: " choice
|
||||||
|
|
||||||
|
case $choice in
|
||||||
|
1)
|
||||||
|
DEPLOY_MODE="local"
|
||||||
|
DEPLOY_DIR="./jrunner/build/install/jrunner"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
DEPLOY_MODE="global"
|
||||||
|
DEPLOY_DIR="/opt/jrunner"
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
DEPLOY_MODE="custom"
|
||||||
|
read -p "Enter deployment directory (required): " DEPLOY_DIR
|
||||||
|
if [ -z "$DEPLOY_DIR" ]; then
|
||||||
|
echo "Error: Directory path is required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Invalid choice"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Prevent deleting critical system directories
|
# Prevent deleting critical system directories
|
||||||
case "${DEPLOY_DIR}" in
|
case "${DEPLOY_DIR}" in
|
||||||
@ -11,32 +42,46 @@ case "${DEPLOY_DIR}" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ ! -d "${DEPLOY_DIR}" ]; then
|
echo ""
|
||||||
echo "Error: Directory does not exist: ${DEPLOY_DIR}"
|
|
||||||
echo "Create it first: sudo mkdir -p ${DEPLOY_DIR}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Building jrunner..."
|
echo "Building jrunner..."
|
||||||
./gradlew build
|
./gradlew build
|
||||||
|
|
||||||
echo "Extracting to temporary location..."
|
if [ "$DEPLOY_MODE" = "local" ]; then
|
||||||
sudo rm -rf /tmp/jrunner
|
echo "Installing locally with gradle..."
|
||||||
sudo unzip -q jrunner/build/distributions/jrunner.zip -d /tmp/
|
./gradlew installDist
|
||||||
|
echo ""
|
||||||
|
echo "✅ Installed locally at: ${DEPLOY_DIR}"
|
||||||
|
echo "Run './jrunner/build/install/jrunner/bin/jrunner --help' to test"
|
||||||
|
else
|
||||||
|
# Global or custom deployment
|
||||||
|
if [ ! -d "${DEPLOY_DIR}" ]; then
|
||||||
|
echo "Creating directory: ${DEPLOY_DIR}"
|
||||||
|
sudo mkdir -p "${DEPLOY_DIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Deploying to ${DEPLOY_DIR}..."
|
echo "Extracting to temporary location..."
|
||||||
sudo rm -rf "${DEPLOY_DIR}"/*
|
sudo rm -rf /tmp/jrunner-deploy
|
||||||
sudo mv /tmp/jrunner/* "${DEPLOY_DIR}"/
|
sudo unzip -q jrunner/build/distributions/jrunner.zip -d /tmp/jrunner-deploy
|
||||||
sudo rm -rf /tmp/jrunner
|
|
||||||
|
|
||||||
echo "Fixing ownership..."
|
echo "Deploying to ${DEPLOY_DIR}..."
|
||||||
sudo chown -R $USER:$USER "${DEPLOY_DIR}"
|
sudo rm -rf "${DEPLOY_DIR}"/*
|
||||||
|
sudo mv /tmp/jrunner-deploy/jrunner/* "${DEPLOY_DIR}"/
|
||||||
|
sudo rm -rf /tmp/jrunner-deploy
|
||||||
|
|
||||||
# Only create symlink for /opt/jrunner
|
echo "Fixing ownership..."
|
||||||
if [ "${DEPLOY_DIR}" = "/opt/jrunner" ]; then
|
sudo chown -R $USER:$USER "${DEPLOY_DIR}"
|
||||||
echo "Creating symlink..."
|
|
||||||
|
# Create symlink for global install
|
||||||
|
if [ "$DEPLOY_MODE" = "global" ]; then
|
||||||
|
echo "Creating symlink at /usr/local/bin/jrunner..."
|
||||||
sudo ln -sf /opt/jrunner/bin/jrunner /usr/local/bin/jrunner
|
sudo ln -sf /opt/jrunner/bin/jrunner /usr/local/bin/jrunner
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✅ Deployed to ${DEPLOY_DIR}"
|
echo ""
|
||||||
echo "Run '${DEPLOY_DIR}/bin/jrunner --help' to test"
|
echo "✅ Deployed to ${DEPLOY_DIR}"
|
||||||
|
echo "Run '${DEPLOY_DIR}/bin/jrunner --help' to test"
|
||||||
|
|
||||||
|
if [ "$DEPLOY_MODE" = "global" ]; then
|
||||||
|
echo "Or simply: jrunner --help"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user