Download and unzip package from following URL
https://github.com/Dreamacro/clash
Execute the clash once and it generated the .config folder under /home/<user> path
Automactically download initial config.yaml & country.mmdb from web.
Download the config.yaml from the ladder site and replace the original config file.
Create clash.service file as following
# edit and save this file to /usr/lib/systemd/system/clash.service [Unit] Description=clash After=network.target [Service] WorkingDirectory=/home/<usrid>/.config/clash ExecStart= /home/<usrid>/.config/clash/start-clash.sh ExecStop= /home/<usrid>/.config/clash/stop-clash.sh Environment="HOME=/home/<usrid>" #Environment="CLASH_URL=" [Install] WantedBy=multi-user.target
Create two shell scripts:
#!/bin/bash # save this file to ${HOME}/.config/clash/start-clash.sh # save pid file echo $$ > ${HOME}/.config/clash/clash.pid ${HOME}/work/clash
#!/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
Then enable and start clash as service
systemctl enable clash systemctl start clash
本篇文章已有0条评论