Last active
July 17, 2022 14:30
-
-
Save qwerzl/cac4ae8f18c1571fd1c3adcd20aa9c86 to your computer and use it in GitHub Desktop.
Clash update subscriptions
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
#!/bin/bash | |
DIRECTORY=/etc/clash | |
URL=[订阅地址] | |
cd $DIRECTORY | |
mv ./config.yaml ./config.yaml.bak | |
curl -L -o config.yaml $URL | |
CURLSTATUS=$? | |
yq -i ' | |
.port = "7890" | | |
.allow-lan = "true" | |
' config.yaml | |
YQSTATUS=$? | |
if [ $CURLSTATUS -eq 0 ] || [ $YQSTATUS -eq 0 ] | |
then | |
if cmp --silent -- "$DIRECTORY/config.yaml.bak" "$DIRECTORY/config.yaml" | |
then | |
notify-send "Clash config updated successfully" "Nothing changed" | |
rm ./config.yaml.bak | |
else | |
notify-send "Clash config updated successfully" "File has changed" | |
rm ./config.yaml.bak | |
fi | |
else | |
notify-send "Clash config updated failed" "cURL: $CURLSTATUS yq: $YQSTATUS" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment