Explorar el Código

* OSInfo(): ahora también comprueba las distribuciones compatibles
* Cambios para adaptarse a los cambios

Guzmán Castanedo Villalba hace 5 años
padre
commit
5346e0bf28
Se han modificado 1 ficheros con 92 adiciones y 51 borrados
  1. 92 51
      install

+ 92 - 51
install

@@ -128,22 +128,22 @@ comprobarError() {
 			error="\n$type $codeNum:\tSQL ya está configurado."
 			;;
 		300)
-			error="\n$type $codeNum:\tError interno (instalación PHP-7.2).\n"
+			error="\n$type $codeNum:\tError interno (instalación PHP-7).\n"
 			;;
 		301)
 			error="\n$type $codeNum:\tError interno (Web Server no seleccionado).\n"
 			;;
 		302)
-			error="\n$type $codeNum:\tError al instalar PHP-7.2.\nDetalles:\n$extraInfo\n"
+			error="\n$type $codeNum:\tError al instalar PHP-7.\nDetalles:\n$extraInfo\n"
 			;;
 		303)
 			error="\n$type $codeNum:\tError al instalar Repositorio Remi.\nDetalles:\n$extraInfo\n"
 			;;
 		304)
-			error="\n$type $codeNum:\tSistema Operativo no compatible con PHP-7.2 ($OS $DIST $REV).\n"
+			error="\n$type $codeNum:\tSistema Operativo no compatible con PHP-7 ($OS $DIST $REV).\n"
 			;;
 		305)
-			error="\n$type $codeNum:\tImposible configurar PHP-7.2.\n"
+			error="\n$type $codeNum:\tImposible configurar PHP-7.\n"
 			;;
 		401)
 			error="\n$type $codeNum:\tError al instalar 'certbot' (Let's Encrypt).\n"
@@ -238,6 +238,9 @@ comprobarError() {
 		816)
 			error="$type $codeNum:\t'find' no instalado.\n"
 			;;
+		817)
+			error="$type $codeNum:\tLa Distribución '$OS $DIST $REV' no está soportada.\nSoportadas: Ubuntu 16.04, 18.04, Debian 9 y CentOS 7.\n"
+			;;
 		900)
 			error="$type $codeNum:\tError interno (habilitar servicio).\n"
 			;;
@@ -299,6 +302,7 @@ comprobarError() {
 
 OSInfo() {
 # Detecta el OS en el que se está ejecutando el programa, así como su versión
+# Sólo continuará si se trata de una distribución compatible
 	echo -en "Detectando SO..." >> $logFile
 	OS=$(uname -s)
 	if [ $OS = "Linux" ]; then
@@ -309,49 +313,95 @@ OSInfo() {
 			ID=$(grep ^ID= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
 			ID_LIKE=$(grep ^ID_LIKE= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
 			VERSION=$(grep ^VERSION_ID= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
-			for i in $ID_LIKE; do
+			for i in $ID; do
 				case $i in
-					debian|ubuntu)
+					debian)
 						debianOS=true
+						case $VERSION in
+							9)
+								apacheName="apache2"
+								nginxName="nginx"
+								mysqlName="mysql"
+								mariadbName="mariadb"
+								phpFPMName="php7.0-fpm"
+								;;
+							*)
+								comprobarError 1 817
+								;;
+						esac
+						break
+						;;
+					ubuntu)
+						debianOS=true
+						case $VERSION in
+							18.04)
+								apacheName="apache2"
+								nginxName="nginx"
+								mysqlName="mysql"
+								mariadbName="mariadb"
+								phpFPMName="php7.2-fpm"
+								;;
+							16.04)
+								apacheName="apache2"
+								nginxName="nginx"
+								mysqlName="mysql"
+								mariadbName="mysql"
+								phpFPMName="php7.0-fpm"
+								;;
+							*)
+								comprobarError 1 817
+								;;
+						esac
+						break
+						;;
+					rhel|centos)
+						rhelOS=true
+						case $VERSION in
+							7)
+								apacheName="httpd"
+								nginxName="nginx"
+								mysqlName=""
+								mariadbName="mariadb"
+								phpFPMName="php-fpm"
+								remiRepo="http://remi.mirrors.cu.be/enterprise/remi-release-7.rpm"
+								;;
+							*)
+								comprobarError 1 817
+								;;
+						esac
 						break
 						;;
-					rhel|fedora)
+					fedora)
 						rhelOS=true
+						case $VERSION in
+							28)
+								apacheName="httpd"
+								nginxName="nginx"
+								mysqlName=""
+								mariadbName="mariadb"
+								phpFPMName="php-fpm"
+								remiRepo="http://remi.mirrors.cu.be/fedora/remi-release-28.rpm"
+								;;
+							*)
+								comprobarError 1 817
+								;;
+						esac
 						break
 						;;
 					*)
 						debianOS=false
 						rhelOS=false
+						comprobarError 1 817
 						;;
 				esac
 			done
-		elif [ -f /etc/debian-version ]; then
-			# Familia Debian (Debian, Ubuntu, Linux Mint, ...)
-			DIST="Debian"
-			REV=""
-			ID_LIKE="debian"
-			VERSION=""
-			debianOS=true
-		elif [ -f /etc/redhat-release ]; then
-			# Familia Red-Hat (RHEL, Fedora, CentOS, ...)
-			DIST="Red-Hat"
-			REV=""
-			ID_LIKE="rhel"
-			VERSION=""
-			rhelOS=true
 		else
 			# Other Linux (No Soportado)
-			DIST=""
-			REV=""
-			ID_LIKE=""
-			VERSION=""
+			comprobarError 1 817
 		fi
 	else
 		# UNIX, OS X, ... (No Soportado)
-		DIST=$OS
-		REV=""
-		ID_LIKE=""
-		VERSION=""
+		comprobarError 1 817
 	fi
 	echo -en " $OS $DIST $REV\n" >> $logFile
 	HDInfo=$(df -h | head -1)"\n"$(df -h | grep ^/dev/sd)"\n"$(df -h | grep ^/dev/mapper)
@@ -508,6 +558,11 @@ inicializarVariables() {
 	hostname=""
 	logFile="./."$(basename $0)".log"
 	maxUpload="100M"
+	apacheName=""
+	nginxName=""
+	mysqlName=""
+	mariadbName=""
+	remiRepo=""
 	webServerName=""
 	webServerUser=""
 	webServerGroup=""
@@ -544,10 +599,6 @@ mostrarBienvenida() {
 # Pantalla de bienvenida y muestra SO y estado de los discos
 	ANCHO=$(tput cols)
 	ALTO=$(tput lines)
-	if [ $debianOS = false ] && [ $rhelOS = false ]; then
-		whiptail --title "ERROR S.O. NO SOPORTADO" --msgbox "Este script automatiza la creación de una web MediaWiki SOLO para distribuciones Linux de la familia Debian (Ubuntu, Linux Mint, ...) y de la familia Red-Hat (CentOS, Fedora, ...).\n\nInformación del sistema:\nOS: $OS $DIST $REV\n$HDInfo" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --ok-button "Salir"
-		exit 1
-	fi
 	whiptail --title "INSTALACION MEDIAWIKI" --yesno "Este script automatiza completamente la instalación de una WIKI y un CAMPUS VIRTUAL.\nPara ello instala un servidor LAMP, el software MediaWiki y configura todo lo necesario.\n\nInformación del sistema:\nOS: $OS $DIST $REV\n$HDInfo" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --yes-button "Continuar" --no-button "Salir"
 	comprobarError $? 1
 }
@@ -765,7 +816,7 @@ mostrarMoodle() {
 
 mostrarConfirmacion() {
 # Pantalla que presenta una confirmación antes de realizar la instalación
-	whiptail --title "INSTALACION" --yesno "ESTA TODO LISTO PARA LA INSTALACION.\n¿DESEA CONTINUAR?" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --yes-button "Instalar" --no-button "Salir"
+	whiptail --title "INSTALACION" --yesno "ESTA TODO LISTO PARA LA INSTALACION.\nNO SE OLVIDE DE GUARDAR LAS CONFIGURACIONES EN UN LUGAR SEGURO, YA QUE SERÁN IMPORTANTES POR SI DESEA HACER ALGÚN CAMBIO EN EL FUTURO.\n¿DESEA CONTINUAR?" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --yes-button "Instalar" --no-button "Salir"
 	comprobarError $? 1
 }
 
@@ -784,12 +835,11 @@ establecerFQDN() {
 
 instalarApache() {
 # Instala Apache2
+	webServerName=$apacheName
 	if [ $debianOS = true ];then
-		webServerName="apache2"
 		result=$(apt-get -q -y install apache2 2>&1)
 		comprobarError $? 101 $result
 	elif [ $rhelOS = true ]; then
-		webServerName="httpd"
 		result=$(yum -y install httpd 2>&1)
 		comprobarError $? 101 $result
 		if [ $sslOn = true ];then
@@ -872,7 +922,7 @@ configurarApache() {
 
 instalarNginx() {
 # Instala Nginx
-	webServerName="nginx"
+	webServerName=$nginxName
 	if [ $debianOS = true ];then
 		result=$(apt-get -q -y install nginx 2>&1)
 		comprobarError $? 102 $result
@@ -1087,7 +1137,7 @@ establecerSQLPasswd() {
 
 instalarMySQL() {
 # Instala MySQL (sólo para Debian)
-	sqlServerName="mysql"
+	sqlServerName=$mysqlName
 	if [ $debianOS = true ];then
 		result=$(apt-get -q -y install mysql-server mysql-client 2>&1)
 		comprobarError $? 201 $result
@@ -1104,7 +1154,7 @@ instalarMySQL() {
 
 instalarMariaDB() {
 # Instala MariaDB
-	sqlServerName="mariadb"
+	sqlServerName=$mariadbName
 	if [ $debianOS = true ];then
 		result=$(apt-get -q -y install mariadb-server mariadb-client 2>&1)
 		comprobarError $? 202 $result
@@ -1160,7 +1210,6 @@ instalarPHP() {
 			result=$(apt-get -q -y install php libapache2-mod-php php-mysql php-intl php-mbstring php-xml php-apcu php-gd php-curl php-zip php-soap php-xmlrpc 2>&1)
 			comprobarError $? 302 $result
 		elif [ $nginxOn = true ];then
-			phpFPMName="php7.2-fpm"
 			result=$(apt-get -q -y install php-fpm php-mysql php-intl php-mbstring php-xml php-apcu php-gd php-curl php-zip php-soap php-xmlrpc 2>&1)
 			comprobarError $? 302 $result
 			deshabilitarServicio $phpFPMName
@@ -1173,15 +1222,8 @@ instalarPHP() {
 		comprobarError $? 103 $result
 		# Necesitamos un repositorio adicional para PHP-7 (REMI-RELEASE)
 		if [ ! -f /etc/yum.repos.d/remi-php72.repo ];then
-			if [ $VERSION = "7" ];then
-				result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-7.rpm 2>&1)
-				comprobarError $? 303 $result
-			elif [ $VERSION = "28" ];then
-				result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-28.rpm 2>&1)
-				comprobarError $? 303 $result
-			else
-				comprobarError 1 304
-			fi
+			result=$(yum -y install "$remiRepo" 2>&1)
+			comprobarError $? 303 $result
 		fi
 		# Activamos repositorio remi-php72
 		result=$(yum-config-manager --enable remi-php72 2>&1)
@@ -1191,7 +1233,6 @@ instalarPHP() {
 			result=$(yum -y install php php-mysql php-intl php-mbstring php-mcrypt php-xml php-pecl-apcu php-gd php-pear-Net-Curl php-pecl-zip php-soap php-xmlrpc 2>&1)
 			comprobarError $? 302 $result
 		elif [ $nginxOn = true ];then
-			phpFPMName="php-fpm"
 			result=$(yum -y install php php-fpm php-mysql php-intl php-mbstring php-mcrypt php-xml php-pecl-apcu php-gd php-pear-Net-Curl php-pecl-zip php-soap php-xmlrpc 2>&1)
 			comprobarError $? 302 $result
 			deshabilitarServicio $phpFPMName
@@ -1845,7 +1886,7 @@ configurarBackups() {
 		echo -en " OK.\n" | tee -a $logFile
 	fi
 
-# Instalación PHP-7.2
+# Instalación PHP-7
 	if [ $phpOn = true ]; then
 		echo -en "Instalando PHP-7..." | tee -a $logFile
 		instalarPHP