fix(scripts): add fallback logic for OpenSMTPD binary detection

The scripts were hardcoded to look for OpenSMTPD at a custom workspace
path, but the Dockerfile installs it via apt to /usr/sbin/smtpd. This
change adds fallback logic to check multiple locations:

1. Custom workspace path (for backward compatibility)
2. System path /usr/sbin/smtpd
3. Anywhere in PATH

Also adds graceful handling when OpenSMTPD is not installed, logging
an informative message instead of failing with "No such file or directory".
This commit is contained in:
cto-new[bot]
2026-02-09 12:51:31 +00:00
parent 0d17918cad
commit ee4e630b45
2 changed files with 36 additions and 7 deletions

View File

@@ -174,8 +174,20 @@ main() {
# Check OpenSMTPD service (ports 25, 587, 465)
health_log "INFO" "=== OpenSMTPD Service ==="
OPENSMTPD_BINARY="/workspace/src/backend/app/opensmtpd/install/sbin/smtpd"
if [ -x "$OPENSMTPD_BINARY" ]; then
OPENSMTPD_CUSTOM_BINARY="/workspace/src/backend/app/opensmtpd/install/sbin/smtpd"
OPENSMTPD_SYSTEM_BINARY="/usr/sbin/smtpd"
# Determine which binary to use (prefer custom, fallback to system)
OPENSMTPD_BINARY=""
if [ -x "$OPENSMTPD_CUSTOM_BINARY" ]; then
OPENSMTPD_BINARY="$OPENSMTPD_CUSTOM_BINARY"
elif [ -x "$OPENSMTPD_SYSTEM_BINARY" ]; then
OPENSMTPD_BINARY="$OPENSMTPD_SYSTEM_BINARY"
elif command -v smtpd &>/dev/null; then
OPENSMTPD_BINARY="$(command -v smtpd)"
fi
if [ -n "$OPENSMTPD_BINARY" ]; then
# Check SMTP port 25
if check_port 25 "SMTP"; then
health_log "INFO" "✓ SMTP port 25 is listening"
@@ -205,7 +217,7 @@ main() {
health_log "WARN" "⚠ OpenSMTPD process not found (may be disabled)"
fi
else
health_log "INFO" "OpenSMTPD not installed at expected location, skipping SMTP checks"
health_log "INFO" "OpenSMTPD not installed (checked: $OPENSMTPD_CUSTOM_BINARY, $OPENSMTPD_SYSTEM_BINARY, PATH), skipping SMTP checks"
fi
# ttyd service has been removed, no longer checking port 4501