1
0
mirror of synced 2025-02-16 12:03:15 +03:00

Improve OS detection

This commit is contained in:
hwdsl2 2021-04-20 00:09:00 -05:00
parent 28b02f28db
commit d90c6121b6
3 changed files with 22 additions and 12 deletions

View File

@ -37,15 +37,19 @@ check_run_as_root() {
check_os_type() {
os_arch=$(uname -m | tr -dc 'A-Za-z0-9_-')
if grep -qs -e "release 7" -e "release 8" /etc/redhat-release; then
rh_file="/etc/redhat-release"
if grep -qs -e "release 7" -e "release 8" "$rh_file"; then
os_type=centos
if grep -qs "Red Hat" /etc/redhat-release; then
if grep -qs "Red Hat" "$rh_file"; then
os_type=rhel
fi
if grep -qs "release 7" /etc/redhat-release; then
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" /etc/redhat-release; then
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
if grep -qi stream "$rh_file"; then
os_ver=8s
fi
fi
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
os_type=amzn

View File

@ -28,14 +28,17 @@ vpnupgrade() {
os_type=centos
os_arch=$(uname -m | tr -dc 'A-Za-z0-9_-')
if grep -qs "Red Hat" /etc/redhat-release; then
rh_file="/etc/redhat-release"
if grep -qs "Red Hat" "$rh_file"; then
os_type=rhel
fi
if grep -qs "release 7" /etc/redhat-release; then
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" /etc/redhat-release; then
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
if grep -qi stream "$rh_file"; then
os_ver=8s
fi
else
echo "Error: This script only supports CentOS/RHEL 7 and 8." >&2
echo "For Ubuntu/Debian, use https://git.io/vpnupgrade" >&2

View File

@ -51,14 +51,17 @@ vpnsetup() {
os_type=centos
os_arch=$(uname -m | tr -dc 'A-Za-z0-9_-')
if grep -qs "Red Hat" /etc/redhat-release; then
rh_file="/etc/redhat-release"
if grep -qs "Red Hat" "$rh_file"; then
os_type=rhel
fi
if grep -qs "release 7" /etc/redhat-release; then
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" /etc/redhat-release; then
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
if grep -qi stream "$rh_file"; then
os_ver=8s
fi
else
echo "Error: This script only supports CentOS/RHEL 7 and 8." >&2
echo "For Ubuntu/Debian, use https://git.io/vpnsetup" >&2