Skip to content

Instantly share code, notes, and snippets.

@ficapy
Created February 7, 2023 09:26
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ficapy/aa5e7efee108d58f24339f3a4ff0f00c to your computer and use it in GitHub Desktop.
  1. create a file /etc/init.d/clash
#!/sbin/openrc-run

command="/root/clash-linux-amd64-v3-2022.11.25"
command_args="-f /root/config.yaml"

depend() {
        need net
        after firewall
}

start() {
        ebegin "Starting clash"
        start-stop-daemon --start --background --make-pidfile --stdout /var/log/clash --pidfile /var/run/clash.pid --exec $command -- $command_args
        eend $?
}

stop() {
        ebegin "Stopping clash"
        start-stop-daemon --stop --pidfile /var/run/clash.pid
        eend $?
}
  1. add execute permission
chmod +x /etc/init.d/clash
  1. add to startup
rc-update add clash default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment