| 
					
				 | 
			
			
				@@ -144,6 +144,15 @@ comprobarError() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		902) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			error="$type $codeNum:\tImposible habilitar servicio '$extraInfo' durante el arranque.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		903) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			error="$type $codeNum:\tError interno (deshabilitar servicio).\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		904) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			error="$type $codeNum:\tImposible parar servicio '$extraInfo'.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		905) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			error="$type $codeNum:\tImposible deshabilitar servicio '$extraInfo' durante el arranque.\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		*) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			error="ERROR 13:\tError interno (comprobación de errores)\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			exitNum=1 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -614,6 +623,54 @@ habilitarServicio() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	echo -en " OK.\n" | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+deshabilitarServicio() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	# Paramos y deshabilitamos el servicio (con SystemD, Upstart o SystemV) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	# Intentamos con systemctl (SystemD) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	echo -en "Deshabilitando servicio $1" | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if [ $# -le 0 ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		comprobarError 1 903 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	which systemctl > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if [ $? -eq 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		echo -en " (SystemD)..." | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		systemctl stop $1 > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		comprobarError $? 904 $1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		systemctl disable $1 > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		comprobarError $? 905 $1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		# Intentamos con service (Upstart) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		which service > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if [ $? -eq 0 ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			echo -en " (Upstart)..." | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			service $1 stop > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			comprobarError $? 904 $1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			# Intentamos con init.d (SystemV) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			echo -en " (SystemV)..." | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			/etc/init.d/$1 stop > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			comprobarError $? 904 $1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		# Intentamos habilitar en el arranque (Upstart) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		which update-rc.d > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if [ $? -eq 0 ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			update-rc.d $1 disable 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			comprobarError $? 905 $1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			# Intentamos habilitar en el arranque (SystemV) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			which chkconfig > /dev/null 2>&1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if [ $? -eq 0 ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				chkconfig $1 off 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				comprobarError $? 905 $1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				# ¿Qué mas opciones nos quedan? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				comprobarError 1 905 $1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	# Mejora: comprobar si el servicio está funcionando 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	echo -en " OK.\n" | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Comprobación del sistema e inicialización 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 inicializarVariables 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 comprobarRoot 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -766,13 +823,32 @@ mostrarExpress 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #	} > >(whiptail --gauge "Configurando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	echo -en " OK.\n" | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	# Arrancar y habilitar todos los servicios (SystemD, Service o SystemV) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	echo -en "Arrancando Servicios..." | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #	{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #		echo -en "%s\n" $((100 * progreso / progresoTotal)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		sleep 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if [ $apacheOn = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if [ $debianOS = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				habilitarServicio apache2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if [ $phpOn = true ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					habilitarServicio php 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			elif [ $rhelOS = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				habilitarServicio httpd 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if [ $phpOn = true ]; then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					habilitarServicio php72 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		elif [ $nginxOn = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			habilitarServicio nginx 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if [ $phpOn = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if [ $debianOS = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					habilitarServicio php-fpm 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				elif [ $rhelOS = true ];then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					habilitarServicio php72-php-fpm 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		progreso=$((progreso + 1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #	} > >(whiptail --gauge "Arrancando Servicios..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	echo -en " OK.\n" | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	# Añadir reglas del cortafuegos 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	echo -en "Configurando Cortafuegos..." | tee -a $logFile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #	{ 
			 |