Created
December 12, 2021 12:54
-
-
Save rkben/99e61b13fe33205e736aecda562cbace to your computer and use it in GitHub Desktop.
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 | |
| ADGUARD_HOST='http://192.168.1.3:8083' | |
| ADGUARD_NAME='admin' | |
| ADGUARD_PASS='password' | |
| ADGUARD_COOKIE=/tmp/adguard-cookie | |
| echo LOGIN: $(curl -s "$ADGUARD_HOST/control/login" -X POST -H 'User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Content-Type: application/json' -H "Origin: $ADGUARD_HOST" -H 'Connection: keep-alive' -H "Referer: $ADGUARD_HOST/login.html" --data-raw "{\"name\":\"$ADGUARD_NAME\",\"password\":\"$ADGUARD_PASS\"}" -c $ADGUARD_COOKIE) | |
| PROT_STATUS=$(curl -s "$ADGUARD_HOST/control/status" -H 'User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Connection: keep-alive' -H "Referer: $ADGUARD_HOST" -b $ADGUARD_COOKIE | jq .protection_enabled) | |
| TO_STATUS=false | |
| if [ $PROT_STATUS == 'false' ] | |
| then | |
| TO_STATUS=true | |
| fi | |
| echo Adguard Home from $PROT_STATUS to $TO_STATUS | |
| curl -s "$ADGUARD_HOST/control/dns_config" -X POST -H 'User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Content-Type: application/json' -H "Origin: $ADGUARD_HOST" -H 'Connection: keep-alive' -H "Referer: $ADGUARD_HOST" --data-raw "{\"protection_enabled\":$TO_STATUS}" -b $ADGUARD_COOKIE | |
| rm -fv $ADGUARD_COOKIE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment