Explorar el Código

* Limpieza de código

Guzmán Castanedo Villalba hace 5 años
padre
commit
aa8f33d05b
Se han modificado 1 ficheros con 15 adiciones y 34 borrados
  1. 15 34
      install

+ 15 - 34
install

@@ -546,6 +546,7 @@ comprobarDependencias() {
 				result=$(apt-get -q -y install xz-utils 2>&1)
 				comprobarError $? 814 $result
 			fi
+			# Comprobamos openssl
 			which openssl > /dev/null 2>&1
 			if [ $? -ne 0 ];then
 				result=$(apt-get -q -y install openssl 2>&1)
@@ -603,6 +604,7 @@ comprobarDependencias() {
 				result=$(yum -y install xz 2>&1)
 				comprobarError $? 814 $result
 			fi
+			# Comprobamos openssl
 			which openssl > /dev/null 2>&1
 			if [ $? -ne 0 ];then
 				result=$(yum -y install openssl 2>&1)
@@ -740,8 +742,6 @@ leerSQLPasswd() {
 		comprobarError $? 1
 		sqlPasswd2=$(whiptail --title "CONTRASEÑA SQL" --passwordbox "Confirme la CONTRASEÑA:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --ok-button "Continuar" --nocancel 3>&1 1>&2 2>&3)
 		comprobarError $? 1
-		#echo -en "SQL Password 1: $sqlPasswd\n"
-		#echo -en "SQL Password 2: $sqlPasswd2\n"
 		if [ -z "$sqlPasswd" ] || [ -z "$sqlPasswd2" ]; then
 			error="ERROR: LA CONTRASEÑA NO PUEDE ESTAR VACIA.\n"
 		elif [ $sqlPasswd != $sqlPasswd2 ];then
@@ -750,7 +750,6 @@ leerSQLPasswd() {
 			control=true
 		fi
 	done
-	#echo -en "SQL Password: $sqlPasswd\n"
 	unset control error sqlPasswd2
 }
 
@@ -1111,7 +1110,7 @@ instalarNginx() {
 			comprobarError $? 102 $result
 			;;
 		centos)
-			# Sólo para CentOS
+			# CentOS requiere un repositorio extra ('epel-release')
 			result=$(yum -y install epel-release)
 			comprobarError $? 103 $result
 			result=$(yum -y install nginx 2>&1)
@@ -1208,7 +1207,7 @@ instalarVirtualHost() {
 			comprobarError $? 908
 		fi
 	elif [ $nginxOn = true ];then
-		# Configuramos root, dominio, logs y php-fpm.sock (NGINX)
+		# Configuramos root, dominio, logs y php-fpm.sock
 		sed -i '/root /c\\troot '$rootVirtualHost';' "$virtualHostFile"
 		comprobarError $? 908
 		sed -i '/server_name /c\\tserver_name '"$dominioVirtualHost"' '"$aliasVirtualHost"';' $virtualHostFile
@@ -1227,15 +1226,17 @@ instalarVirtualHost() {
 			comprobarError $? 908
 		fi
 	fi
-	# Copiamos ficheros de configuración
+	# Copiamos Virtual Host
 	cp -f $virtualHostFile "/etc/$webServerName/sites-available/$virtualHostName" >> $logFile 2>&1
 	comprobarError $? 910
 	if [ -f "/etc/$webServerName/sites-enabled/$virtualHostName" ];then
 		rm -f /etc/$webServerName/sites-enabled/$virtualHostName 2>/dev/null
 		comprobarError 911 $virtualHostName
 	fi
+	# Habilitamos Virtual Host
 	ln -s "/etc/$webServerName/sites-available/$virtualHostName" "/etc/$webServerName/sites-enabled/$virtualHostName" >> $logFile 2>&1
 	comprobarError $? 911 $virtualHostName
+	# Recargamos servicio
 	recargarServicio $webServerName
 	unset rootVirtualHost dominioVirtualHost virtualHostFile virtualHostName aliasVirtualHost socket
 }
@@ -1620,20 +1621,18 @@ generarDHParam() {
 		sed -i '/ssl_param /c\\tssl_dhparam '$dhParamFile';' $nginxConfFile
 		comprobarError $? 403
 	fi
-#	unset sslDir dhParamFile apacheConfFile nginxConfFile
 	unset sslDir dhParamFile nginxConfFile
 }
 
 habilitarServicio() {
 # Arrancamos y habilitamos el servicio (con SystemD, Upstart o SystemV)
-	# Intentamos con systemctl (SystemD)
-	#echo -en "Habilitando Servicio '$1'" | tee -a $logFile
+	# Arrancamos el servicio
 	if [ $# -le 0 ];then
 		comprobarError 1 900
 	fi
+	# Intentamos con Systemd
 	which systemctl > /dev/null 2>&1
 	if [ $? -eq 0 ]; then
-		#echo -en " (SystemD)..." | tee -a $logFile
 		systemctl start $1 > /dev/null 2>&1
 		comprobarError $? 901 $1
 		systemctl enable $1 > /dev/null 2>&1
@@ -1642,12 +1641,10 @@ habilitarServicio() {
 		# Intentamos con service (Upstart)
 		which service > /dev/null 2>&1
 		if [ $? -eq 0 ]; then
-			#echo -en " (Upstart)..." | tee -a $logFile
 			service $1 start > /dev/null 2>&1
 			comprobarError $? 901 $1
 		else
 			# Intentamos con init.d (SystemV)
-			#echo -en " (SystemV)..." | tee -a $logFile
 			/etc/init.d/$1 start > /dev/null 2>&1
 			comprobarError $? 901 $1
 		fi
@@ -1663,25 +1660,21 @@ habilitarServicio() {
 				chkconfig $1 on
 				comprobarError $? 902 $1
 			else
-				# ¿Qué mas opciones nos quedan?
 				comprobarError 1 902 $1
 			fi
 		fi
 	fi
-	# Mejora: comprobar si el servicio está parado
-	#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
+	# Paramos el servicio
 	if [ $# -le 0 ];then
 		comprobarError 1 903
 	fi
+	# Intentamos con Systemd
 	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
@@ -1690,64 +1683,54 @@ deshabilitarServicio() {
 		# 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)
+		# Intentamos deshabilitar 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)
+			# Intentamos deshabilitar 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
 }
 
 recargarServicio() {
 # Recargamos el servicio (con SystemD, Upstart o SystemV)
-	# Intentamos con systemctl (SystemD)
-	#echo -en "Recargando Servicio '$1'" | tee -a $logFile
+	# Recargamos el servicio
 	if [ $# -le 0 ];then
 		comprobarError 1 912
 	fi
+	# Intentamos con Systemd
 	which systemctl > /dev/null 2>&1
 	if [ $? -eq 0 ]; then
-		#echo -en " (SystemD)..." | tee -a $logFile
 		systemctl reload $1 > /dev/null 2>&1
 		comprobarError $? 913 $1
 	else
 		# Intentamos con service (Upstart)
 		which service > /dev/null 2>&1
 		if [ $? -eq 0 ]; then
-			#echo -en " (Upstart)..." | tee -a $logFile
 			service $1 reload > /dev/null 2>&1
 			comprobarError $? 913 $1
 		else
 			# Intentamos con init.d (SystemV)
-			#echo -en " (SystemV)..." | tee -a $logFile
 			/etc/init.d/$1 reload > /dev/null 2>&1
 			comprobarError $? 913 $1
 		fi
 	fi
-	# Mejora: comprobar si el servicio está funcionando
-	#echo -en " OK.\n" | tee -a $logFile
 }
 
 configurarCortafuegos() {
@@ -1861,8 +1844,6 @@ descargarMoodle() {
 	if [ ! -d ./var ];then
 		comprobarError 1 5 "./var"
 	fi
-	#echo -en "Descargando Moodle-3.5-1..." | tee -a $logFile
-	#curl -o "./var/moodle-3.5.1.tgz" "https://download.moodle.org/download.php/direct/stable35/moodle-latest-35.tgz" >> $logFile 2>&1
 	curl "https://download.moodle.org/download.php/direct/stable35/moodle-latest-35.tgz" 2>/dev/null | tar -xz -C "./var/"
 	comprobarError $? 501
 	#echo -en " OK.\n" | tee -a $logFile