Your First Deploy Script

Write a bash script with conditionals, exit codes, and variable validation.

A advanced Linux challenge worth 20 points. Solve it hands-on in a real Linux environment in your browser - no local setup, no fake shells.

The Challenge

Scenario: The team wants a pre-deploy validation script that CI will call before every deployment.

Write the script at /tmp/validate_deploy.sh that:

  1. Checks if /opt/app/config.json exists → exit 1 with message "ERROR: config.json missing" if not
  2. Checks if /opt/app/deploy.sh is executable → exit 1 with message "ERROR: deploy.sh not executable" if not
  3. Checks if the $APP_ENV variable is set → exit 1 with message "ERROR: APP_ENV not set" if not
  4. Prints "DEPLOY OK" and exits 0 if all checks pass

Make it executable and test: APP_ENV=production bash /tmp/validate_deploy.sh

Commands to learn: if [ -f ], if [ -x ], if [ -z ], exit 1, chmod +x

Run check when done.