|
@@ -151,7 +151,7 @@ comprobarError() {
|
|
|
;;
|
|
|
esac
|
|
|
if [ $exitNum -ne 0 ];then
|
|
|
- printf "$error" | tee -a $logFile
|
|
|
+ echo -en "$error" | tee -a $logFile
|
|
|
if [ $type = "ERROR" ];then
|
|
|
exit $codeNum
|
|
|
fi
|
|
@@ -160,7 +160,7 @@ comprobarError() {
|
|
|
}
|
|
|
|
|
|
OSInfo() {
|
|
|
- printf "Detectando SO..." >> $logFile
|
|
|
+ echo -en "Detectando SO..." >> $logFile
|
|
|
OS=$(uname -s)
|
|
|
if [ $OS = "Linux" ]; then
|
|
|
OS="GNU/Linux"
|
|
@@ -170,7 +170,7 @@ OSInfo() {
|
|
|
ID_LIKE=$(grep ^ID_LIKE= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
|
|
|
VERSION=$(grep ^VERSION_ID= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
|
|
|
for i in $ID_LIKE; do
|
|
|
- #printf "$i\n"
|
|
|
+ #echo -en "$i\n"
|
|
|
case $i in
|
|
|
debian|ubuntu)
|
|
|
debianOS=true
|
|
@@ -214,9 +214,9 @@ OSInfo() {
|
|
|
ID_LIKE=""
|
|
|
VERSION=""
|
|
|
fi
|
|
|
- printf " $OS $DIST $REV\n" >> $logFile
|
|
|
+ echo -en " $OS $DIST $REV\n" >> $logFile
|
|
|
HDInfo=$(df -h | head -1)"\n"$(df -h | grep ^/dev/sd)"\n"$(df -h | grep ^/dev/mapper)
|
|
|
- printf "$HDInfo\n" >> $logFile
|
|
|
+ echo -en "$HDInfo\n" >> $logFile
|
|
|
}
|
|
|
|
|
|
comprobarRoot() {
|
|
@@ -238,10 +238,10 @@ comprobarDependencias() {
|
|
|
which apt-get > /dev/null 2>&1
|
|
|
comprobarError $? 803
|
|
|
# Actualizamos base de datos del repositorio
|
|
|
- printf "Actualizando repositorio APT..." | tee -a $logFile
|
|
|
+ echo -en "Actualizando repositorio APT..." | tee -a $logFile
|
|
|
result=$(apt-get -q -y update)
|
|
|
comprobarError $? 805 $result
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
# Comprobamos Firewall (ufw)
|
|
|
which ufw > /dev/null 2>&1
|
|
|
comprobarError $? 806
|
|
@@ -251,10 +251,10 @@ comprobarDependencias() {
|
|
|
which yum > /dev/null 2>&1
|
|
|
comprobarError $? 804
|
|
|
# Actualizamos base de datos del repositorio
|
|
|
- printf "Actualizando repositorio YUM..."
|
|
|
+ echo -en "Actualizando repositorio YUM..."
|
|
|
result=$(yum -y makecache 2>&1)
|
|
|
comprobarError $? 805 $result
|
|
|
- printf " OK.\n"
|
|
|
+ echo -en " OK.\n"
|
|
|
# Comprobamos Firewall (firewall-cmd)
|
|
|
which firewall-cmd > /dev/null 2>&1
|
|
|
comprobarError $? 807
|
|
@@ -392,7 +392,7 @@ establecerFQDN() {
|
|
|
hostname=$(hostname)
|
|
|
fi
|
|
|
done
|
|
|
- printf "Hostname: $hostname\n" >> $logFile
|
|
|
+ echo -en "Hostname: $hostname\n" >> $logFile
|
|
|
}
|
|
|
|
|
|
instalarApache() {
|
|
@@ -460,8 +460,8 @@ 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
|
|
|
- #printf "SQL Password 1: $sqlPasswd\n"
|
|
|
- #printf "SQL Password 2: $sqlPasswd2\n"
|
|
|
+ #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
|
|
@@ -470,7 +470,7 @@ leerSQLPasswd() {
|
|
|
control=true
|
|
|
fi
|
|
|
done
|
|
|
- #printf "SQL Password: $sqlPasswd\n"
|
|
|
+ #echo -en "SQL Password: $sqlPasswd\n"
|
|
|
unset control error sqlPasswd2
|
|
|
}
|
|
|
|
|
@@ -572,13 +572,13 @@ instalarPHP() {
|
|
|
habilitarServicio() {
|
|
|
# Arrancamos y habilitamos el servicio (con SystemD, Upstart o SystemV)
|
|
|
# Intentamos con systemctl (SystemD)
|
|
|
- printf "Habilitando servicio $1" | tee -a $logFile
|
|
|
+ echo -en "Habilitando servicio $1" | tee -a $logFile
|
|
|
if [ $# -le 0 ];then
|
|
|
comprobarError 1 900
|
|
|
fi
|
|
|
which systemctl > /dev/null 2>&1
|
|
|
if [ $? -eq 0 ]; then
|
|
|
- printf " (SystemD)..." | tee -a $logFile
|
|
|
+ echo -en " (SystemD)..." | tee -a $logFile
|
|
|
systemctl start $1 > /dev/null 2>&1
|
|
|
comprobarError $? 901 $1
|
|
|
systemctl enable $1 > /dev/null 2>&1
|
|
@@ -587,12 +587,12 @@ habilitarServicio() {
|
|
|
# Intentamos con service (Upstart)
|
|
|
which service > /dev/null 2>&1
|
|
|
if [ $? -eq 0 ]; then
|
|
|
- printf " (Upstart)..." | tee -a $logFile
|
|
|
+ echo -en " (Upstart)..." | tee -a $logFile
|
|
|
service $1 start > /dev/null 2>&1
|
|
|
comprobarError $? 901 $1
|
|
|
else
|
|
|
# Intentamos con init.d (SystemV)
|
|
|
- printf " (SystemV)..." | tee -a $logFile
|
|
|
+ echo -en " (SystemV)..." | tee -a $logFile
|
|
|
/etc/init.d/$1 start > /dev/null 2>&1
|
|
|
comprobarError $? 901 $1
|
|
|
fi
|
|
@@ -614,7 +614,7 @@ habilitarServicio() {
|
|
|
fi
|
|
|
fi
|
|
|
# Mejora: comprobar si el servicio está funcionando
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
}
|
|
|
|
|
|
# Comprobación del sistema e inicialización
|
|
@@ -635,76 +635,76 @@ mostrarExpress
|
|
|
# FALTA: whiptail --gauge -> Más bonito
|
|
|
# Servidor Web
|
|
|
if [ $apacheOn = true ]; then
|
|
|
- printf "Instalando Web Server Apache..." | tee -a $logFile
|
|
|
+ echo -en "Instalando Web Server Apache..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
instalarApache
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Instalando Web Server Apache..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
elif [ $nginxOn = true ]; then
|
|
|
- printf "Instalando Web Server Nginx..." | tee -a $logFile
|
|
|
+ echo -en "Instalando Web Server Nginx..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
instalarNginx
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Instalando Web Server Nginx..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
fi
|
|
|
# Base de Datos
|
|
|
if [ $mySQLOn = true ]; then
|
|
|
- printf "Instalando Base de Datos MySQL..." | tee -a $logFile
|
|
|
+ echo -en "Instalando Base de Datos MySQL..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
instalarMySQL
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Instalando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
elif [ $mariaDBOn = true ]; then
|
|
|
- printf "Instalando Base de Datos MariaDB..." | tee -a $logFile
|
|
|
+ echo -en "Instalando Base de Datos MariaDB..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
instalarMariaDB
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Instalando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
fi
|
|
|
# PHP
|
|
|
if [ $phpOn = true ]; then
|
|
|
- printf "Instalando PHP-7..." | tee -a $logFile
|
|
|
+ echo -en "Instalando PHP-7..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
instalarPHP
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Instalando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
fi
|
|
|
# SSL/TLS
|
|
|
# Falta por implementar
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Instalando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
# MediaWiki
|
|
|
if [ $mediaWikiOn = true ]; then
|
|
|
- printf "Instalando MediaWiki..." | tee -a $logFile
|
|
|
+ echo -en "Instalando MediaWiki..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Instalando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
fi
|
|
|
# Moodle
|
|
|
if [ $moodleOn = true ]; then
|
|
|
- printf "Instalando Moodle..." | tee -a $logFile
|
|
|
+ echo -en "Instalando Moodle..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Instalando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
fi
|
|
|
|
|
|
# PRECAUCION!!!! Hay que habilitar algunos servicios antes de configurarlos
|
|
@@ -713,95 +713,95 @@ mostrarExpress
|
|
|
# Configuración
|
|
|
# Configuración Apache
|
|
|
# Virtual Hosts
|
|
|
- printf "Configurando Servidor Web..." | tee -a $logFile
|
|
|
+ echo -en "Configurando Servidor Web..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando Servidor Web..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
# Configuración Database
|
|
|
# Arrancar Base de Datos, establecer contraseña y configuración segura
|
|
|
if [ $mySQLOn = true ];then
|
|
|
habilitarServicio mysql
|
|
|
- printf "Configurando Base de Datos MySQL..." | tee -a $logFile
|
|
|
+ echo -en "Configurando Base de Datos MySQL..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
establecerSQLPasswd
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
fi
|
|
|
if [ $mariaDBOn = true ];then
|
|
|
habilitarServicio mariadb
|
|
|
- printf "Configurando Base de Datos MariaDB..." | tee -a $logFile
|
|
|
+ echo -en "Configurando Base de Datos MariaDB..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
establecerSQLPasswd
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
fi
|
|
|
# Configuración PHP
|
|
|
# cgi.fix_pathinfo=0
|
|
|
# Configurar máximo de subida de archivos
|
|
|
- printf "Configurando PHP-7..." | tee -a $logFile
|
|
|
+ echo -en "Configurando PHP-7..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
# Configuración MediWiki
|
|
|
- printf "Configurando MediaWiki..." | tee -a $logFile
|
|
|
+ echo -en "Configurando MediaWiki..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
# Configuración Moodle
|
|
|
- printf "Configurando Moodle..." | tee -a $logFile
|
|
|
+ echo -en "Configurando Moodle..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
# Arrancar y habilitar todos los servicios (SystemD, Service o SystemV)
|
|
|
- printf "Arrancando Servicios..." | tee -a $logFile
|
|
|
+ echo -en "Arrancando Servicios..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Arrancando Servicios..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
# Añadir reglas del cortafuegos
|
|
|
- printf "Configurando Cortafuegos..."
|
|
|
+ echo -en "Configurando Cortafuegos..."
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando Cortafuegos..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
# Configuración SSL/TLS
|
|
|
# Generar certificados
|
|
|
# Configurar certificados
|
|
|
- printf "Configurando SSL/TLS..." | tee -a $logFile
|
|
|
+ echo -en "Configurando SSL/TLS..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
# Configurar actualizaciones
|
|
|
if [ $actualizacionesOn = true ]; then
|
|
|
- printf "Configurando actualizaciones automáticas..." | tee -a $logFile
|
|
|
+ echo -en "Configurando actualizaciones automáticas..." | tee -a $logFile
|
|
|
# {
|
|
|
-# printf "%s\n" $((100 * progreso / progresoTotal))
|
|
|
+# echo -en "%s\n" $((100 * progreso / progresoTotal))
|
|
|
sleep 2
|
|
|
progreso=$((progreso + 1))
|
|
|
# } > >(whiptail --gauge "Configurando actualizaciones automáticas..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
|
|
|
- printf " OK.\n" | tee -a $logFile
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
fi
|
|
|
|