Procházet zdrojové kódy

WireGuard VPN Multi-user Configuration Script, Support IPV6

hongwenjun před 6 roky
rodič
revize
53022b797b
2 změnil soubory, kde provedl 82 přidání a 29 odebrání
  1. 18 3
      README.md
  2. 64 26
      wireguard-install.sh

+ 18 - 3
README.md

@@ -4,7 +4,12 @@
 bash <(curl -L -s https://raw.githubusercontent.com/hongwenjun/vps_setup/english/vps.sh)
 ```
 ------
-### wireguard-install
+### WireGuard
+
+```
+# One-Step Automated Install WireGuard Script
+bash <(curl -L -s https://raw.githubusercontent.com/hongwenjun/vps_setup/english/wireguard-install.sh)
+```
 
 [WireGuard](https://www.wireguard.com) installer for Ubuntu 18.04 LTS, Debian 9 and CentOS 7.
 
@@ -14,8 +19,18 @@ This script will let you setup your own VPN server in no more than a minute, eve
 
 ### shadowsocks-libev
 
-[![Travis CI](https://travis-ci.org/shadowsocks/shadowsocks-libev.svg?branch=master)](https://travis-ci.org/shadowsocks/shadowsocks-libev) [![Snap Status](https://build.snapcraft.io/badge/shadowsocks/shadowsocks-libev.svg)](https://build.snapcraft.io/user/shadowsocks/shadowsocks-libev)
+[Shadowsocks-libev](https://shadowsocks.org) is a lightweight secured SOCKS5
+proxy for embedded devices and low-end boxes.
+
+It is a port of [Shadowsocks](https://github.com/shadowsocks/shadowsocks)
+created by [@clowwindy](https://github.com/clowwindy), and maintained by
+[@madeye](https://github.com/madeye) and [@linusyang](https://github.com/linusyang).
 
 ------
 ### Project V  (V2Ray)
-Project V is a set of network tools that help you to build your own computer network. It secures your network connections and thus protects your privacy. See [our website](https://www.v2ray.com/) for more information.
+Project V is a set of network tools that help you to build your own computer network. It secures your network connections and thus protects your privacy. See [our website](https://www.v2ray.com/) for more information.
+
+```
+# Easy Install Shadowsocks & V2Ray : Generate and display QR code
+bash <(curl -L -s https://raw.githubusercontent.com/hongwenjun/vps_setup/english/v2ray_ss_conf.sh)
+```

+ 64 - 26
wireguard-install.sh

@@ -1,30 +1,69 @@
 #!/bin/bash
-
-# wireguard-install
 # WireGuard  installer for Ubuntu 18.04 LTS, Debian 9 and CentOS 7.
 
-# This script will let you setup your own VPN server in no more than a minute, even if you haven't used WireGuard before. 
+# This script will let you setup your own VPN server in no more than a minute, even if you haven't used WireGuard before.
 # It has been designed to be as unobtrusive and universal as possible.
 
+# wireguard-install
+wireguard_install(){
+    if [ -e /etc/centos-release ]; then
+        DISTRO="CentOS"
+    elif [ -e /etc/debian_version ]; then
+        DISTRO=$( lsb_release -is )
+    else
+        echo "Your distribution is not supported (yet)"
+        exit
+    fi
 
-# 一键安装wireguard 脚本
-wget -qO- git.io/fptwc | bash
+    if [ "$DISTRO" == "Ubuntu" ]; then
+        apt update
+        apt install software-properties-common -y
+        echo .read | add-apt-repository ppa:wireguard/wireguard
+        apt update
+        apt install wireguard resolvconf qrencode -y
+
+    elif [ "$DISTRO" == "Debian" ]; then
+        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
+        apt install wireguard resolvconf qrencode -y
+
+    elif [ "$DISTRO" == "CentOS" ]; then
+        curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-7/jdoss-wireguard-epel-7.repo
+        yum install -y epel-release
+        yum install -y wireguard-dkms wireguard-tools
+        yum -y install qrencode iptables-services
+
+        systemctl stop firewalld  && systemctl disable firewalld
+        systemctl enable iptables && systemctl start iptables
+        iptables -F  && service iptables save && service iptables restart
 
+    fi
+
+    mkdir -p /etc/wireguard
+    cd /etc/wireguard
+    wg genkey | tee sprivatekey | wg pubkey > spublickey
+    wg genkey | tee cprivatekey | wg pubkey > cpublickey
+    chmod 777 -R /etc/wireguard
+    systemctl enable wg-quick@wg0
+}
 
-# WireGuard VPN多用户服务端 自动配置脚本 支持IPV6
+if [ ! -f '/usr/bin/wg' ]; then
+    wireguard_install
+fi
 
+# WireGuard VPN  Multi-user Configuration Script, Support IPV6
 #############################################################
-
 let port=$RANDOM/2+9999
 mtu=1420
 ip_list=(2 5 8 178 186 118 158 198 168 9)
 ipv6_range="fd08:620c:4df0:65eb::"
 
 
-# 安装 bash wgmtu 脚本用来设置服务器
+#  Get WireGuard Management Command : bash wgmtu
 wget -O ~/wgmtu  https://raw.githubusercontent.com/hongwenjun/vps_setup/english/wgmtu.sh
 
-# 定义文字颜色
+# 瀹氫箟鏂囧瓧棰滆壊
 Green="\033[32m"  && Red="\033[31m" && GreenBG="\033[42;37m" && RedBG="\033[41;37m"
 Font="\033[0m"  && Yellow="\033[0;33m" && SkyBlue="\033[0;36m"
 
@@ -51,7 +90,7 @@ if [[ $# > 0 ]]; then
 fi
 
 host=$(hostname -s)
-# 获得服务器ip,自动获取
+# 鑾峰緱鏈嶅姟鍣╥p锛岃嚜鍔ㄨ幏鍙�
 if [ ! -f '/usr/bin/curl' ]; then
     apt update && apt install -y curl
 fi
@@ -61,14 +100,9 @@ if [ ! -e '/var/ip_addr' ]; then
 fi
 serverip=$(cat /var/ip_addr)
 
-# 安装二维码插件
-if [ ! -f '/usr/bin/qrencode' ]; then
-    apt -y install qrencode
-fi
-
 #############################################################
 
-# 打开ip4/ipv6防火墙转发功能
+# 鎵撳紑ip4/ipv6闃茬伀澧欒浆鍙戝姛鑳�
 sysctl_config() {
     sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
     sed -i '/net.ipv6.conf.all.forwarding/d' /etc/sysctl.conf
@@ -82,16 +116,16 @@ sysctl_config() {
 }
 sysctl_config
 
-# wg配置文件目录 /etc/wireguard
+# wg閰嶇疆鏂囦欢鐩�綍 /etc/wireguard
 mkdir -p /etc/wireguard
 chmod 777 -R /etc/wireguard
 cd /etc/wireguard
 
-# 然后开始生成 密匙对(公匙+私匙)。
+# 鐒跺悗寮€濮嬬敓鎴� 瀵嗗寵瀵�(鍏�寵+绉佸寵)銆�
 wg genkey | tee sprivatekey | wg pubkey > spublickey
 wg genkey | tee cprivatekey | wg pubkey > cpublickey
 
-# 生成服务端配置文件
+# 鐢熸垚鏈嶅姟绔�厤缃�枃浠�
 cat <<EOF >wg0.conf
 [Interface]
 PrivateKey = $(cat sprivatekey)
@@ -108,7 +142,7 @@ AllowedIPs = 10.0.0.188/32,  ${ipv6_range}188
 
 EOF
 
-# 生成简洁的客户端配置
+# 鐢熸垚绠€娲佺殑瀹㈡埛绔�厤缃�
 cat <<EOF >client.conf
 [Interface]
 PrivateKey = $(cat cprivatekey)
@@ -126,7 +160,7 @@ PersistentKeepalive = 25
 
 EOF
 
-# 添加 2-9 号多用户配置
+# 娣诲姞 2-9 鍙峰�鐢ㄦ埛閰嶇疆
 for i in {2..9}
 do
     ip=10.0.0.${ip_list[$i]}
@@ -157,20 +191,24 @@ EOF
 done
 
 
-# 重启wg服务器
+# restart WG server
 wg-quick down wg0
 wg-quick up wg0
-
+wg
 
 next() {
     printf "# %-70s\n" "-" | sed 's/\s/-/g'
 }
 
-echo -e  "# Windows 客户端配置,请复制配置文本"
+echo
+echo_SkyBlue  ":: Windows Client configuration, Please copy the conf text."
 cat /etc/wireguard/client.conf       && next
 cat /etc/wireguard/wg_${host}_2.conf   && next
 cat /etc/wireguard/wg_${host}_3.conf   && next
 
-echo_GreenBG  "#  WireGuard Management Command."
+echo_RedBG   " One-Step Automated Install WireGuard Script For Debian_9 Ubuntu Centos_7 "
+echo_GreenBG "      Open Source Project: https://github.com/hongwenjun/vps_setup        "
+
+echo_Yellow  ":: WireGuard Management Command."
 echo_SkyBlue  "Usage: ${GreenBG} bash wgmtu ${SkyBlue} [ setup | remove | vps | bench | -U ] "
-echo_SkyBlue                      "                    [ v2ray | vnstat | log | trace | -h ] "
+echo_SkyBlue                      "                    [ v2ray | vnstat | log | trace | -h ] "