Skip to content

Instantly share code, notes, and snippets.

@qwerzl
Last active July 17, 2022 14:30
Show Gist options
  • Save qwerzl/cac4ae8f18c1571fd1c3adcd20aa9c86 to your computer and use it in GitHub Desktop.
Save qwerzl/cac4ae8f18c1571fd1c3adcd20aa9c86 to your computer and use it in GitHub Desktop.
Clash update subscriptions
#!/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