commit fa12c85cbca2ddcfc5085af4248e292a40622721 Author: gaoyuheng Date: Fri Dec 5 22:28:10 2025 +0800 i diff --git a/example.net b/example.net new file mode 100644 index 0000000..4a885da --- /dev/null +++ b/example.net @@ -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 \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..fa37276 --- /dev/null +++ b/install.sh @@ -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 \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..6cbea7e --- /dev/null +++ b/readme.md @@ -0,0 +1,2 @@ +cd && wget https://git.nia.ink/brnet/vpncloud-alpine/raw/branch/master/install.sh && chmod +x install.sh && ./install.sh + diff --git a/vpncloud_bin b/vpncloud_bin new file mode 100644 index 0000000..bdfa43d Binary files /dev/null and b/vpncloud_bin differ diff --git a/vpncloud_init.d b/vpncloud_init.d new file mode 100644 index 0000000..29b4fdd --- /dev/null +++ b/vpncloud_init.d @@ -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." + eerror "Then start: rc-service vpncloud. 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 $? +} \ No newline at end of file