From b35b729f2fa919be5ddfd491a3c08bf97d0d89d3 Mon Sep 17 00:00:00 2001 From: andre <1+andre@noreply.192.168.100.5> Date: Sat, 23 May 2026 11:28:31 +0200 Subject: [PATCH] =?UTF-8?q?Endurain/auto-upload/watcher.sh=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Endurain/auto-upload/watcher.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Endurain/auto-upload/watcher.sh diff --git a/Endurain/auto-upload/watcher.sh b/Endurain/auto-upload/watcher.sh new file mode 100644 index 0000000..7e9d53f --- /dev/null +++ b/Endurain/auto-upload/watcher.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +source ~/cycling/.config + +ACCESS_TOKEN=$(./login.sh) + +inotifywait -m ~/cycling/inbox -e create | +while read path action file; do + + FULLFILE="$path$file" + + echo "Uploading: $FULLFILE" + + RESPONSE=$(./upload.sh "$ACCESS_TOKEN" "$FULLFILE") + + if echo "$RESPONSE" | jq -e '.id' >/dev/null; then + echo "OK" + mv "$FULLFILE" ~/cycling/uploaded/ + else + echo "FAIL" + mv "$FULLFILE" ~/cycling/failed/ + fi + +done \ No newline at end of file