- 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 $?
}
- add execute permission
chmod +x /etc/init.d/clash
- add to startup
rc-update add clash default