change debian the third party repository

This commit is contained in:
xiagw 2018-01-06 16:34:15 +08:00
parent 182c651c94
commit 3d95333ec5

View File

@ -28,7 +28,7 @@ file_client_tpl="${dir_openvpn}/client-template.txt"
file_openvpn_conf="${dir_openvpn}/server.conf" file_openvpn_conf="${dir_openvpn}/server.conf"
file_iptables='/etc/sysconfig/iptables.rules' file_iptables='/etc/sysconfig/iptables.rules'
## function: config the firewall
set_firewall(){ set_firewall(){
# Create the sysctl configuration file if needed (mainly for Arch Linux) # Create the sysctl configuration file if needed (mainly for Arch Linux)
@ -80,6 +80,7 @@ if hash sestatus 2>/dev/null; then
fi fi
} }
## function: generate the new client??.ovpn
generate_newclient() { generate_newclient() {
# Where to write the custom client.ovpn? # Where to write the custom client.ovpn?
@ -108,6 +109,7 @@ cat ${dir_openvpn}/tls-auth.key >> ${file_client}
echo "</tls-auth>" >> ${file_client} echo "</tls-auth>" >> ${file_client}
} }
## function: install easyrsa 3.0.3
install_easyrsa(){ install_easyrsa(){
# An old version of easy-rsa was available by default in some openvpn packages # An old version of easy-rsa was available by default in some openvpn packages
@ -170,8 +172,7 @@ WantedBy=multi-user.target" > ${file_ipt_svc}
fi fi
} }
## function: install openvpn server
## function for install openvpn server
install_openvpn(){ install_openvpn(){
clear clear
@ -311,33 +312,27 @@ read -n1 -r -p "Press any key to continue..."
if [[ "$OS" = 'debian' ]]; then if [[ "$OS" = 'debian' ]]; then
apt-get install ca-certificates -y apt-get install ca-certificates -y
# We add the OpenVPN repo to get the latest version. # We add the OpenVPN repo to get the latest version.
# Debian 7 case $VERSION_ID in
if [[ "$VERSION_ID" = 'VERSION_ID="7"' ]]; then '7') # Debian 7
echo "deb http://build.openvpn.net/debian/openvpn/stable wheezy main" > /etc/apt/sources.list.d/openvpn.list echo "deb http://build.openvpn.net/debian/openvpn/stable wheezy main" > /etc/apt/sources.list.d/openvpn.list
wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add - wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add -
apt-get update apt-get update
fi ;;
# Debian 8 '8') # Debian 8
if [[ "$VERSION_ID" = 'VERSION_ID="8"' ]]; then
os_vername=jessie
echo "deb http://build.openvpn.net/debian/openvpn/stable jessie main" > /etc/apt/sources.list.d/openvpn.list 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 - wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add -
apt update apt update
fi ;;
# Ubuntu 12.04 '12.04') # Ubuntu 12.04
if [[ "$VERSION_ID" = 'VERSION_ID="12.04"' ]]; then
os_vername=precise
echo "deb http://build.openvpn.net/debian/openvpn/stable precise main" > /etc/apt/sources.list.d/openvpn.list 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 - wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add -
apt-get update apt-get update
fi ;;
# Ubuntu 14.04 '14.04') # Ubuntu 14.04
if [[ "$VERSION_ID" = 'VERSION_ID="14.04"' ]]; then
os_vername=trusty
echo "deb http://build.openvpn.net/debian/openvpn/stable trusty main" > /etc/apt/sources.list.d/openvpn.list 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 - wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add -
apt-get update apt-get update
fi esac
# Ubuntu >= 16.04 and Debian > 8 have OpenVPN > 2.3.3 without the need of a third party repository. # 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 apt-get install openvpn iptables openssl wget ca-certificates curl -y
@ -348,10 +343,12 @@ elif [[ "$OS" = 'centos7' || "$OS" = 'fedora' ]]; then
fi fi
yum --enablerepo=epel install openvpn iptables openssl wget ca-certificates curl -y yum --enablerepo=epel install openvpn iptables openssl wget ca-certificates curl -y
# install_ipt_service ## call function # install_ipt_service ## call function
read -p "Please manually set the firewall,press anykey continue"
elif [[ "$OS" = 'centos6' ]]; then elif [[ "$OS" = 'centos6' ]]; then
yum install epel-release -y yum install epel-release -y
yum --enablerepo=epel install openvpn iptables openssl wget ca-certificates curl -y yum --enablerepo=epel install openvpn iptables openssl wget ca-certificates curl -y
# install_ipt_service ## call function # install_ipt_service ## call function
read -p "Please manually set the firewall,press anykey continue"
else else
# Else, the distro is ArchLinux # Else, the distro is ArchLinux
echo "" echo ""
@ -553,6 +550,7 @@ echo "Your client config is available at $homeDir/$CLIENT.ovpn"
echo "If you want to add more clients, you simply need to run this script again!" echo "If you want to add more clients, you simply need to run this script again!"
} }
## function: remove openvpn server and config dir
remove_openvpn(){ remove_openvpn(){
echo "" echo ""
@ -597,6 +595,7 @@ else
fi fi
} }
config_openvpn(){ config_openvpn(){
while : while :
@ -745,4 +744,3 @@ fi
} }
main $@ main $@
# exit 0;