2023-10-26 23:55:12 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Run script with a crontab to automatically restart on error.
|
|
|
|
# Checks the API to see if data is still being pushed through.
|
|
|
|
|
2023-12-05 13:32:03 +00:00
|
|
|
FIRST_CHAR=$(curl -s 127.0.0.1:3000/api/map | head -c1)
|
|
|
|
TIMESTAMP=$(curl -s 127.0.0.1:3000/api/map | head -c23 | tail -c10)
|
2023-10-27 21:10:36 +00:00
|
|
|
CURR_TIMESTAMP=$(date +%s)
|
|
|
|
DIFF_TIMESTAMP=$(($CURR_TIMESTAMP-$TIMESTAMP))
|
2023-10-26 23:55:12 +00:00
|
|
|
|
2023-10-27 21:10:36 +00:00
|
|
|
if [[ "$FIRST_CHAR" != "{" ]] || [[ $DIFF_TIMESTAMP -gt 60 ]]; then
|
2023-10-26 23:55:12 +00:00
|
|
|
docker compose -f /opt/blah2/docker-compose.yml down
|
|
|
|
systemctl restart sdrplay.service
|
|
|
|
docker compose -f /opt/blah2/docker-compose.yml up -d
|
2023-10-27 11:21:54 +00:00
|
|
|
echo "Successfully restarted blah2"
|
2023-10-26 23:55:12 +00:00
|
|
|
fi
|