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