1
0
Эх сурвалжийг харах

Arch 和 Debian系统 能添加到开机服务

蘭雅sRGB 4 жил өмнө
parent
commit
211c059a4c
1 өөрчлөгдсөн 31 нэмэгдсэн , 5 устгасан
  1. 31 5
      debian/sskcp.sh

+ 31 - 5
debian/sskcp.sh

@@ -4,6 +4,7 @@ SERVER_IP=188.188.188.188
 PORT=1999
 PASSWORD=wg2999
 SS_PORT=40000
+SOCKS5_PORT=1080
 
 start(){
   # SS + KcpTun + Udp2RAW
@@ -11,9 +12,9 @@ start(){
     kcp-client -r 127.0.0.1:4000 -l :$SS_PORT --key $PASSWORD -mode fast2 -mtu 1300  >> /var/log/kcp-client.log  2>&1 &
 
   # ss-local -s 服务器IP地址  -p 服务器端口  -b 绑定本地IP  -l 本地端口  -k 密码  -m 加密方式 [-c 配置文件]
-    ss-local -s 127.0.0.1 -p $SS_PORT -b 0.0.0.0 -l 1080 -k $PASSWORD -m aes-256-gcm  -t 300 >> /var/log/ss-local.log &
+    ss-local -s 127.0.0.1 -p $SS_PORT -b 0.0.0.0 -l $SOCKS5_PORT -k $PASSWORD -m aes-256-gcm  -t 300 >> /var/log/ss-local.log &
 
-    status
+  # status
 }
 
 stop(){
@@ -29,7 +30,7 @@ restart(){
 
 help(){
     echo -e "${SkyBlue}:: Source: ${Green}https://git.io/sskcp.sh  ${Font}By 蘭雅sRGB"
-    echo -e "${SkyBlue}:: Usage: ${GreenBG} bash sskcp.sh ${Yellow} [start|stop|restart|set] ${Font}"
+    echo -e "${SkyBlue}:: Usage: ${GreenBG} bash sskcp.sh ${Yellow} [start|stop|restart|service|set] ${Font}"
     echo
 }
 
@@ -71,7 +72,7 @@ setconf()
         sed -i "s/^SS_PORT=.*/SS_PORT=${ss_port}/g"  "sskcp.sh"
     fi
 
-    echo -e "${Yellow}" && head -n 6 sskcp.sh | tail -n 4 &&  echo -e "${Font}"
+    echo -e "${Yellow}" && head -n 7 sskcp.sh | tail -n 5 &&  echo -e "${Font}"
 }
 
 system_def(){
@@ -79,6 +80,29 @@ system_def(){
 	Font="\033[0m"  && Yellow="\033[0;33m" && SkyBlue="\033[0;36m"
 }
 
+systemd_service(){
+    # 安装启动服务
+    cat <<EOF >/usr/lib/systemd/system/sskcp.service
+[Unit]
+Description=sskcp.sh Service
+After=network.target
+
+[Service]
+Type=forking
+User=root
+ExecStart=nohup /root/sskcp.sh start &
+ExecReload=sh /root/sskcp.sh stop
+
+[Install]
+WantedBy=multi-user.target
+
+EOF
+	chmod +x  /root/sskcp.sh
+	systemctl enable sskcp.service
+	systemctl start sskcp.service
+	systemctl status sskcp.service
+}
+
 # 脚本命令参数
 system_def
 if [[ $# > 0 ]]; then
@@ -93,6 +117,9 @@ if [[ $# > 0 ]]; then
         restart)
           restart
         ;;
+	service)
+          systemd_service
+        ;;
         set)
           setconf
         ;;
@@ -101,4 +128,3 @@ else
     status
 fi
 help
-