403Webshell
Server IP : 202.61.199.114  /  Your IP : 216.73.217.139
Web Server : nginx/1.22.1
System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
User : web20 ( 1018)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/crons/private/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/crons/private/weather_report.sh
#!/usr/bin/env bash
set -euo pipefail

# =========================
# Konfiguration
# =========================
PUSHOVER_TOKEN="as42nnc2mc83d2s16d3ksgd2u36s4a"
PUSHOVER_USER="u1dm6khe362yms9fwx2k8ysc9zuigb"
PUSHOVER_DEVICE="iphone"   # optional, sonst leer lassen

CITY="Rostock"
LAT="54.0924"
LON="12.0991"
TIMEZONE="Europe/Berlin"

RAIN_THRESHOLD="0.0"

TMP_JSON="$(mktemp)"
trap 'rm -f "$TMP_JSON"' EXIT

# =========================
# Wetter abrufen
# =========================
curl -fsSL \
  "https://api.open-meteo.com/v1/forecast?latitude=${LAT}&longitude=${LON}&hourly=rain&timezone=${TIMEZONE}&forecast_days=1" \
  -o "$TMP_JSON"

# =========================
# Regenlogik + Nachricht
# =========================
MESSAGE="$(
jq -r --arg city "$CITY" --argjson threshold "$RAIN_THRESHOLD" '
  def rainy_hours:
    [ range(0; (.hourly.time | length)) as $i
      | select((.hourly.rain[$i] // 0) > $threshold)
      | (.hourly.time[$i] | split("T")[1] | split(":")[0] | tonumber)
    ];

  def ranges(xs):
    reduce xs[] as $h (
      [];
      if length == 0 then
        [{start:$h, end:$h}]
      else
        .[-1] as $last
        | if $h == ($last.end + 1) then
            .[0:length-1] + [{start:$last.start, end:$h}]
          else
            . + [{start:$h, end:$h}]
          end
      end
    );

  (rainy_hours) as $hours
  | if ($hours | length) == 0 then
      empty
    else
      (ranges($hours)) as $ranges
      | ($ranges | length) as $count
      | if $count == 1 and (($ranges[0].end - $ranges[0].start) >= 2) then
          "🌧️ Heute ist zwischen \($ranges[0].start) und \($ranges[0].end) Uhr in \($city) mit Regen zu rechnen."
        else
          "🌧️ Heute ist zwischen " +
          ($ranges | map(
            if .start == .end then
              "\(.start) Uhr"
            else
              "\(.start)-\(.end) Uhr"
            end
          ) | join(" und ")) +
          " in \($city) mit Regen zu rechnen."
        end
    end
' "$TMP_JSON"
)"

# =========================
# Nur senden, wenn Regen (silent)
# =========================
if [[ -n "$MESSAGE" ]]; then
  curl -fsS \
    --form-string "token=$PUSHOVER_TOKEN" \
    --form-string "user=$PUSHOVER_USER" \
    --form-string "title=REGEN in Rostock" \
    --form-string "message=$MESSAGE" \
    ${PUSHOVER_DEVICE:+--form-string "device=$PUSHOVER_DEVICE"} \
    https://api.pushover.net/1/messages.json > /dev/null 2>&1
fi

Youez - 2016 - github.com/yon3zu
LinuXploit