Просмотр исходного кода

Check for Ubuntu LTS releases before installing

If the system is running on a non-LTS release, abort the installation process as it is an unsupported configuration.
Luiz Júnior 7 лет назад
Родитель
Сommit
6509d7b76c
1 измененных файлов с 52 добавлено и 24 удалено
  1. 52 24
      install/hst-install.sh

+ 52 - 24
install/hst-install.sh

@@ -11,8 +11,8 @@
 
 # Am I root?
 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
 
 # Check admin user account
@@ -42,34 +42,62 @@ case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
     *)          type="NoSupport" ;;
 esac
 
+no_support_message() {
+	echo "Your OS is currently not supported."
+	exit 1;
+}
+
 # Check if OS is supported
 if [ "$type" = "NoSupport" ]; then
-    echo "Your OS is currently not supported."
-    exit 1;
+	no_support_message
+fi
+
+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 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
+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'
 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
+if [ "$type" = "ubuntu" ]; then
+	codename="$(lsb_release -s -c)"
+	release="$(lsb_release -s -r)"
+	VERSION='ubuntu'
 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
+# Check Ubuntu Version Are Acceptable to install
+if [ "$codename" = "14.04" ] || [ "$codename" = "16.04" ] || [  "$codename" = "18.04" ]; then
+	check_wget_curl
+else
+	no_support_message
 fi
 
+
 exit