| 
					
				 | 
			
			
				@@ -0,0 +1,154 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#!/bin/bash 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+################################################################# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# auto-mediawiki												# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# Instala un servidor LAMP (Linux+Apache+MySQL+PHP) e instala	# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# MediaWiki y lo configura.										# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#																# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# Guzman Castanedo Villalba (guzman@castanedo.es) Junio 2018	# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# GPLv3 (https://www.gnu.org/licenses/gpl.html)					# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+################################################################# 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+OSInfo() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	#printf "Detectando SO..." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	debianOS=false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	rhelOS=false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	OS=$(uname -s) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if [ $OS = "Linux" ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		OS="GNU/Linux" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if [ -f /etc/os-release ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			DIST=$(grep ^NAME= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			REV=$(grep ^VERSION= /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) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for i in $ID_LIKE; do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				printf "$i\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				case $i in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					debian|ubuntu) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						debianOS=true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					rhel|fedora) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						rhelOS=true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					*) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						debianOS=false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						rhelOS=false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				esac 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			done 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		elif [ -f /etc/debian-version ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			# Familia Debian (Debian, Ubuntu, Linux Mint, ...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			DIST="Debian" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			REV="" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			debianOS=true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		elif [ -f /etc/redhat-release ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			# Familia Red-Hat (RHEL, Fedora, CentOS, ...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			DIST="Red-Hat" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			REV="" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			rhelOS=true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			# Other Linux (No Soportado) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			DIST="" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			REV="" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		#UNIX, OS X, ... (No Soportado) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		DIST=$OS 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		REV="" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	#printf " $DIST $REV\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	HDInfo=$(df -h | head -1)"\n"$(df -h | grep ^/dev/sd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+comprobarRoot() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if [ $(id -u) -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		printf "ERROR:\tEs necesario ser root ('sudo $0').\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+comprobarDependencias() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if [ ! -x $(which whiptail) ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		printf "ERROR:\twhiptail no disponible.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if [ $debianOS = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		which apt-get > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "ERROR:\t'apt-get' no está disponible.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if [ $rhelOS = true ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		which yum > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "ERROR:\t'yum' no está disponible.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if [ $? -ne 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		printf "ERROR:\tInstalación interrumpida por el usuario.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		exit 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# Comprobamos 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+comprobarRoot 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+OSInfo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+comprobarDependencias 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# Bienvenida 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+mostrarBienvenida 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# Selección de componentes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+componentes=$(whiptail --title "Instalación" --checklist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge los componentes que quieres instalar:" 20 70 5 \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"WebServer" "Instalar servidor web http/https" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"Database" "Instalar una base de datos SQL" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"PHP" "Instala PHP7" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"SSL/TLS" "Instala certificados para activar HTTPS" ON \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"MediaWiki" "Instala la última versión de MediaWiki" 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" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	exit 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#printf "$componentes\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+for i in $componentes; do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	case $i in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		\"WebServer\") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "Instalación WebServer\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		\"Database\") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "Instalación Database\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		\"PHP\") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "Instalación PHP\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		\"SSL/TLS\") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "Instalación SSL/TLS\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		\"MediaWiki\") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "Instalación MediaWiki\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		*) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			printf "ERROR:\tError interno (selección de componentes).\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			exit 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	esac 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+done 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# Autodestrucción 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for i in $(seq 0 5 100); do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		sleep 0.1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		echo $i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	done 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} | whiptail --gauge "Autodestrucción..." 7 70 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 |