From 9cd45d257e8adf31242742f8b2af323cbba6f620 Mon Sep 17 00:00:00 2001 From: xiagw Date: Thu, 4 Jan 2018 20:51:46 +0800 Subject: [PATCH] my comment --xia. add step number change debian apt-get update --- openvpn-install.sh | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index ffc2ea8..0e26ba8 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -232,6 +232,7 @@ EOF read -p "Do you really want to remove OpenVPN? [y/n]: " -e -i n REMOVE if [[ 'y' = "$REMOVE" ]]; then PORT=$(grep '^port ' ${file_openvpn_conf} | cut -d " " -f 2) + PROTOCOL=$(grep '^proto ' ${file_openvpn_conf} | cut -d " " -f 2) if pgrep firewalld; then # Using both permanent and not permanent rules to avoid a firewalld reload. firewall-cmd --zone=public --remove-port=$PORT/${PROTOCOL} @@ -249,7 +250,7 @@ EOF if hash sestatus 2>/dev/null; then if sestatus | grep "Current mode" | grep -qs "enforcing"; then if [[ "$PORT" != '1194' ]]; then - semanage port -d -t openvpn_port_t -p udp $PORT + semanage port -d -t openvpn_port_t -p ${PROTOCOL} $PORT fi fi fi @@ -260,8 +261,7 @@ EOF else yum remove openvpn -y fi - rm -rf ${dir_openvpn} - rm -rf /usr/share/doc/openvpn* + rm -rf ${dir_openvpn} /usr/share/doc/openvpn* echo "" echo "OpenVPN removed!" else @@ -275,6 +275,8 @@ EOF done fi + + ## OpenVPN setup and first user creation if [[ ! -e ${file_openvpn_conf} ]]; then clear @@ -293,13 +295,13 @@ EOF echo "What port do you want for OpenVPN?" read -p "Port: " -e -i 1194 PORT echo "" - echo "What protocol do you want for OpenVPN?" + echo "1/6.What protocol do you want for OpenVPN?" echo "Unless UDP is blocked, you should not use TCP (unnecessarily slower)" while [[ $PROTOCOL != "udp" && $PROTOCOL != "tcp" ]]; do read -p "Protocol [udp/tcp]: " -e -i udp PROTOCOL done cat < /etc/apt/sources.list.d/openvpn.list - wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add - - apt-get update + os_vername=wheezy + bin_apt=apt-get fi # Debian 8 if [[ "$VERSION_ID" = 'VERSION_ID="8"' ]]; then - echo "deb http://build.openvpn.net/debian/openvpn/stable jessie main" > /etc/apt/sources.list.d/openvpn.list - wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add - - apt update + os_vername=jessie + bin_apt=apt fi # Ubuntu 12.04 if [[ "$VERSION_ID" = 'VERSION_ID="12.04"' ]]; then - echo "deb http://build.openvpn.net/debian/openvpn/stable precise main" > /etc/apt/sources.list.d/openvpn.list - wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add - - apt-get update + os_vername=precise + bin_apt=apt-get fi # Ubuntu 14.04 if [[ "$VERSION_ID" = 'VERSION_ID="14.04"' ]]; then - echo "deb http://build.openvpn.net/debian/openvpn/stable trusty main" > /etc/apt/sources.list.d/openvpn.list - wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add - - apt-get update + os_vername=trusty + bin_apt=apt-get fi + echo "deb http://build.openvpn.net/debian/openvpn/stable ${os_vername} main" > /etc/apt/sources.list.d/openvpn.list + wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add - + ${bin_apt} update # Ubuntu >= 16.04 and Debian > 8 have OpenVPN > 2.3.3 without the need of a third party repository. - # The we install OpenVPN + + ## The we install OpenVPN apt-get install openvpn iptables openssl wget ca-certificates curl -y # Install iptables service if [[ ! -e /etc/systemd/system/iptables.service ]]; then