45 lines
1.1 KiB
Bash
Executable File
45 lines
1.1 KiB
Bash
Executable File
TIME=$(date +%s)
|
|
ALERT_GAP=86400
|
|
|
|
source /Users/noahheague/.config/scripts/util/secret.sh
|
|
API_KEY=$(getSecret "/server/mac-mini-1/seed-api-key")
|
|
API_URL=$(getSecret "/server/mac-mini-1/seed-api-url")
|
|
|
|
echo $API_URL
|
|
echo $API_KEY
|
|
|
|
SEED_COUNT=$(curl --request GET \
|
|
--silent \
|
|
--url "$API_URL" \
|
|
--header "X-API-Key: $API_KEY" \
|
|
--header "Cache-Control: no-cache" \
|
|
| jq ".response.community.seeding")
|
|
|
|
echo $SEED_COUNT
|
|
|
|
if [ "$SEED_COUNT" = "null" ]; then
|
|
if [ ! -f /tmp/seed-timestamp.txt ]; then
|
|
echo $TIME > /tmp/seed-timestamp.txt;
|
|
|
|
/Users/noahheague/.config/scripts/util/webhook.sh \
|
|
-c "torrent" \
|
|
-m "Seeding has paused!"
|
|
|
|
/usr/local/bin/docker restart $(/usr/local/bin/docker ps | grep deluge | cut -d' ' -f1)
|
|
|
|
fi;
|
|
|
|
SAVED_TIME=$(cat /tmp/seed-timestamp.txt)
|
|
SAVED_TIME_PLUS=$(( $SAVED_TIME + $ALERT_GAP ));
|
|
|
|
if [ $TIME -ge $SAVED_TIME_PLUS ]; then
|
|
echo $TIME > /tmp/seed-timestamp.txt;
|
|
|
|
/Users/noahheague/.config/scripts/util/webhook.sh \
|
|
-c "torrent" \
|
|
-m "Seeding is still paused!"
|
|
fi
|
|
else
|
|
rm /tmp/seed-timestamp.txt 2> /dev/null || true
|
|
fi
|