Created
July 12, 2019 09:04
-
-
Save kmarius/63076f502090010d543b5e1ff2b27377 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/system/bin/sh | |
APIKEY=get this from syncthing config | |
# wait for service to start | |
retries=5 | |
while ! curl -s -L -k -X GET -H "X-API-Key: $APIKEY" "http://localhost:8384/rest/system/ping" | |
do | |
sleep 1 | |
if test $retries -eq 0; then | |
exit 100 | |
fi | |
retries=$((retries-1)) | |
done | |
# force rescan | |
curl -s -L -k -X POST -H "X-API-Key: $APIKEY" "http://localhost:8384/rest/db/scan" | |
# wait for completion | |
while | |
sleep 5 | |
do | |
if ! curl -s -L -k -X GET -H "X-API-Key: $APIKEY" \ | |
"http://localhost:8384/rest/system/ping" | |
then | |
exit 101 | |
fi | |
if ! curl -s -L -k -X GET -H "X-API-Key: $APIKEY" \ | |
"http://localhost:8384/rest/system/connections" \ | |
| grep -q '"connected":.*true' | |
then | |
exit 102 | |
fi | |
if curl -s -L -k -X GET -H "X-API-Key: $APIKEY" \ | |
"http://localhost:8384/rest/events?events=FolderCompletion&limit=1&timeout=15" \ | |
| grep -q '"completion":.*100' | |
then | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment