Last active
August 11, 2022 02:09
-
-
Save mbierman/f0a8fffdfd358def4416f943112b82e0 to your computer and use it in GitHub Desktop.
Gets an auth token and then lists the plugins you have installed and all the information about them. Can be used for any homebridge UI API call.
This file contains hidden or 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
| #!/bin/sh | |
| # token=$(curl -s -X POST "http://pigpen.lan:8581/api/auth/login" -H "accept: */*" -H "Content-Type: application/json" -d '{"username":"admin","password":"^","otp":"string"}' | jq '.access_token' | | |
| token=$(curl -s -X POST "http://pigpen.lan:8581/api/auth/login" -H "accept: */*" -H "Content-Type: application/json" -d '{"username":"admin","password":"","otp":"string"}' | grep -e 'access_token' | |
| basedir=/homebridge/plugins/plugins_ | |
| today=$basedir$(date "+%m.%d.%Y").txt | |
| curl -X GET "http://pigpen.lan:8581/api/plugins" -H "accept: */*" -H "Authorization: Bearer $token" -o $today 2>&1 | |
| yesterday=$basedir$(date --date yesterday '+%m.%d.%Y').txt | |
| DIFF=$(grep 'updateAvailable":true,' $today) | |
| if [ "$DIFF" != "" ] | |
| then | |
| mv $today $basedir$(date "+%m.%d.%Y")_UPDATE_READY.txt | |
| fi | |
| find /homebridge/plugins/plugins_* -mtime +7 -not -name "*UPDATE*" -exec rm -f {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment