fix race condition in deploy script rename logic
Previous version failed when /opt/jrunner existed from a prior run, because mv cannot move over an existing directory. Now the script: 1. Removes target directory if it exists 2. Removes intermediate jrunner/ directory if it exists and differs from target (prevents collision) 3. Extracts cleanly 4. Renames to target name This fixes the issue where ./deploy.sh /opt/jr_test would fail if /opt/jrunner already existed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4b8ffcdd1c
commit
c6d34847d5
21
deploy.sh
21
deploy.sh
@ -22,16 +22,27 @@ echo "Building jrunner..."
|
||||
./gradlew build
|
||||
|
||||
echo "Deploying to ${DEPLOY_DIR}..."
|
||||
|
||||
# Remove both target and intermediate jrunner directory if they exist
|
||||
if [ -d "${DEPLOY_DIR}" ]; then
|
||||
echo "Removing existing deployment..."
|
||||
echo "Removing existing deployment at ${DEPLOY_DIR}..."
|
||||
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
|
||||
PARENT_DIR="$(dirname "${DEPLOY_DIR}")"
|
||||
EXTRACT_DIR="${PARENT_DIR}/jrunner"
|
||||
|
||||
if [ -d "${EXTRACT_DIR}" ] && [ "${EXTRACT_DIR}" != "${DEPLOY_DIR}" ]; then
|
||||
echo "Removing existing jrunner directory at ${EXTRACT_DIR}..."
|
||||
sudo rm -rf "${EXTRACT_DIR}"
|
||||
fi
|
||||
|
||||
# Extract and rename if needed
|
||||
sudo mkdir -p "${PARENT_DIR}"
|
||||
sudo unzip -q jrunner/build/distributions/jrunner.zip -d "${PARENT_DIR}"
|
||||
|
||||
if [ "$(basename "${DEPLOY_DIR}")" != "jrunner" ]; then
|
||||
sudo mv "$(dirname "${DEPLOY_DIR}")/jrunner" "${DEPLOY_DIR}"
|
||||
sudo mv "${EXTRACT_DIR}" "${DEPLOY_DIR}"
|
||||
fi
|
||||
|
||||
# Only create symlink for default location
|
||||
|
||||
Loading…
Reference in New Issue
Block a user