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:
@@ -89,7 +89,7 @@ CONFIG
|
||||
# ========================================
|
||||
|
||||
# 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 ""
|
||||
echo "jq is required for JSON processing. Install it with:"
|
||||
@@ -105,11 +105,11 @@ fi
|
||||
# ========================================
|
||||
|
||||
MODE="auto"
|
||||
if [ "$1" == "--setup" ]; then
|
||||
if [ "$1" = "--setup" ]; then
|
||||
MODE="setup"
|
||||
elif [ "$1" == "--update" ]; then
|
||||
elif [ "$1" = "--update" ]; then
|
||||
MODE="update"
|
||||
elif [ "$1" == "--status" ]; then
|
||||
elif [ "$1" = "--status" ]; then
|
||||
MODE="status"
|
||||
elif [ -n "$1" ]; then
|
||||
echo "❌ Unknown option: $1"
|
||||
@@ -201,7 +201,7 @@ else
|
||||
USER_ID=$(echo "$REGISTER_RESPONSE" | jq -r '.user_id')
|
||||
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 "Response: $REGISTER_RESPONSE"
|
||||
exit 1
|
||||
@@ -315,7 +315,7 @@ fi
|
||||
# Auto-detect Mode
|
||||
# ========================================
|
||||
|
||||
if [ "$MODE" == "auto" ]; then
|
||||
if [ "$MODE" = "auto" ]; then
|
||||
if [ -n "$APP_UUID" ]; then
|
||||
MODE="update"
|
||||
else
|
||||
@@ -327,7 +327,7 @@ fi
|
||||
# Setup Mode: Additional Checks
|
||||
# ========================================
|
||||
|
||||
if [ "$MODE" == "setup" ]; then
|
||||
if [ "$MODE" = "setup" ]; then
|
||||
# GITEA_API_TOKEN only required for setup mode (webhook creation)
|
||||
if [ -z "$GITEA_API_TOKEN" ]; then
|
||||
echo "❌ Error: GITEA_API_TOKEN environment variable not set"
|
||||
@@ -363,7 +363,7 @@ FULL_DOMAIN="${SUBDOMAIN}recruit.startanaicompany.com"
|
||||
# ========================================
|
||||
# MODE: STATUS
|
||||
# ========================================
|
||||
if [ "$MODE" == "status" ]; then
|
||||
if [ "$MODE" = "status" ]; then
|
||||
echo "========================================="
|
||||
echo " Deployment Status"
|
||||
echo "========================================="
|
||||
@@ -410,7 +410,7 @@ fi
|
||||
# ========================================
|
||||
# MODE: UPDATE
|
||||
# ========================================
|
||||
if [ "$MODE" == "update" ]; then
|
||||
if [ "$MODE" = "update" ]; then
|
||||
echo "========================================="
|
||||
echo " AI Recruitment Site Deployment"
|
||||
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)
|
||||
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 "Response: $APP_RESPONSE"
|
||||
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)
|
||||
|
||||
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)"
|
||||
else
|
||||
echo "✅ Webhook configured for automatic deployments"
|
||||
|
||||
Reference in New Issue
Block a user