1
0
mirror of synced 2024-11-28 23:56:04 +03:00

Minor clean up

This commit is contained in:
hwdsl2 2016-10-31 01:13:20 -05:00
parent 75bcdfae75
commit 6e16712bc5
3 changed files with 18 additions and 30 deletions

View File

@ -20,10 +20,6 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
exiterr() { echo "Error: ${1}" >&2; exit 1; } exiterr() { echo "Error: ${1}" >&2; exit 1; }
exiterr2() { echo "Error: 'yum install' failed." >&2; exit 1; } exiterr2() { echo "Error: 'yum install' failed." >&2; exit 1; }
if [ ! -f /etc/redhat-release ]; then
exiterr "This script only supports CentOS/RHEL."
fi
if ! grep -qs -e "release 6" -e "release 7" /etc/redhat-release; then if ! grep -qs -e "release 6" -e "release 7" /etc/redhat-release; then
exiterr "This script only supports CentOS/RHEL 6 and 7." exiterr "This script only supports CentOS/RHEL 6 and 7."
fi fi

View File

@ -50,7 +50,9 @@ if [ "$os_type" != "Ubuntu" ] && [ "$os_type" != "Debian" ] && [ "$os_type" != "
fi fi
if [ -f /proc/user_beancounters ]; then if [ -f /proc/user_beancounters ]; then
exiterr "This script does not support OpenVZ VPS." echo "Error: This script does not support OpenVZ VPS." >&2
echo "Try OpenVPN: https://github.com/Nyr/openvpn-install" >&2
exit 1
fi fi
if [ "$(id -u)" != 0 ]; then if [ "$(id -u)" != 0 ]; then
@ -68,12 +70,9 @@ cat 1>&2 <<'EOF'
DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC! DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC!
If running on a server, you may fix this error by first If running on a server, you may fix this error by first
finding the active network interface: setting this variable and re-run the script:
route | grep '^default' | grep -o '[^ ]*$'
Then set this variable and re-run the script:
export VPN_IFACE="YOUR_INTERFACE"
export VPN_IFACE="$(route | grep '^default' | grep -o '[^ ]*$')"
EOF EOF
exit 1 exit 1
fi fi
@ -161,8 +160,6 @@ apt-get -yq install ppp xl2tpd || exiterr2
# Install Fail2Ban to protect SSH server # Install Fail2Ban to protect SSH server
apt-get -yq install fail2ban || exiterr2 apt-get -yq install fail2ban || exiterr2
update-rc.d fail2ban enable
systemctl enable fail2ban 2>/dev/null
# Compile and install Libreswan # Compile and install Libreswan
swan_ver=3.18 swan_ver=3.18
@ -377,7 +374,7 @@ if [ "$ipt_flag" = "1" ]; then
fi fi
fi fi
# Load IPTables rules at system boot # Load IPTables rules at boot
mkdir -p /etc/network/if-pre-up.d mkdir -p /etc/network/if-pre-up.d
cat > /etc/network/if-pre-up.d/iptablesload <<'EOF' cat > /etc/network/if-pre-up.d/iptablesload <<'EOF'
#!/bin/sh #!/bin/sh
@ -386,22 +383,22 @@ exit 0
EOF EOF
# Start services at boot # Start services at boot
update-rc.d fail2ban enable >/dev/null 2>&1
systemctl enable fail2ban >/dev/null 2>&1
if ! grep -qs "hwdsl2 VPN script" /etc/rc.local; then if ! grep -qs "hwdsl2 VPN script" /etc/rc.local; then
conf_bk "/etc/rc.local" conf_bk "/etc/rc.local"
sed --follow-symlinks -i -e '/^exit 0/d' /etc/rc.local sed --follow-symlinks -i '/^exit 0/d' /etc/rc.local
cat >> /etc/rc.local <<'EOF' cat >> /etc/rc.local <<'EOF'
# Added by hwdsl2 VPN script # Added by hwdsl2 VPN script
EOF
if grep -qs raspbian /etc/os-release; then
echo "sleep 30" >> /etc/rc.local
fi
cat >> /etc/rc.local <<'EOF'
service ipsec start service ipsec start
service xl2tpd start service xl2tpd start
echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_forward
exit 0 exit 0
EOF EOF
if grep -qs raspbian /etc/os-release; then
sed --follow-symlinks -i '/hwdsl2 VPN script/a sleep 15' /etc/rc.local
fi
fi fi
# Reload sysctl.conf # Reload sysctl.conf

View File

@ -44,16 +44,14 @@ check_ip() {
printf %s "${1}" | tr -d '\n' | grep -Eq "$IP_REGEX" printf %s "${1}" | tr -d '\n' | grep -Eq "$IP_REGEX"
} }
if [ ! -f /etc/redhat-release ]; then
exiterr "This script only supports CentOS/RHEL."
fi
if ! grep -qs -e "release 6" -e "release 7" /etc/redhat-release; then if ! grep -qs -e "release 6" -e "release 7" /etc/redhat-release; then
exiterr "This script only supports CentOS/RHEL 6 and 7." exiterr "This script only supports CentOS/RHEL 6 and 7."
fi fi
if [ -f /proc/user_beancounters ]; then if [ -f /proc/user_beancounters ]; then
exiterr "This script does not support OpenVZ VPS." echo "Error: This script does not support OpenVZ VPS." >&2
echo "Try OpenVPN: https://github.com/Nyr/openvpn-install" >&2
exit 1
fi fi
if [ "$(id -u)" != 0 ]; then if [ "$(id -u)" != 0 ]; then
@ -71,12 +69,9 @@ cat 1>&2 <<'EOF'
DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC! DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC!
If running on a server, you may fix this error by first If running on a server, you may fix this error by first
finding the active network interface: setting this variable and re-run the script:
route | grep '^default' | grep -o '[^ ]*$'
Then set this variable and re-run the script:
export VPN_IFACE="YOUR_INTERFACE"
export VPN_IFACE="$(route | grep '^default' | grep -o '[^ ]*$')"
EOF EOF
exit 1 exit 1
fi fi
@ -380,7 +375,7 @@ if grep -qs "release 6" /etc/redhat-release; then
else else
systemctl --now mask firewalld systemctl --now mask firewalld
yum -y install iptables-services || exiterr2 yum -y install iptables-services || exiterr2
systemctl enable iptables fail2ban systemctl enable iptables fail2ban >/dev/null 2>&1
fi fi
if ! grep -qs "hwdsl2 VPN script" /etc/rc.local; then if ! grep -qs "hwdsl2 VPN script" /etc/rc.local; then
conf_bk "/etc/rc.local" conf_bk "/etc/rc.local"