Closed master-coder-ll closed 1 year ago
針對Linux作業系統比較不熟悉的朋友
在設定開機自動啟動v2proxy的時候有發現腳本在各系統架構的有些許不太一樣的語法格式 使用Ubuntu的朋友如果單一執行腳本出現Bad Substitution,請把"{"、"}"改成"("、")"即可
Ubuntu: Create v2panel-stop.sh
#!/bin/sh
PID1=$(cat /var/run/v2ray-admin.pid)
kill -15 $PID1
PID2=$(cat /var/run/v2ray-proxy.pid)
kill -15 $PID2
腳本記得檢查是否有無執行權限,若無執行權限會無法順利執行v2panel.service
直接使用 systemctl
管理進程
vi /etc/systemd/system/v2ray-admin.service
[Unit]
Description=V2Ray Admin
After=network.target
[Service]
SuccessExitStatus=143
User=root
Group=root
Type=simple
WorkingDirectory=/opt/jar
ExecStart=/usr/bin/java -jar -Xms40m -Xmx40m -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=80m admin.jar --spring.config.location=/opt/jar/admin.yaml
ExecStop=/bin/kill -15 $MAINPID
[Install]
WantedBy=multi-user.target
vi /etc/systemd/system/v2ray-proxy.service
[Unit]
Description=V2Ray Proxy
After=network.target
[Service]
SuccessExitStatus=143
User=root
Group=root
Type=simple
WorkingDirectory=/opt/jar
ExecStart=/usr/bin/java -jar -Xms40m -Xmx40m -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=80m v2ray-proxy.jar --spring.config.location=/opt/jar/proxy.yaml
ExecStop=/bin/kill -15 $MAINPID
[Install]
WantedBy=multi-user.target
Create v2panel-start.sh
vi /opt/jar/v2panel-start.sh
Create v2panel-stop.sh
vi /opt/jar/v2panel-stop.sh
Register v2panel service
vi /etc/systemd/system/v2panel.service
Set autostart
systemctl enable v2panel
Start servicesystemctl start v2panel
Stop servicesystemctl stop v2panel
Originally posted by @savaza in https://github.com/master-coder-ll/v2ray-web-manager/issues/59#issuecomment-605067523