Bladeren bron

Rework if condition for version check and text.

Raphael Schneeberger 7 jaren geleden
bovenliggende
commit
97ad1e8b8c
1 gewijzigde bestanden met toevoegingen van 39 en 39 verwijderingen
  1. 39 39
      install/hst-install.sh

+ 39 - 39
install/hst-install.sh

@@ -11,8 +11,8 @@
 
 
 # Am I root?
 # Am I root?
 if [ "x$(id -u)" != 'x0' ]; then
 if [ "x$(id -u)" != 'x0' ]; then
-	echo 'Error: this script can only be executed by root'
-	exit 1
+    echo 'Error: this script can only be executed by root'
+    exit 1
 fi
 fi
 
 
 # Check admin user account
 # Check admin user account
@@ -43,61 +43,61 @@ case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
 esac
 esac
 
 
 no_support_message() {
 no_support_message() {
-	echo "Your OS is currently not supported."
-	exit 1;
+    echo "Your OS is currently not supported, please consider to use:"
+    echo "  Debian:  8, 9"
+    echo "  Ubuntu:  16.04, 18.04"
+    exit 1;
 }
 }
 
 
 # Check if OS is supported
 # Check if OS is supported
 if [ "$type" = "NoSupport" ]; then
 if [ "$type" = "NoSupport" ]; then
-	no_support_message
+    no_support_message
 fi
 fi
 
 
 check_wget_curl(){
 check_wget_curl(){
-	# Check wget
-	if [ -e '/usr/bin/wget' ]; then
-		wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh -O hst-install-$type.sh
-		if [ "$?" -eq '0' ]; then
-			bash hst-install-$type.sh $*
-			exit
-		else
-			echo "Error: hst-install-$type.sh download failed."
-			exit 1
-		fi
-	fi
+    # Check wget
+    if [ -e '/usr/bin/wget' ]; then
+        wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh -O hst-install-$type.sh
+        if [ "$?" -eq '0' ]; then
+            bash hst-install-$type.sh $*
+            exit
+        else
+            echo "Error: hst-install-$type.sh download failed."
+            exit 1
+        fi
+    fi
 
 
-	# Check curl
-	if [ -e '/usr/bin/curl' ]; then
-		curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh
-		if [ "$?" -eq '0' ]; then
-			bash hst-install-$type.sh $*
-			exit
-		else
-			echo "Error: hst-install-$type.sh download failed."
-			exit 1
-		fi
-	fi
+    # Check curl
+    if [ -e '/usr/bin/curl' ]; then
+        curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh
+        if [ "$?" -eq '0' ]; then
+            bash hst-install-$type.sh $*
+            exit
+        else
+            echo "Error: hst-install-$type.sh download failed."
+            exit 1
+        fi
+    fi
 }
 }
 
 
 
 
-# Detect codename
+# Detect codename for debian
 if [ "$type" = "debian" ]; then
 if [ "$type" = "debian" ]; then
-	codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))"
-	release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
-	VERSION='debian'
+    release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
+    VERSION='debian'
 fi
 fi
 
 
+# Detect codename for ubuntu
 if [ "$type" = "ubuntu" ]; then
 if [ "$type" = "ubuntu" ]; then
-	codename="$(lsb_release -s -c)"
-	release="$(lsb_release -s -r)"
-	VERSION='ubuntu'
+    release="$(lsb_release -s -r)"
+    VERSION='ubuntu'
 fi
 fi
 
 
 # Check Ubuntu Version Are Acceptable to install
 # Check Ubuntu Version Are Acceptable to install
-if [ "$codename" = "14.04" ] || [ "$codename" = "16.04" ] || [  "$codename" = "18.04" ]; then
-	check_wget_curl
+if [[ "$release" =~ ^(8|9|16.04|18.04)$ ]]; then
+    check_wget_curl
 else
 else
-	no_support_message
+    no_support_message
 fi
 fi
 
 
-
-exit
+exit