Procházet zdrojové kódy

一键 wg ss v2 添加单独选择安装和卸载菜单

hongwenjun před 6 roky
rodič
revize
d69ff75c76
4 změnil soubory, kde provedl 94 přidání a 18 odebrání
  1. 2 0
      README.md
  2. 18 10
      debian_wg_vpn.sh
  3. binární
      img/vps.sh.png
  4. 74 8
      vps.sh

+ 2 - 0
README.md

@@ -5,6 +5,8 @@
 | :------:| :------: | :------: |
 | wget -qO- git.io/fptwc \| bash | bash <(curl -L -s git.io/fhExJ) update | bash <(curl -L -s https://install.direct/go.sh) |
 
+![](https://raw.githubusercontent.com/hongwenjun/vps_setup/master/img/vps.sh.png)
+
 | WireGuard 管理 | bash wgmtu | 卸载命令 | bash wgmtu remove | 
 | :------:| :------: | :------:| :------: |
 

+ 18 - 10
debian_wg_vpn.sh

@@ -10,6 +10,9 @@
 # Debian9  安装 WireGuard 步骤
 # 详细参考逗比  https://doub.io/wg-jc1/
 
+
+debian_wireguard_install(){
+
 # Debian 默认往往都没有 linux-headers 内核,而安装使用 WireGuard 必须要
 
 # 更新软件包源
@@ -25,10 +28,10 @@ dpkg -l|grep linux-headers
 # 添加 unstable 软件包源,以确保安装版本是最新的
 echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/unstable.list
 printf 'Package: *\nPin: release a=unstable\nPin-Priority: 90\n' > /etc/apt/preferences.d/limit-unstable
- 
+
 # 更新一下软件包源
 apt update
- 
+
 # 开始安装 WireGuard ,和辅助库 resolvconf
 apt install wireguard resolvconf -y
 
@@ -54,7 +57,7 @@ echo "[Interface]
 PrivateKey = $(cat sprivatekey)
 
 # VPN中本机的内网IP,一般默认即可,除非和你服务器或客户端设备本地网段冲突
-Address = 10.0.0.1/24 
+Address = 10.0.0.1/24
 
 # 运行 WireGuard 时要执行的 iptables 防火墙规则,用于打开NAT转发之类的。
 # 如果你的服务器主网卡名称不是 eth0 ,那么请修改下面防火墙规则中最后的 eth0 为你的主网卡名称。
@@ -119,7 +122,7 @@ PersistentKeepalive = 25"|sed '/^#/d;/^\s*$/d' > client.conf
 
 # 赋予配置文件夹权限
 chmod 777 -R /etc/wireguard
- 
+
 sysctl_config() {
     sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
     sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
@@ -131,7 +134,7 @@ sysctl_config() {
 # 开启 BBR
 sysctl_config
 lsmod | grep bbr
- 
+
 # 打开防火墙转发功能
 echo 1 > /proc/sys/net/ipv4/ip_forward
 echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
@@ -146,6 +149,12 @@ systemctl enable wg-quick@wg0
 # 查询WireGuard状态
 wg
 
+# 以上配置文本只做参考文档使用,实际生成 WireGuard 多用户配置
+
+# 一键 WireGuard 多用户配置共享脚本
+wget -qO- https://git.io/fpnQt | bash
+
+}
 # ======= 容错:检查系统,调用 Ubuntu Centos 系统对应安装脚本 ========
 check_sys(){
     if [[ -f /etc/redhat-release ]]; then
@@ -168,8 +177,8 @@ check_sys(){
 
 wireguard_config(){
     if [[ ${release} == "centos" ]]; then
-    	yum install -y wget vim curl  	
-        # CentOS 7 一键脚本安装WireGuard  (官方脚本自动升级内核)      
+    	yum install -y wget vim curl
+        # CentOS 7 一键脚本安装WireGuard  (官方脚本自动升级内核)
 		wget -qO- git.io/fhnhS | bash
     fi
 
@@ -179,10 +188,9 @@ wireguard_config(){
     fi
 
     if [[ ${release} == "debian" ]]; then
-        # 一键 WireGuard 多用户配置共享脚本 
-		wget -qO- https://git.io/fpnQt | bash
+        debian_wireguard_install
     fi
 }
 
-# 以上配置文本只是参考文档使用,实际生成 WireGuard 多用户配置 
+
 check_sys && wireguard_config

binární
img/vps.sh.png


+ 74 - 8
vps.sh

@@ -1,13 +1,79 @@
 #!/bin/bash
 
-# 一键安装wireguard 脚本
-wget -qO- git.io/fptwc | bash
+# 默认安装 WireGuard Shadowsocks V2Ray 服务端三合一脚本
+default_install(){
 
-# V2Ray官方一键脚本
-bash <(curl -L -s https://install.direct/go.sh)
+    # 一键安装wireguard 脚本
+    wget -qO- git.io/fptwc | bash
 
-# 一键安装shadowsocks-libev脚本
-wget -qO- git.io/fhExJ | bash
+    # V2Ray官方一键脚本
+    bash <(curl -L -s https://install.direct/go.sh)
+
+    # 一键安装shadowsocks-libev脚本
+    wget -qO- git.io/fhExJ | bash
+
+    # 安装 WireGuard+Speeder+Udp2Raw 和 SS+Kcp+Udp2RAW 配置
+    bash wgmtu setup
+}
+
+display_conf(){
+    echo
+    echo
+    echo_SkyBlue "# ======================================="
+    echo_GreenBG "# V2ray 服务端配置 /etc/v2ray/config.json"
+    cat /etc/v2ray/config.json
+    echo
+    echo_SkyBlue "# WG+Speed+Udp2Raw 和 SS+Kcp+Udp2RAW 配置 /etc/rc.local"
+    cat /etc/rc.local
+    echo_GreenBG "# WireGuard 客户端配置 /etc/wireguard/client.conf"
+    cat /etc/wireguard/client.conf
+}
+
+# 设置菜单
+start_menu(){
+    clear
+    echo_GreenBG ">  开源项目:  https://github.com/hongwenjun/vps_setup  "
+    echo_SkyBlue ">  1. 默认安装 WireGuard Shadowsocks V2Ray 服务端三合一"
+    echo_SkyBlue ">  2. 选择安装 WireGuard 多用户服务端"
+    echo_SkyBlue ">  3. 选择安装 Shadowsocks 编译/更新"
+    echo_SkyBlue ">  4. 卸载 WireGuard Shadowsocks V2ray 服务"
+    echo_SkyBlue ">  5. 显示 WireGuard V2ray 和 rc.local 配置"
+    echo_SkyBlue ">  6. 退出"
+    read -p "请输入数字:" num
+    case "$num" in
+        1)
+        default_install
+        ;;
+        2)
+        wget -qO- git.io/fptwc | bash
+        ;;
+        3)
+        bash <(curl -L -s git.io/fhExJ) update
+        ;;
+        4)
+        bash <(curl -L -s https://install.direct/go.sh) --remove
+        bash wgmtu remove
+        ;;
+        5)
+        display_conf
+        ;;
+        6)
+        exit 1
+        ;;
+        *)
+        default_install
+        ;;
+        esac
+}
+
+# 显示文字颜色
+GreenBG="\033[42;37m" && Font="\033[0m" && SkyBlue="\033[0;36m"
+echo_GreenBG(){
+    echo -e "${GreenBG}$1${Font}"
+}
+echo_SkyBlue(){
+    echo -e "${SkyBlue}$1${Font}"
+}
+
+start_menu
 
-# 安装 WireGuard+Speeder+Udp2Raw 和 SS+Kcp+Udp2RAW 配置
-bash wgmtu setup