Fix POSIX shell compatibility in deployment script

- Replace bash-specific &> with >/dev/null 2>&1
- Replace bash-specific == with POSIX-compliant = in [ ] tests
- Script now works with both sh and bash
- Fixes "unexpected operator" errors when run with sh

Issue: User ran script with 'sh' instead of 'bash', causing errors
Root cause: Bash-specific syntax (== and &>) not compatible with POSIX sh
Solution: Use POSIX-compliant alternatives that work in both shells
This commit is contained in:
2026-01-24 19:58:32 +01:00
parent 2082c3caec
commit 0fce839b7c

View File

@@ -89,7 +89,7 @@ CONFIG
# ======================================== # ========================================
# Check if jq is installed # Check if jq is installed
if ! command -v jq &> /dev/null; then if ! command -v jq >/dev/null 2>&1; then
echo "❌ Error: jq is not installed" echo "❌ Error: jq is not installed"
echo "" echo ""
echo "jq is required for JSON processing. Install it with:" echo "jq is required for JSON processing. Install it with:"
@@ -105,11 +105,11 @@ fi
# ======================================== # ========================================
MODE="auto" MODE="auto"
if [ "$1" == "--setup" ]; then if [ "$1" = "--setup" ]; then
MODE="setup" MODE="setup"
elif [ "$1" == "--update" ]; then elif [ "$1" = "--update" ]; then
MODE="update" MODE="update"
elif [ "$1" == "--status" ]; then elif [ "$1" = "--status" ]; then
MODE="status" MODE="status"
elif [ -n "$1" ]; then elif [ -n "$1" ]; then
echo "❌ Unknown option: $1" echo "❌ Unknown option: $1"
@@ -201,7 +201,7 @@ else
USER_ID=$(echo "$REGISTER_RESPONSE" | jq -r '.user_id') USER_ID=$(echo "$REGISTER_RESPONSE" | jq -r '.user_id')
SAAC_API_KEY=$(echo "$REGISTER_RESPONSE" | jq -r '.api_key') SAAC_API_KEY=$(echo "$REGISTER_RESPONSE" | jq -r '.api_key')
if [ "$USER_ID" == "null" ] || [ -z "$USER_ID" ] || [ "$SAAC_API_KEY" == "null" ] || [ -z "$SAAC_API_KEY" ]; then if [ "$USER_ID" = "null" ] || [ -z "$USER_ID" ] || [ "$SAAC_API_KEY" = "null" ] || [ -z "$SAAC_API_KEY" ]; then
echo "❌ Failed to extract user data from registration response" echo "❌ Failed to extract user data from registration response"
echo "Response: $REGISTER_RESPONSE" echo "Response: $REGISTER_RESPONSE"
exit 1 exit 1
@@ -315,7 +315,7 @@ fi
# Auto-detect Mode # Auto-detect Mode
# ======================================== # ========================================
if [ "$MODE" == "auto" ]; then if [ "$MODE" = "auto" ]; then
if [ -n "$APP_UUID" ]; then if [ -n "$APP_UUID" ]; then
MODE="update" MODE="update"
else else
@@ -327,7 +327,7 @@ fi
# Setup Mode: Additional Checks # Setup Mode: Additional Checks
# ======================================== # ========================================
if [ "$MODE" == "setup" ]; then if [ "$MODE" = "setup" ]; then
# GITEA_API_TOKEN only required for setup mode (webhook creation) # GITEA_API_TOKEN only required for setup mode (webhook creation)
if [ -z "$GITEA_API_TOKEN" ]; then if [ -z "$GITEA_API_TOKEN" ]; then
echo "❌ Error: GITEA_API_TOKEN environment variable not set" echo "❌ Error: GITEA_API_TOKEN environment variable not set"
@@ -363,7 +363,7 @@ FULL_DOMAIN="${SUBDOMAIN}recruit.startanaicompany.com"
# ======================================== # ========================================
# MODE: STATUS # MODE: STATUS
# ======================================== # ========================================
if [ "$MODE" == "status" ]; then if [ "$MODE" = "status" ]; then
echo "=========================================" echo "========================================="
echo " Deployment Status" echo " Deployment Status"
echo "=========================================" echo "========================================="
@@ -410,7 +410,7 @@ fi
# ======================================== # ========================================
# MODE: UPDATE # MODE: UPDATE
# ======================================== # ========================================
if [ "$MODE" == "update" ]; then if [ "$MODE" = "update" ]; then
echo "=========================================" echo "========================================="
echo " AI Recruitment Site Deployment" echo " AI Recruitment Site Deployment"
echo "=========================================" echo "========================================="
@@ -575,7 +575,7 @@ APP_UUID=$(echo "$APP_RESPONSE" | jq -r '.application_uuid' 2>/dev/null)
DOMAIN=$(echo "$APP_RESPONSE" | jq -r '.domain' 2>/dev/null) DOMAIN=$(echo "$APP_RESPONSE" | jq -r '.domain' 2>/dev/null)
WEBHOOK_URL=$(echo "$APP_RESPONSE" | jq -r '.webhook_url' 2>/dev/null) WEBHOOK_URL=$(echo "$APP_RESPONSE" | jq -r '.webhook_url' 2>/dev/null)
if [ "$APP_UUID" == "null" ] || [ -z "$APP_UUID" ]; then if [ "$APP_UUID" = "null" ] || [ -z "$APP_UUID" ]; then
echo "❌ Failed to create application" echo "❌ Failed to create application"
echo "Response: $APP_RESPONSE" echo "Response: $APP_RESPONSE"
exit 1 exit 1
@@ -612,7 +612,7 @@ WEBHOOK_RESPONSE=$(curl -s -X POST "${GITEA_API}/repos/${GITEA_USERNAME}/${GITEA
WEBHOOK_ID=$(echo "$WEBHOOK_RESPONSE" | jq -r '.id' 2>/dev/null) WEBHOOK_ID=$(echo "$WEBHOOK_RESPONSE" | jq -r '.id' 2>/dev/null)
if [ "$WEBHOOK_ID" == "null" ] || [ -z "$WEBHOOK_ID" ]; then if [ "$WEBHOOK_ID" = "null" ] || [ -z "$WEBHOOK_ID" ]; then
echo "⚠️ Warning: Failed to create Gitea webhook (may already exist)" echo "⚠️ Warning: Failed to create Gitea webhook (may already exist)"
else else
echo "✅ Webhook configured for automatic deployments" echo "✅ Webhook configured for automatic deployments"