Sfoglia il codice sorgente

improved preinstall validation

Serghey Rodin 12 anni fa
parent
commit
12a7181dc8
2 ha cambiato i file con 59 aggiunte e 16 eliminazioni
  1. 33 9
      install/vst-install-ubuntu.sh
  2. 26 7
      install/vst-install.sh

+ 33 - 9
install/vst-install-ubuntu.sh

@@ -10,15 +10,6 @@ export DEBIAN_FRONTEND=noninteractive
 RHOST='apt.vestacp.com'
 CHOST='c.vestacp.com'
 VERSION='0.9.8/ubuntu'
-if [ "$(arch)" != 'x86_64' ]; then
-    arch='i386'
-else
-    arch="amd64"
-fi
-os=$(head -n 1 /etc/issue | cut -f 1 -d ' ')
-release=$(head -n 1 /etc/issue | cut -f 2 -d ' ' )
-codename=$(lsb_release -cs)
-memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
 software="nginx apache2 apache2-utils apache2.2-common apache2-suexec-custom
     libapache2-mod-ruid2 libapache2-mod-rpaf libapache2-mod-fcgid bind9 idn
     mysql-server mysql-common mysql-client php5-common php5-cgi php5-mysql
@@ -90,11 +81,43 @@ if [ -e '/etc/redhat-release' ]; then
 fi
 
 # Check supported OS
+if [ "$(arch)" != 'x86_64' ]; then
+    arch='i386'
+else
+    arch="amd64"
+fi
+os=$(head -n 1 /etc/issue | cut -f 1 -d ' ')
+release=$(head -n 1 /etc/issue | cut -f 2 -d ' ' )
+if [ -e "/usr/bin/lsb_release" ]; then
+    codename=$(lsb_release -cs)
+else
+    codename='unknown'
+fi
 if [ $codename !=  'precise' ] && [ $codename != 'raring' ]; then
     echo 'Error: only Ubuntu LTS 12.04 and Ubuntu 13.04 is supported'
     exit 1
 fi
 
+# Check admin user account
+if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" != 'yes' ]; then
+    echo "Error: user admin exists"
+    echo
+    echo 'Please remove admin user account before proceeding.'
+    echo 'If you want to do it automatically run installer with -f option:'
+    echo "Example: bash $0 --force"
+    exit 1
+fi
+
+# Check admin user account
+if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" != 'yes' ]; then
+    echo "Error: user admin exists"
+    echo
+    echo 'Please remove admin user account before proceeding.'
+    echo 'If you want to do it automatically run installer with -f option:'
+    echo "Example: bash $0 --force"
+    exit 1
+fi
+
 # Check wget
 if [ ! -e '/usr/bin/wget' ]; then
     apt-get -y install wget
@@ -136,6 +159,7 @@ if [ ! -z "$conflicts" ] && [ -z "$force" ]; then
 fi
 
 # Check server type
+memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
 if [ "$memory" -lt '350000' ] && [ -z "$force" ]; then
     echo "Error: not enough memory to install Vesta Control Panel."
     echo -e "\nMinimum RAM required: 350Mb"

+ 26 - 7
install/vst-install.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Vesta installer v.03
+# Vesta RHEL/CentOS installer v.03
 
 #----------------------------------------------------------#
 #                  Variables&Functions                     #
@@ -11,11 +11,6 @@ CHOST='c.vestacp.com'
 REPO='cmmnt'
 VERSION='0.9.8/rhel'
 YUM_REPO='/etc/yum.repos.d/vesta.repo'
-arch=$(uname -i)
-os=$(cut -f 1 -d ' ' /etc/redhat-release)
-release=$(grep -o "[0-9]" /etc/redhat-release |head -n1)
-codename="${os}_$release"
-memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
 software="nginx httpd mod_ssl mod_ruid2 mod_extract_forwarded mod_fcgid
     php php-bcmath php-cli php-common php-gd php-imap php-mbstring php-mcrypt
     php-mysql php-pdo php-soap php-tidy php-xml php-xmlrpc php-pecl-apc
@@ -25,7 +20,6 @@ software="nginx httpd mod_ssl mod_ruid2 mod_extract_forwarded mod_fcgid
     ImageMagick sqlite pcre sudo bc jwhois mailx lsof tar telnet rsync
     rrdtool GeoIP freetype ntp openssh-clients vesta vesta-nginx vesta-php"
 
-
 help() {
     echo "usage: $0 [OPTIONS]
    -d, --disable-remi         Disable remi
@@ -92,10 +86,34 @@ if [ ! -e '/etc/redhat-release' ]; then
 fi
 
 # Check supported OS
+arch=$(uname -i)
+os=$(cut -f 1 -d ' ' /etc/redhat-release)
+release=$(grep -o "[0-9]" /etc/redhat-release |head -n1)
+codename="${os}_$release"
 if [ $os !=  'CentOS' ] && [ $os != 'Red' ]; then
     echo 'Error: sorry, we currently support RHEL and CentOS only'
 fi
 
+# Check admin user account
+if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" != 'yes' ]; then
+    echo "Error: user admin exists"
+    echo
+    echo 'Please remove admin user account before proceeding.'
+    echo 'If you want to do it automatically run installer with -f option:'
+    echo "Example: bash $0 --force"
+    exit 1
+fi
+
+# Check admin user account
+if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" != 'yes' ]; then
+    echo "Error: user admin exists"
+    echo
+    echo 'Please remove admin user account before proceeding.'
+    echo 'If you want to do it automatically run installer with -f option:'
+    echo "Example: bash $0 --force"
+    exit 1
+fi
+
 # Check wget
 if [ ! -e '/usr/bin/wget' ]; then
     yum -y install wget
@@ -137,6 +155,7 @@ if [ ! -z "$conflicts" ] && [ -z "$force" ]; then
 fi
 
 # Check server type
+memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
 if [ "$memory" -lt '350000' ] && [ -z "$force" ]; then
     echo "Error: not enough memory to install Vesta Control Panel."
     echo -e "\nMinimum RAM required: 350Mb"