-
-
Save jinhucheung/958c57e612c593b0e485e6baca1639b9 to your computer and use it in GitHub Desktop.
clash auto start and update subcribe configuration
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
# edit and save this file to /usr/lib/systemd/system/clash.service | |
[Unit] | |
Description=clash | |
After=network.target | |
[Service] | |
WorkingDirectory="your home directory"/.config/clash | |
ExecStart="your home directory"/.config/clash/start-clash.sh | |
ExecStop="your home directory"/.config/clash/stop-clash.sh | |
Environment="HOME=your home directory" | |
Environment="CLASH_URL=your subscribe address" | |
[Install] | |
WantedBy=multi-user.target |
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/bash | |
# save this file to ${HOME}/.config/clash/start-clash.sh | |
# save pid file | |
echo $$ > ${HOME}/.config/clash/clash.pid | |
diff ${HOME}/.config/clash/config.yaml <(curl -s ${CLASH_URL}) | |
if [ "$?" == 0 ] | |
then | |
/usr/bin/clash | |
else | |
TIME=`date '+%Y-%m-%d %H:%M:%S'` | |
cp ${HOME}/.config/clash/config.yaml "${HOME}/.config/clash/config.yaml.bak${TIME}" | |
curl -L -o ${HOME}/.config/clash/config.yaml ${CLASH_URL} | |
/usr/bin/clash | |
fi |
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/bash | |
# save this file to ${HOME}/.config/clash/stop-clash.sh | |
# read pid file | |
PID=`cat ${HOME}/.config/clash/clash.pid` | |
kill -9 ${PID} | |
rm ${HOME}/.config/clash/clash.pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment