diff --git a/notify.sh b/notify.sh index 87648a8..5a2455f 100644 --- a/notify.sh +++ b/notify.sh @@ -15,10 +15,19 @@ echo "" # Function: Send to Ntfy (Modern Push Notification) send_ntfy() { + echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" + echo -e "${YELLOW}🔔 Ntfy Push Notification${NC}" + echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" + + # Debug: Show environment variables + echo -e " ${YELLOW}Debug Info:${NC}" + echo -e " NTFY_URL: ${GREEN}${NTFY_URL:-'(not set)'}${NC}" + echo -e " NTFY_TOPIC: ${GREEN}${NTFY_TOPIC:-'(not set)'}${NC}" + echo -e " NTFY_USERNAME: ${GREEN}${NTFY_USERNAME:-'(not set)'}${NC}" + echo -e " NTFY_PASSWORD: ${GREEN}${NTFY_PASSWORD:+'***set***'}${NTFY_PASSWORD:-'(not set)'}${NC}" + echo "" + if [ -n "$NTFY_URL" ] && [ -n "$NTFY_TOPIC" ]; then - echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" - echo -e "${YELLOW}🔔 Ntfy Push Notification${NC}" - echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e " Server: ${GREEN}$NTFY_URL${NC}" echo -e " Topic: ${GREEN}$NTFY_TOPIC${NC}" echo "" @@ -37,7 +46,11 @@ send_ntfy() { # Check for Basic Auth if [ -n "$NTFY_USERNAME" ] && [ -n "$NTFY_PASSWORD" ]; then auth_args="-u $NTFY_USERNAME:$NTFY_PASSWORD" + echo -e " ${GREEN}✓${NC} Using Basic Authentication" + else + echo -e " ${YELLOW}⚠${NC} No authentication (public topic)" fi + echo "" # Build rich message with metadata local rich_message=$(cat <&1) http_code=$(echo "$response" | tail -n1) + response_body=$(echo "$response" | head -n -1) if [ "$http_code" = "200" ] || [ "$http_code" = "201" ]; then - echo -e " ${GREEN}✓${NC} Notification sent successfully" + echo -e " ${GREEN}✓${NC} Notification sent successfully (HTTP $http_code)" else echo -e " ${RED}✗${NC} Failed to send notification (HTTP $http_code)" + if [ -n "$response_body" ]; then + echo -e " ${RED}Response:${NC} $response_body" + fi fi echo "" + else + echo -e " ${RED}✗${NC} Skipping Ntfy - Missing required configuration" + [ -z "$NTFY_URL" ] && echo -e " ${RED}•${NC} NTFY_URL is not set" + [ -z "$NTFY_TOPIC" ] && echo -e " ${RED}•${NC} NTFY_TOPIC is not set" + echo "" fi }