Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
chore(scripts): make the smoke tests runnable and drop a superseded helper
Yudhi Armyndharis9c95d9c084ae
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 93dea69a0..8ff25ce82 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -241,10 +241,11 @@ jobs:- name: Install shellcheckrun: sudo apt-get install -y --no-install-recommends shellcheck- - name: shellcheck the backup/restore scripts- # Scope this PR: lint the three scripts #926 added or rewrote. Widening to the rest of- # scripts/*.sh is tracked separately so a pre-existing warning elsewhere can't fail this gate.- run: shellcheck scripts/backup.sh scripts/restore.sh scripts/smoke-test-backup-restore.sh+ - name: shellcheck every shell script+ # Widened from the original three (#926) now that the rest are clean too. The narrow scope was+ # not free: `smoke-test-non-root.sh` carried a UTF-8 BOM before its shebang for months, which+ # shellcheck reports as SC1082 and which nothing else here would ever have caught.+ run: shellcheck scripts/*.sh- name: Run backup/restore smoke testrun: ./scripts/smoke-test-backup-restore.shdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex c99c9c041..186387c93 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Fixed++- **The non-root smoke test can actually be run.** `scripts/smoke-test-non-root.sh` carried a UTF-8+ BOM ahead of its `#!/bin/sh`, and neither it nor `scripts/smoke-test-docker-proxy.sh` had the+ executable bit — so the `./scripts/…` invocation both of them document failed outright. The image+ runs its process as a non-root user by dropping privileges in the entrypoint rather than by a+ `USER` directive, which is a runtime property no static check can see, and this script is the only+ thing that verifies it. CI's shellcheck step now covers every script in `scripts/` instead of three+ of them; the BOM is exactly what it reports as SC1082, so the narrow scope is what let it survive.++### Removed++- `scripts/openwa.sh`, an orchestration helper superseded by the in-process Docker orchestration on+ `/api/infra`. It had no reference from `package.json`, any workflow, the Dockerfile, either compose+ file, or the documentation.+## [0.12.1] - 2026-07-30### Addeddiff --git a/scripts/openwa.sh b/scripts/openwa.shdeleted file mode 100755index d0b617ce5..000000000--- a/scripts/openwa.sh+++ /dev/null@@ -1,205 +0,0 @@-#!/bin/bash-# OpenWA Smart Orchestration Script-# Reads .env and activates appropriate Docker profiles--set -e--# Colors-RED='\033[0;31m'-GREEN='\033[0;32m'-YELLOW='\033[1;33m'-BLUE='\033[0;34m'-NC='\033[0m' # No Color--# Script directory-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"-PROJECT_DIR="$(dirname "$SCRIPT_DIR")"--# Log functions-log_info() { echo -e "${BLUE}ℹ${NC} $1"; }-log_success() { echo -e "${GREEN}✓${NC} $1"; }-log_warn() { echo -e "${YELLOW}⚠${NC} $1"; }-log_error() { echo -e "${RED}✗${NC} $1"; }--# Load environment variables-load_env() {- if [ -f "$PROJECT_DIR/.env" ]; then- log_info "Loading .env file..."- set -a- source "$PROJECT_DIR/.env"- set +a- else- log_warn ".env file not found, using defaults"- fi-}--# Determine which profiles to activate-get_profiles() {- local profiles=""-- # Dashboard is bundled into the openwa-api image and served by NestJS on the API port —- # no separate container/profile needed. Put your own TLS proxy in front if required.-- # PostgreSQL (built-in)- if [ "${DATABASE_TYPE:-sqlite}" = "postgres" ] && [ "${POSTGRES_BUILTIN:-false}" = "true" ]; then- profiles="$profiles --profile postgres"- log_info "PostgreSQL: built-in container"- elif [ "${DATABASE_TYPE:-sqlite}" = "postgres" ]; then- log_info "PostgreSQL: external (${DATABASE_HOST:-localhost}:${DATABASE_PORT:-5432})"- else- log_info "Database: SQLite"- fi-- # Redis (built-in)- if [ "${REDIS_ENABLED:-false}" = "true" ] && [ "${REDIS_BUILTIN:-false}" = "true" ]; then- profiles="$profiles --profile redis"- log_info "Redis: built-in container"- elif [ "${REDIS_ENABLED:-false}" = "true" ]; then- log_info "Redis: external (${REDIS_HOST:-localhost}:${REDIS_PORT:-6379})"- else- log_info "Redis: disabled"- fi-- # MinIO (built-in S3)- if [ "${STORAGE_TYPE:-local}" = "s3" ] && [ "${MINIO_BUILTIN:-false}" = "true" ]; then- profiles="$profiles --profile minio"- log_info "Storage: built-in MinIO"- elif [ "${STORAGE_TYPE:-local}" = "s3" ]; then- log_info "Storage: external S3 (${S3_ENDPOINT})"- else- log_info "Storage: local filesystem"- fi-- # Engine type- log_info "Engine: ${ENGINE_TYPE:-whatsapp-web.js}"-- echo "$profiles"-}--# Validate engine type-validate_engine() {- local engine="${ENGINE_TYPE:-whatsapp-web.js}"- local valid_engines=("whatsapp-web.js" "baileys")-- for valid in "${valid_engines[@]}"; do- if [ "$engine" = "$valid" ]; then- return 0- fi- done-- log_error "Invalid ENGINE_TYPE: $engine"- log_error "Valid options: ${valid_engines[*]}"- exit 1-}--# Start OpenWA-cmd_start() {- log_info "Starting OpenWA..."- load_env- validate_engine-- local profiles=$(get_profiles)-- echo ""- log_info "Activating profiles:$profiles"- echo ""-- cd "$PROJECT_DIR"- docker compose $profiles up -d-- echo ""- log_success "OpenWA started successfully!"- echo ""- log_info "Dashboard & API: http://localhost:${API_PORT:-2785}"-}--# Stop OpenWA-cmd_stop() {- log_info "Stopping OpenWA..."- cd "$PROJECT_DIR"- docker compose --profile full down- log_success "OpenWA stopped"-}--# Restart OpenWA-cmd_restart() {- cmd_stop- cmd_start-}--# Show status-cmd_status() {- log_info "OpenWA container status:"- echo ""- cd "$PROJECT_DIR"- docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Ports}}"-}--# Show logs-cmd_logs() {- local service="${1:-openwa-api}"- local lines="${2:-100}"- cd "$PROJECT_DIR"- docker compose logs -f --tail="$lines" "$service"-}--# Build images-cmd_build() {- log_info "Building OpenWA images..."- load_env- local profiles=$(get_profiles)- cd "$PROJECT_DIR"- docker compose $profiles build- log_success "Build complete"-}--# Update (pull + build + restart)-cmd_update() {- log_info "Updating OpenWA..."- cd "$PROJECT_DIR"- git pull- cmd_build- cmd_restart- log_success "Update complete"-}--# Show help-cmd_help() {- echo ""- echo "OpenWA Smart Orchestration Script"- echo ""- echo "Usage: $0 <command> [options]"- echo ""- echo "Commands:"- echo " start Start OpenWA with auto-detected profiles"- echo " stop Stop all OpenWA containers"- echo " restart Restart OpenWA"- echo " status Show container status"- echo " logs Show logs (default: openwa-api)"- echo " build Build Docker images"- echo " update Pull latest code and restart"- echo " help Show this help"- echo ""- echo "Profile activation is automatic based on .env:"- echo " POSTGRES_BUILTIN=true → activates postgres profile"- echo " REDIS_BUILTIN=true → activates redis profile"- echo " MINIO_BUILTIN=true → activates minio profile"- echo ""-}--# Main-case "${1:-help}" in- start) cmd_start ;;- stop) cmd_stop ;;- restart) cmd_restart ;;- status) cmd_status ;;- logs) cmd_logs "${2:-}" "${3:-}" ;;- build) cmd_build ;;- update) cmd_update ;;- help) cmd_help ;;- *)- log_error "Unknown command: $1"- cmd_help- exit 1- ;;-esacdiff --git a/scripts/smoke-test-docker-proxy.sh b/scripts/smoke-test-docker-proxy.shold mode 100644new mode 100755diff --git a/scripts/smoke-test-non-root.sh b/scripts/smoke-test-non-root.shold mode 100644new mode 100755index 6df3b63c5..5e13d36c8--- a/scripts/smoke-test-non-root.sh+++ b/scripts/smoke-test-non-root.sh@@ -1,4 +1,4 @@-#!/bin/sh+#!/bin/sh# Smoke test: verify the built image runs its process as the openwa user (not root).# Usage: ./scripts/smoke-test-non-root.sh# Requires Docker to be running locally.