| 
					
				 | 
			
			
				@@ -1,11 +1,11 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #!/bin/bash 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ################################################################# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-# auto-mediawiki												# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# auto-mediawiki						# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Instala un servidor LAMP (Linux+Apache+MySQL+PHP) e instala	# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-# MediaWiki y lo configura.										# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-#																# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# MediaWiki y lo configura.					# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#								# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Guzman Castanedo Villalba (guzman@castanedo.es) Junio 2018	# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-# GPLv3 (https://www.gnu.org/licenses/gpl.html)					# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# GPLv3 (https://www.gnu.org/licenses/gpl.html)			# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ################################################################# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 OSInfo() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -59,7 +59,7 @@ OSInfo() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		DIST=$OS 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		REV="" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	#printf " $DIST $REV\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	#printf " $OS $DIST $REV\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	HDInfo=$(df -h | head -1)"\n"$(df -h | grep ^/dev/sd)"\n"$(df -h | grep ^/dev/mapper) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -133,7 +133,7 @@ comprobarDependencias() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 comprobarHostname() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	while [ -z $hostname ]; do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		hostname=$(whiptail --title "Hostname" --inputbox "El nombre de dominio de este servidor es:\n"$(hostname)"\n\nQuieres cambiarlo por otro?" --ok-button "Cambiar" --cancel-button "No Cambiar" 20 70 3>&1 1>&2 2>&3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		hostname=$(whiptail --title "HOSTNAME" --inputbox "El nombre de dominio de este servidor es:\n"$(hostname)"\n\nQuieres cambiarlo por otro?" --ok-button "Cambiar" --cancel-button "No Cambiar" 20 70 3>&1 1>&2 2>&3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if [ $? -eq 0 ] && [ ! -z $hostname ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			hostnamectl set-hostname $hostname 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		else 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -145,10 +145,10 @@ comprobarHostname() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 mostrarBienvenida() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if [ $debianOS = false ] && [ $rhelOS = false ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		whiptail --title "ERROR OS 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" --ok-button "Salir" 20 70 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		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" --ok-button "Salir" 20 70 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	whiptail --title "Instalación MediaWiki" --yesno "Este script automatiza completamente la instalación de una wiki.\nPara ello instala un servidor LAMP, el software MediaWiki y lo configura todo.\n\nInformación del sistema:\nOS: $OS $DIST $REV\n$HDInfo" --yes-button "Continuar" --no-button "Salir" 20 70 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	whiptail --title "INSTALACION MEDIAWIKI" --yesno "Este script automatiza completamente la instalación de una wiki.\nPara ello instala un servidor LAMP, el software MediaWiki y lo configura todo.\n\nInformación del sistema:\nOS: $OS $DIST $REV\n$HDInfo" --yes-button "Continuar" --no-button "Salir" 20 70 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		printf "ERROR:\tInstalación interrumpida por el usuario.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		exit 2 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -156,13 +156,14 @@ mostrarBienvenida() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 mostrarComponentes() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	componentes=$(whiptail --title "Instalación" --checklist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge los componentes que quieres instalar:" 20 70 6 \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	componentes=$(whiptail --title "INSTALACION" --checklist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge los componentes que quieres instalar:" 20 70 7 \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"WebServer" "Instalar servidor web http/https" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"Database" "Instalar una base de datos SQL" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"PHP" "Instala PHP7" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"SSL/TLS" "Instalar certificados para activar HTTPS" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"MediaWiki" "Instalar wiki con MediaWiki" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"Moodle" "Instalar campus virtual con Moodle" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"Actualizaciones" "Programar actualizaciones automáticas" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	--ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		printf "ERROR:\tInstalación interrumpida por el usuario.\n" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -197,6 +198,10 @@ mostrarComponentes() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				printf "Instalando Moodle..." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				printf " OK.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			\"Actualizaciones\") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				printf "Configurando actualizaciones..." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				printf " OK.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			*) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				printf "ERROR:\tError interno (selección de componentes).\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				exit 1 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -206,7 +211,7 @@ mostrarComponentes() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 instalarWebServer() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	webServer=$(whiptail --title "Servidor Web" --radiolist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge el servidor web que quieres usar:" 20 70 2 \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	webServer=$(whiptail --title "SERVIDOR WEB" --radiolist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge el servidor web que quieres usar:" 20 70 2 \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"Apache" "Instalar el servidor web Apache2" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"Nginx" "Instalar el servidor web Nginx" OFF \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	--ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -236,19 +241,19 @@ instalarApache() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if [ $debianOS = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		result=$(apt-get -q -y install apache2 2>&1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			printf "\nERROR:\tError al instalar apache2.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "\nERROR:\tError al instalar Apache2.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			printf "Detalles:\n$result\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	elif [ $rhelOS = true ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		result=$(yum -y install httpd 2>&1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			printf "\nERROR:\tError al instalar apache2.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "\nERROR:\tError al instalar Apache2.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			printf "Detalles:\n$result\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		printf "\nERROR:\tError interno (instalación apache).\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		printf "\nERROR:\tError interno (instalación Apache2).\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -257,27 +262,33 @@ instalarNginx() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if [ $debianOS = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		result=$(apt-get -q -y install nginx 2>&1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			printf "\nERROR:\tError al instalar apache2.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "\nERROR:\tError al instalar Nginx.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			printf "Detalles:\n$result\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	elif [ $rhelOS = true ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		# Hay que instalar primero otro repositorio 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		result=$(yum -y install epel-release) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "\nERROR:\tError al intalar repositorio 'epel-release'.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "Detalles:\n$result\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		result=$(yum -y install nginx 2>&1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			printf "\nERROR:\tError al instalar apache2.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "\nERROR:\tError al instalar Nginx.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			printf "Detalles:\n$result\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		printf "\nERROR:\tError interno (instalación apache).\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		printf "\nERROR:\tError interno (instalación Nginx).\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 instalarDatabase() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if [ $debianOS = true ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		database=$(whiptail --title "Base de Datos" --radiolist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge la base de datos que quieres usar:" 20 70 2 \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		database=$(whiptail --title "BASE DE DATOS" --radiolist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge la base de datos que quieres usar:" 20 70 2 \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		"MySQL" "Instalar la base de datos MySQL (no uso comercial)" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		"MariaDB" "Instalar la base de datos MariaDB (fork de MySQL)" OFF \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		--ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -301,7 +312,7 @@ instalarDatabase() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		esac 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	elif [ $rhelOS = true ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		whiptail --title "Base de Datos" --yesno "Para su distribucion $OS $DIST $REV, sólo está disponible la base de datos MariaDB." --yes-button "Continuar" --no-button "Salir" 20 70 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		whiptail --title "BASE DE DATOS" --yesno "Para su distribucion $OS $DIST $REV, sólo está disponible la base de datos MariaDB." --yes-button "Continuar" --no-button "Salir" 20 70 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			printf "\nERROR:\tInstalación interrumpida por el usuario.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			exit 2 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -355,7 +366,7 @@ instalarMariaDB() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-# Comprobamos 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# Comprobación del sistema 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 comprobarRoot 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 OSInfo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 comprobarDependencias 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -365,11 +376,14 @@ mostrarBienvenida 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Mejora: instalación express vs instalación avanzada 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Selección de componentes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 mostrarComponentes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Pre-configuración 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	# Habilitar cortafuegos -> PROBLEMA: se corta la conexión ssh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Instalación 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	# Cuando funcionen todos los instaladores, cambiarlo por variables de estado e instalar en este punto 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	# whiptail --gauge 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Configuración 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	# Configuración Apache 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		# Virtual Hosts 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -385,6 +399,7 @@ mostrarComponentes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	# Configuración SSL/TLS 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		# Generar certificados 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		# Configurar certificados 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	# Configurar actualización 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Autodestrucción 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 |