net-proxy/shadowsocks-rust: add openrc init scripts
[gentoo-zh.git] / net-proxy / v2rayA / files / v2rayA-user.initd
blobd27c6ae7d95aad030c1955b3e7fd0bd2822ef81c
1 #!/sbin/openrc-run
2 # Copyright 2022 Gentoo Authors
3 # Distributed under the terms of the GNU General Public License v2
5 USER="${RC_SVCNAME##*.}"
6 HOME="$(eval echo ~${USER})"
7 name="v2rayA for ${USER}"
8 description="A Linux web GUI client of Project V which supports V2Ray, Xray, SS, SSR, Trojan and Pingtunnel"
9 command="/usr/bin/v2raya"
10 command_user="${USER}"
11 command_args="--lite --log-file ${HOME}/.config/v2raya/v2raya.log ${V2RAYA_OPTS}"
12 error_log="${HOME}/.config/v2raya/error.log"
13 pidfile="/run/${RC_SVCNAME}.pid"
14 command_background="yes"
16 depend() {
17         need net
18         after net
21 start_pre() {
22         if [ "$USER" = "v2raya-user" ]; then
23                 eerror "You are not supposed to run this script directly."
24                 eerror "Create a symlink for this script:"
25                 eerror "  ln -s ${RC_SVCNAME} /etc/init.d/${RC_SVCNAME}.<user>"
26                 return 1
28         elif [ "$USER" = "root" ]; then
29                 eerror "Root user doesn't need to run v2rayA daemon by link."
30                 eerror "Instead just run /etc/init.d/v2raya directly."
31                 return 1
32         fi