diff --git a/platform/shell-sync/sync.sh b/platform/shell-sync/sync.sh index b0689024..0496d178 100644 --- a/platform/shell-sync/sync.sh +++ b/platform/shell-sync/sync.sh @@ -72,3 +72,24 @@ validate_settings() { ;; esac + if [ "$NOTIFY_MODE" != "none" ]; then + if [ -z "$SMTP_HOST" ] || [ -z "$SMTP_FROM" ] || [ -z "$SMTP_TO" ]; then + log "Configuration error: SMTP_HOST, SMTP_FROM, and SMTP_TO are required when notifications are enabled" + return 1 + fi + if ! [[ "$SMTP_PORT" =~ ^[1-9][0-9]*$ ]]; then + log "Configuration error: SMTP_PORT must be a valid port number" + return 1 + fi + if { [ -n "$SMTP_USER" ] && [ -z "$SMTP_PASS" ]; } || { [ -z "$SMTP_USER" ] && [ -n "$SMTP_PASS" ]; }; then + log "Configuration error: SMTP_USER and SMTP_PASS must either both be set or both be empty" + return 1 + fi + case "$SMTP_TLS" in starttls|tls|none) ;; *) + log "Configuration error: SMTP_TLS must be starttls, tls, or none" + return 1 + ;; + esac + fi +} +