i
This commit is contained in:
4
example.net
Normal file
4
example.net
Normal file
@@ -0,0 +1,4 @@
|
||||
# ln -s /etc/init.d/wg-quick /etc/init.d/vpncloud.vc_38903
|
||||
# 启动:rc-service vpncloud.vc_38903 start
|
||||
# 停止:rc-service vpncloud.vc_38903 stop
|
||||
# 开机自启:rc-update add vpncloud.vc_38903 default
|
||||
15
install.sh
Normal file
15
install.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd
|
||||
git clone https://git.nia.ink/brnet/vpncloud-alpine.git
|
||||
|
||||
mv ./vpncloud-alpine/vpncloud_bin /usr/local/bin/vpncloud
|
||||
chmod +x /usr/local/bin/vpncloud
|
||||
mv ./vpncloud-alpine/vpncloud_init.d /etc/init.d/vpncloud
|
||||
chmod +x /etc/init.d/vpncloud
|
||||
mkdir /etc/vpncloud
|
||||
mv ./vpncloud-alpine/example.net /etc/vpncloud/example.net
|
||||
|
||||
cd
|
||||
rm -rf vpncloud-alpine
|
||||
rm install.sh
|
||||
2
readme.md
Normal file
2
readme.md
Normal file
@@ -0,0 +1,2 @@
|
||||
cd && wget https://git.nia.ink/brnet/vpncloud-alpine/raw/branch/master/install.sh && chmod +x install.sh && ./install.sh
|
||||
|
||||
BIN
vpncloud_bin
Normal file
BIN
vpncloud_bin
Normal file
Binary file not shown.
78
vpncloud_init.d
Normal file
78
vpncloud_init.d
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
name="VPNCloud"
|
||||
description="VPNCloud 2.4.0"
|
||||
extra_started_commands="status"
|
||||
|
||||
CONF="${SVCNAME#*.}"
|
||||
CONFIG_FILE="/etc/vpncloud/$CONF.net"
|
||||
PIDFILE="/var/run/vpncloud-$CONF.pid"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
use dns
|
||||
}
|
||||
|
||||
checkconfig() {
|
||||
if [ "$CONF" = "$SVCNAME" ]; then
|
||||
eerror "Usage error: Create symlink first:"
|
||||
eerror " ln -s /etc/init.d/vpncloud /etc/init.d/vpncloud.<conf-name>"
|
||||
eerror "Then start: rc-service vpncloud.<conf-name> start"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
eerror "Config file $CONFIG_FILE not found!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p /var/run
|
||||
chmod 755 /var/run
|
||||
return 0
|
||||
}
|
||||
|
||||
start() {
|
||||
checkconfig || return 1
|
||||
ebegin "Starting $description (config: $CONF.net)"
|
||||
nohup /usr/local/bin/vpncloud --config "$CONFIG_FILE" > /dev/null 2>&1 &
|
||||
echo $! > "$PIDFILE"
|
||||
eend $? "Start failed!"
|
||||
}
|
||||
|
||||
stop() {
|
||||
checkconfig || return 1
|
||||
ebegin "Stopping $description (config: $CONF.net)"
|
||||
|
||||
if [ -f "$PIDFILE" ]; then
|
||||
local PID=$(cat "$PIDFILE")
|
||||
# 适配 BusyBox ps:用 grep 过滤 PID(替代 ps -p)
|
||||
if ps | grep -w "$PID" > /dev/null; then
|
||||
kill -INT "$PID" && sleep 2
|
||||
# 再次检查,未停止则强制终止
|
||||
if ps | grep -w "$PID" > /dev/null; then
|
||||
kill -KILL "$PID"
|
||||
fi
|
||||
fi
|
||||
rm -f "$PIDFILE"
|
||||
else
|
||||
eerror "PID file not found - service not running?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
eend $? "Stop failed!"
|
||||
}
|
||||
|
||||
status() {
|
||||
checkconfig || return 1
|
||||
ebegin "Checking $description status (config: $CONF.net)"
|
||||
|
||||
if [ -f "$PIDFILE" ] && ps | grep -w "$(cat "$PIDFILE")" > /dev/null; then
|
||||
eecho "Running (PID: $(cat "$PIDFILE"))"
|
||||
return 0
|
||||
else
|
||||
eecho "Not running"
|
||||
return 1
|
||||
fi
|
||||
|
||||
eend $?
|
||||
}
|
||||
Reference in New Issue
Block a user