add safety checks to deploy script
Prevent dangerous sudo rm -rf operations: - Check that DEPLOY_DIR is not empty - Block deployment to critical system directories (/, /usr, /etc, etc.) - Only remove directory if it already exists - Show message before removal for clarity This prevents catastrophic mistakes like accidentally deploying to / or deleting important system directories. 🤖 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
20d40f069d
commit
9cf698c67d
19
deploy.sh
19
deploy.sh
@ -4,11 +4,28 @@ set -e
|
|||||||
# Default deployment directory
|
# Default deployment directory
|
||||||
DEPLOY_DIR="${1:-/opt/jrunner}"
|
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..."
|
echo "Building jrunner..."
|
||||||
./gradlew build
|
./gradlew build
|
||||||
|
|
||||||
echo "Deploying to ${DEPLOY_DIR}..."
|
echo "Deploying to ${DEPLOY_DIR}..."
|
||||||
sudo rm -rf "${DEPLOY_DIR}"
|
if [ -d "${DEPLOY_DIR}" ]; then
|
||||||
|
echo "Removing existing deployment..."
|
||||||
|
sudo rm -rf "${DEPLOY_DIR}"
|
||||||
|
fi
|
||||||
sudo mkdir -p "$(dirname "${DEPLOY_DIR}")"
|
sudo mkdir -p "$(dirname "${DEPLOY_DIR}")"
|
||||||
sudo unzip jrunner/build/distributions/jrunner.zip -d "$(dirname "${DEPLOY_DIR}")"
|
sudo unzip jrunner/build/distributions/jrunner.zip -d "$(dirname "${DEPLOY_DIR}")"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user