From 4360737eafab3e7319e631ef62f5857470b6cbe1 Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Mon, 13 Jan 2020 00:07:39 -0800 Subject: [PATCH] Improve OS detection --- extras/add_vpn_user.sh | 2 +- extras/del_vpn_user.sh | 2 +- extras/update_vpn_users.sh | 2 +- extras/vpnupgrade.sh | 6 ++++-- extras/vpnupgrade_centos.sh | 6 ++++-- vpnsetup.sh | 6 ++++-- vpnsetup_centos.sh | 6 ++++-- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/extras/add_vpn_user.sh b/extras/add_vpn_user.sh index a142b61..aadad2a 100644 --- a/extras/add_vpn_user.sh +++ b/extras/add_vpn_user.sh @@ -2,7 +2,7 @@ # # Script to add/update an VPN user for both IPsec/L2TP and Cisco IPsec # -# Copyright (C) 2018-2019 Lin Song +# Copyright (C) 2018-2020 Lin Song # # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 # Unported License: http://creativecommons.org/licenses/by-sa/3.0/ diff --git a/extras/del_vpn_user.sh b/extras/del_vpn_user.sh index 514b2d6..ee0249e 100644 --- a/extras/del_vpn_user.sh +++ b/extras/del_vpn_user.sh @@ -2,7 +2,7 @@ # # Script to delete an VPN user for both IPsec/L2TP and Cisco IPsec # -# Copyright (C) 2018-2019 Lin Song +# Copyright (C) 2018-2020 Lin Song # # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 # Unported License: http://creativecommons.org/licenses/by-sa/3.0/ diff --git a/extras/update_vpn_users.sh b/extras/update_vpn_users.sh index 0df05da..93ec63b 100644 --- a/extras/update_vpn_users.sh +++ b/extras/update_vpn_users.sh @@ -2,7 +2,7 @@ # # Script to update VPN users for both IPsec/L2TP and Cisco IPsec # -# Copyright (C) 2018-2019 Lin Song +# Copyright (C) 2018-2020 Lin Song # # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 # Unported License: http://creativecommons.org/licenses/by-sa/3.0/ diff --git a/extras/vpnupgrade.sh b/extras/vpnupgrade.sh index f7c408f..dcaae74 100644 --- a/extras/vpnupgrade.sh +++ b/extras/vpnupgrade.sh @@ -2,7 +2,7 @@ # # Script to upgrade Libreswan on Ubuntu and Debian # -# Copyright (C) 2016-2019 Lin Song +# Copyright (C) 2016-2020 Lin Song # # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 # Unported License: http://creativecommons.org/licenses/by-sa/3.0/ @@ -28,7 +28,9 @@ if [ -z "$os_type" ]; then [ -f /etc/lsb-release ] && os_type=$(. /etc/lsb-release && printf '%s' "$DISTRIB_ID") fi if ! printf '%s' "$os_type" | head -n 1 | grep -qiF -e ubuntu -e debian -e raspbian; then - exiterr "This script only supports Ubuntu and Debian." + echo "Error: This script only supports Ubuntu and Debian." >&2 + echo "For CentOS/RHEL, use https://git.io/vpnupgrade-centos" >&2 + exit 1 fi if [ "$(sed 's/\..*//' /etc/debian_version)" = "7" ]; then diff --git a/extras/vpnupgrade_centos.sh b/extras/vpnupgrade_centos.sh index 5f494e3..202a2e1 100644 --- a/extras/vpnupgrade_centos.sh +++ b/extras/vpnupgrade_centos.sh @@ -2,7 +2,7 @@ # # Script to upgrade Libreswan on CentOS and RHEL # -# Copyright (C) 2016-2019 Lin Song +# Copyright (C) 2016-2020 Lin Song # # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 # Unported License: http://creativecommons.org/licenses/by-sa/3.0/ @@ -23,7 +23,9 @@ exiterr2() { exiterr "'yum install' failed."; } vpnupgrade() { if ! grep -qs -e "release 6" -e "release 7" -e "release 8" /etc/redhat-release; then - exiterr "This script only supports CentOS/RHEL 6, 7 and 8." + echo "Error: This script only supports CentOS/RHEL 6, 7 and 8." >&2 + echo "For Ubuntu/Debian, use https://git.io/vpnupgrade" >&2 + exit 1 fi if [ -f /proc/user_beancounters ]; then diff --git a/vpnsetup.sh b/vpnsetup.sh index d6cf046..6c95f7d 100755 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -8,7 +8,7 @@ # The latest version of this script is available at: # https://github.com/hwdsl2/setup-ipsec-vpn # -# Copyright (C) 2014-2019 Lin Song +# Copyright (C) 2014-2020 Lin Song # Based on the work of Thomas Sarlandie (Copyright 2012) # # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 @@ -54,7 +54,9 @@ if [ -z "$os_type" ]; then [ -f /etc/lsb-release ] && os_type=$(. /etc/lsb-release && printf '%s' "$DISTRIB_ID") fi if ! printf '%s' "$os_type" | head -n 1 | grep -qiF -e ubuntu -e debian -e raspbian; then - exiterr "This script only supports Ubuntu and Debian." + echo "Error: This script only supports Ubuntu and Debian." >&2 + echo "For CentOS/RHEL, use https://git.io/vpnsetup-centos" >&2 + exit 1 fi if [ "$(sed 's/\..*//' /etc/debian_version)" = "7" ]; then diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index b0ab813..29904c2 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -8,7 +8,7 @@ # The latest version of this script is available at: # https://github.com/hwdsl2/setup-ipsec-vpn # -# Copyright (C) 2015-2019 Lin Song +# Copyright (C) 2015-2020 Lin Song # Based on the work of Thomas Sarlandie (Copyright 2012) # # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 @@ -49,7 +49,9 @@ check_ip() { vpnsetup() { if ! grep -qs -e "release 6" -e "release 7" -e "release 8" /etc/redhat-release; then - exiterr "This script only supports CentOS/RHEL 6, 7 and 8." + echo "Error: This script only supports CentOS/RHEL 6, 7 and 8." >&2 + echo "For Ubuntu/Debian, use https://git.io/vpnsetup" >&2 + exit 1 fi if [ -f /proc/user_beancounters ]; then