|
@@ -316,7 +316,6 @@ OSInfo() {
|
|
|
for i in $ID; do
|
|
|
case $i in
|
|
|
debian)
|
|
|
- debianOS=true
|
|
|
case $VERSION in
|
|
|
9)
|
|
|
apacheName="apache2"
|
|
@@ -333,7 +332,6 @@ OSInfo() {
|
|
|
break
|
|
|
;;
|
|
|
ubuntu)
|
|
|
- debianOS=true
|
|
|
case $VERSION in
|
|
|
18.04)
|
|
|
apacheName="apache2"
|
|
@@ -358,7 +356,6 @@ OSInfo() {
|
|
|
break
|
|
|
;;
|
|
|
rhel|centos)
|
|
|
- rhelOS=true
|
|
|
case $VERSION in
|
|
|
7)
|
|
|
apacheName="httpd"
|
|
@@ -374,7 +371,6 @@ OSInfo() {
|
|
|
break
|
|
|
;;
|
|
|
fedora)
|
|
|
- rhelOS=true
|
|
|
case $VERSION in
|
|
|
28)
|
|
|
apacheName="httpd"
|
|
@@ -390,8 +386,6 @@ OSInfo() {
|
|
|
break
|
|
|
;;
|
|
|
*)
|
|
|
- debianOS=false
|
|
|
- rhelOS=false
|
|
|
comprobarError 1 817
|
|
|
;;
|
|
|
esac
|
|
@@ -425,129 +419,129 @@ comprobarDependencias() {
|
|
|
comprobarError $? 802
|
|
|
which find > /dev/null 2>&1
|
|
|
comprobarError $? 816
|
|
|
- if [ $debianOS = true ];then
|
|
|
- # Comprobamos apt-get
|
|
|
- which apt-get > /dev/null 2>&1
|
|
|
- comprobarError $? 803
|
|
|
- # Actualizamos base de datos del repositorio
|
|
|
- echo -en "Actualizando repositorio APT..." | tee -a $logFile
|
|
|
- result=$(apt-get -q -y update 2>&1)
|
|
|
- comprobarError $? 805 $result
|
|
|
- echo -en " OK.\n" | tee -a $logFile
|
|
|
- # Comprobamos Firewall (ufw)
|
|
|
- which ufw > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install ufw 2>&1)
|
|
|
- comprobarError $? 806 $result
|
|
|
- fi
|
|
|
- # Comprobamos tput
|
|
|
- which tput > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install ncurses-bin 2>&1)
|
|
|
- comprobarError $? 808 $result
|
|
|
- fi
|
|
|
- # Comprobar sed
|
|
|
- which sed > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install sed 2>&1)
|
|
|
- comprobarError $? 809 $result
|
|
|
- fi
|
|
|
- # Comprobar curl
|
|
|
- which curl > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install curl 2>&1)
|
|
|
- comprobarError $? 810 $result
|
|
|
- fi
|
|
|
- # Comprobamos tar, gzip, bzip2 y xz
|
|
|
- which tar > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install tar 2>&1)
|
|
|
- comprobarError $? 811 $result
|
|
|
- fi
|
|
|
- which gzip > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install gzip 2>&1)
|
|
|
- comprobarError $? 812 $result
|
|
|
- fi
|
|
|
- which bzip2 > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install bzip2 2>&1)
|
|
|
- comprobarError $? 813 $result
|
|
|
- fi
|
|
|
- which xz > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install xz-utils 2>&1)
|
|
|
- comprobarError $? 814 $result
|
|
|
- fi
|
|
|
- which openssl > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(apt-get -q -y install openssl 2>&1)
|
|
|
- comprobarError $? 815 $result
|
|
|
- fi
|
|
|
- fi
|
|
|
- if [ $rhelOS = true ]; then
|
|
|
- # Comprobamos yum
|
|
|
- which yum > /dev/null 2>&1
|
|
|
- comprobarError $? 804
|
|
|
- # Actualizamos base de datos del repositorio
|
|
|
- echo -en "Actualizando repositorio YUM..." | tee -a $logFile
|
|
|
- result=$(yum -y makecache 2>&1)
|
|
|
- comprobarError $? 805 $result
|
|
|
- echo -en " OK.\n" | tee -a $logFile
|
|
|
- # Comprobamos Firewall (firewall-cmd)
|
|
|
- which firewall-cmd > /dev/null 2>&1
|
|
|
- comprobarError $? 807
|
|
|
- # Comprobamos tput
|
|
|
- which tput > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(yum -y install ncurses 2>&1)
|
|
|
- comprobarError $? 808 $result
|
|
|
- fi
|
|
|
- # Comprobar sed
|
|
|
- which sed > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(yum -y install sed 2>&1)
|
|
|
- comprobarError $? 809 $result
|
|
|
- fi
|
|
|
- # Comprobar curl
|
|
|
- which curl > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(yum -y install curl 2>&1)
|
|
|
- comprobarError $? 810 $result
|
|
|
- fi
|
|
|
- # Comprobamos tar, gzip, bzip2 y xz
|
|
|
- which tar > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(yum -y install tar 2>&1)
|
|
|
- comprobarError $? 811 $result
|
|
|
- fi
|
|
|
- which gzip > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(yum -y install gzip 2>&1)
|
|
|
- comprobarError $? 812 $result
|
|
|
- fi
|
|
|
- which bzip2 > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(yum -y install bzip2 2>&1)
|
|
|
- comprobarError $? 813 $result
|
|
|
- fi
|
|
|
- which xz > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(yum -y install xz 2>&1)
|
|
|
- comprobarError $? 814 $result
|
|
|
- fi
|
|
|
- which openssl > /dev/null 2>&1
|
|
|
- if [ $? -ne 0 ];then
|
|
|
- result=$(yum -y install openssl 2>&1)
|
|
|
- comprobarError $? 815 $result
|
|
|
- fi
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ # Comprobamos apt-get
|
|
|
+ which apt-get > /dev/null 2>&1
|
|
|
+ comprobarError $? 803
|
|
|
+ # Actualizamos base de datos del repositorio
|
|
|
+ echo -en "Actualizando repositorio APT..." | tee -a $logFile
|
|
|
+ result=$(apt-get -q -y update 2>&1)
|
|
|
+ comprobarError $? 805 $result
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
+ # Comprobamos Firewall (ufw)
|
|
|
+ which ufw > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install ufw 2>&1)
|
|
|
+ comprobarError $? 806 $result
|
|
|
+ fi
|
|
|
+ # Comprobamos tput
|
|
|
+ which tput > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install ncurses-bin 2>&1)
|
|
|
+ comprobarError $? 808 $result
|
|
|
+ fi
|
|
|
+ # Comprobar sed
|
|
|
+ which sed > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install sed 2>&1)
|
|
|
+ comprobarError $? 809 $result
|
|
|
+ fi
|
|
|
+ # Comprobar curl
|
|
|
+ which curl > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install curl 2>&1)
|
|
|
+ comprobarError $? 810 $result
|
|
|
+ fi
|
|
|
+ # Comprobamos tar, gzip, bzip2 y xz
|
|
|
+ which tar > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install tar 2>&1)
|
|
|
+ comprobarError $? 811 $result
|
|
|
+ fi
|
|
|
+ which gzip > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install gzip 2>&1)
|
|
|
+ comprobarError $? 812 $result
|
|
|
+ fi
|
|
|
+ which bzip2 > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install bzip2 2>&1)
|
|
|
+ comprobarError $? 813 $result
|
|
|
+ fi
|
|
|
+ which xz > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install xz-utils 2>&1)
|
|
|
+ comprobarError $? 814 $result
|
|
|
+ fi
|
|
|
+ which openssl > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(apt-get -q -y install openssl 2>&1)
|
|
|
+ comprobarError $? 815 $result
|
|
|
+ fi
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ # Comprobamos yum
|
|
|
+ which yum > /dev/null 2>&1
|
|
|
+ comprobarError $? 804
|
|
|
+ # Actualizamos base de datos del repositorio
|
|
|
+ echo -en "Actualizando repositorio YUM..." | tee -a $logFile
|
|
|
+ result=$(yum -y makecache 2>&1)
|
|
|
+ comprobarError $? 805 $result
|
|
|
+ echo -en " OK.\n" | tee -a $logFile
|
|
|
+ # Comprobamos Firewall (firewall-cmd)
|
|
|
+ which firewall-cmd > /dev/null 2>&1
|
|
|
+ comprobarError $? 807
|
|
|
+ # Comprobamos tput
|
|
|
+ which tput > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(yum -y install ncurses 2>&1)
|
|
|
+ comprobarError $? 808 $result
|
|
|
+ fi
|
|
|
+ # Comprobar sed
|
|
|
+ which sed > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(yum -y install sed 2>&1)
|
|
|
+ comprobarError $? 809 $result
|
|
|
+ fi
|
|
|
+ # Comprobar curl
|
|
|
+ which curl > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(yum -y install curl 2>&1)
|
|
|
+ comprobarError $? 810 $result
|
|
|
+ fi
|
|
|
+ # Comprobamos tar, gzip, bzip2 y xz
|
|
|
+ which tar > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(yum -y install tar 2>&1)
|
|
|
+ comprobarError $? 811 $result
|
|
|
+ fi
|
|
|
+ which gzip > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(yum -y install gzip 2>&1)
|
|
|
+ comprobarError $? 812 $result
|
|
|
+ fi
|
|
|
+ which bzip2 > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(yum -y install bzip2 2>&1)
|
|
|
+ comprobarError $? 813 $result
|
|
|
+ fi
|
|
|
+ which xz > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(yum -y install xz 2>&1)
|
|
|
+ comprobarError $? 814 $result
|
|
|
+ fi
|
|
|
+ which openssl > /dev/null 2>&1
|
|
|
+ if [ $? -ne 0 ];then
|
|
|
+ result=$(yum -y install openssl 2>&1)
|
|
|
+ comprobarError $? 815 $result
|
|
|
+ fi
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
}
|
|
|
|
|
|
inicializarVariables() {
|
|
|
# Inicializa las variables que necesitan de un estado previo
|
|
|
- debianOS=false
|
|
|
- rhelOS=false
|
|
|
apacheOn=false
|
|
|
nginxOn=false
|
|
|
mySQLOn=false
|
|
@@ -564,13 +558,15 @@ inicializarVariables() {
|
|
|
maxUpload="100M"
|
|
|
apacheName=""
|
|
|
nginxName=""
|
|
|
- mysqlName=""
|
|
|
- mariadbName=""
|
|
|
webServerName=""
|
|
|
webServerUser=""
|
|
|
webServerGroup=""
|
|
|
+ mysqlName=""
|
|
|
+ mariadbName=""
|
|
|
sqlServerName=""
|
|
|
+ dbType=""
|
|
|
phpFPMName=""
|
|
|
+ phpDest=""
|
|
|
nombreMediaWiki=""
|
|
|
dominioMediaWiki=""
|
|
|
passwdMediaWiki=""
|
|
@@ -582,8 +578,22 @@ inicializarVariables() {
|
|
|
|
|
|
instalacionExpress() {
|
|
|
# Permite una instalación rápida, haciendo el menor número de preguntas
|
|
|
+# Defecto: Nginx + MariaDB + PHP + Let's Encrypt + MediaWiki + Moodle + Backup
|
|
|
nginxOn=true
|
|
|
- mariaDBOn=true
|
|
|
+ case $ID in
|
|
|
+ debian)
|
|
|
+ mySQLOn=true
|
|
|
+ dbType="mariadb"
|
|
|
+ ;;
|
|
|
+ ubuntu)
|
|
|
+ mariaDBOn=true
|
|
|
+ dbType="mariadb"
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ mariaDBOn=true
|
|
|
+ dbType="mariadb"
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
phpOn=true
|
|
|
sslOn=true
|
|
|
letsEncryptOn=true
|
|
@@ -839,75 +849,86 @@ establecerFQDN() {
|
|
|
instalarApache() {
|
|
|
# Instala Apache2
|
|
|
webServerName=$apacheName
|
|
|
- if [ $debianOS = true ];then
|
|
|
- result=$(apt-get -q -y install apache2 2>&1)
|
|
|
- comprobarError $? 101 $result
|
|
|
- elif [ $rhelOS = true ]; then
|
|
|
- result=$(yum -y install httpd 2>&1)
|
|
|
- comprobarError $? 101 $result
|
|
|
- if [ $sslOn = true ];then
|
|
|
- # Instalamos módulo mod_ssl (no se instala por defecto)
|
|
|
- result=$(yum -y install mod_ssl 2>&1)
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ result=$(apt-get -q -y install apache2 2>&1)
|
|
|
comprobarError $? 101 $result
|
|
|
- fi
|
|
|
- else
|
|
|
- comprobarError 1 104
|
|
|
- fi
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ result=$(yum -y install httpd 2>&1)
|
|
|
+ comprobarError $? 101 $result
|
|
|
+ if [ $sslOn = true ];then
|
|
|
+ # Instalamos módulo mod_ssl (no se instala por defecto)
|
|
|
+ result=$(yum -y install mod_ssl 2>&1)
|
|
|
+ comprobarError $? 101 $result
|
|
|
+ fi
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ comprobarError 1 104
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
deshabilitarServicio $webServerName
|
|
|
}
|
|
|
|
|
|
configurarApache() {
|
|
|
# Configura Apache2
|
|
|
- if [ $debianOS = true ];then
|
|
|
- apacheConfFile="./etc/apache2/apache2.conf"
|
|
|
- if [ ! -f $apacheConfFile ];then
|
|
|
- comprobarError 1 4 $apacheConfFile
|
|
|
- fi
|
|
|
- cp -f $apacheConfFile /etc/$webServerName/apache2.conf 2>/dev/null
|
|
|
- comprobarError $? 108
|
|
|
- webServerUser=$(grep ^User /etc/$webServerName/apache2.conf | cut -d ' ' -f 2)
|
|
|
- webServerGroup=$(grep ^Group /etc/$webServerName/apache2.conf | cut -d ' ' -f 2)
|
|
|
- if [ ! -L /etc/$webServerName/logs ];then
|
|
|
- ln -s /var/log/apache2 /etc/$webServerName/logs 2>/dev/null
|
|
|
- comprobarError $? 108
|
|
|
- fi
|
|
|
- # Activamos mod_rewrite (no viene activado por defecto)
|
|
|
- a2enmod rewrite >/dev/null 2>&1
|
|
|
- comprobarError $? 108
|
|
|
- # Activamos mod_ssl y mod_headers (no viene activado por defecto)
|
|
|
- if [ $sslOn = true ];then
|
|
|
- a2enmod ssl >/dev/null 2>&1
|
|
|
- comprobarError $? 108
|
|
|
- a2enmod headers >/dev/null 2>&1
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ apacheConfFile="./etc/apache2/apache2.conf"
|
|
|
+ if [ ! -f $apacheConfFile ];then
|
|
|
+ comprobarError 1 4 $apacheConfFile
|
|
|
+ fi
|
|
|
+ cp -f $apacheConfFile /etc/$webServerName/apache2.conf 2>/dev/null
|
|
|
comprobarError $? 108
|
|
|
- fi
|
|
|
- unset apacheConfFile
|
|
|
- elif [ $rhelOS = true ];then
|
|
|
- apacheConfFile="./etc/apache2/conf/httpd.conf"
|
|
|
- sslConfFile="./etc/apache2/conf.d/ssl.conf"
|
|
|
- welcomeConfFile="/etc/apache2/conf.d/welcome.conf"
|
|
|
- if [ ! -f $apacheConfFile ];then
|
|
|
- comprobarError 1 4 $apacheConfFile
|
|
|
- fi
|
|
|
- cp -f $apacheConfFile /etc/$webServerName/conf/httpd.conf 2>/dev/null
|
|
|
- comprobarError $? 108
|
|
|
- # Desactivamos Mensaje de Bienvenida
|
|
|
- if [ -f $welcomeConfFile ];then
|
|
|
- sed -i -e 's/^/#/' $welcomeConfFile
|
|
|
+ webServerUser=$(grep ^User /etc/$webServerName/apache2.conf | cut -d ' ' -f 2)
|
|
|
+ webServerGroup=$(grep ^Group /etc/$webServerName/apache2.conf | cut -d ' ' -f 2)
|
|
|
+ if [ ! -L /etc/$webServerName/logs ];then
|
|
|
+ ln -s /var/log/apache2 /etc/$webServerName/logs 2>/dev/null
|
|
|
+ comprobarError $? 108
|
|
|
+ fi
|
|
|
+ # Activamos mod_rewrite (no viene activado por defecto)
|
|
|
+ a2enmod rewrite >/dev/null 2>&1
|
|
|
comprobarError $? 108
|
|
|
- fi
|
|
|
- # Configuramos mod_ssl
|
|
|
- if [ $sslOn = true ];then
|
|
|
- if [ ! -f $sslConfFile ];then
|
|
|
- comprobarError 1 4 $sslConfFile
|
|
|
+ # Activamos mod_ssl y mod_headers (no viene activado por defecto)
|
|
|
+ if [ $sslOn = true ];then
|
|
|
+ a2enmod ssl >/dev/null 2>&1
|
|
|
+ comprobarError $? 108
|
|
|
+ a2enmod headers >/dev/null 2>&1
|
|
|
+ comprobarError $? 108
|
|
|
fi
|
|
|
- cp -f $sslConfFile /etc/$webServerName/conf.d/ssl.conf 2>/dev/null
|
|
|
+ unset apacheConfFile
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ apacheConfFile="./etc/apache2/conf/httpd.conf"
|
|
|
+ sslConfFile="./etc/apache2/conf.d/ssl.conf"
|
|
|
+ welcomeConfFile="/etc/apache2/conf.d/welcome.conf"
|
|
|
+ if [ ! -f $apacheConfFile ];then
|
|
|
+ comprobarError 1 4 $apacheConfFile
|
|
|
+ fi
|
|
|
+ cp -f $apacheConfFile /etc/$webServerName/conf/httpd.conf 2>/dev/null
|
|
|
comprobarError $? 108
|
|
|
- fi
|
|
|
- webServerUser=$(grep ^User /etc/$webServerName/conf/httpd.conf | cut -d ' ' -f 2)
|
|
|
- webServerGroup=$(grep ^Group /etc/$webServerName/conf/httpd.conf | cut -d ' ' -f 2)
|
|
|
- unset apacheConfFile sslConfFile welcomeConfFile
|
|
|
- fi
|
|
|
+ # Desactivamos Mensaje de Bienvenida
|
|
|
+ if [ -f $welcomeConfFile ];then
|
|
|
+ sed -i -e 's/^/#/' $welcomeConfFile
|
|
|
+ comprobarError $? 108
|
|
|
+ fi
|
|
|
+ # Configuramos mod_ssl
|
|
|
+ if [ $sslOn = true ];then
|
|
|
+ if [ ! -f $sslConfFile ];then
|
|
|
+ comprobarError 1 4 $sslConfFile
|
|
|
+ fi
|
|
|
+ cp -f $sslConfFile /etc/$webServerName/conf.d/ssl.conf 2>/dev/null
|
|
|
+ comprobarError $? 108
|
|
|
+ fi
|
|
|
+ webServerUser=$(grep ^User /etc/$webServerName/conf/httpd.conf | cut -d ' ' -f 2)
|
|
|
+ webServerGroup=$(grep ^Group /etc/$webServerName/conf/httpd.conf | cut -d ' ' -f 2)
|
|
|
+ unset apacheConfFile sslConfFile welcomeConfFile
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ comprobarError 1 108
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
+ # Creamos directorios sites-available y sites-enabled
|
|
|
if [ ! -d "/etc/$webServerName/sites-available" ];then
|
|
|
mkdir "/etc/$webServerName/sites-available" 2>/dev/null
|
|
|
comprobarError $? 5 "/etc/$webServerName/sites-available"
|
|
@@ -960,6 +981,7 @@ configurarNginx() {
|
|
|
else
|
|
|
comprobarError 1 5 "$nginxConfFile"
|
|
|
fi
|
|
|
+ # Creamos directorios sites-available y sites-enabled
|
|
|
if [ ! -d "/etc/$webServerName/sites-available" ];then
|
|
|
mkdir "/etc/$webServerName/sites-available" 2>/dev/null
|
|
|
comprobarError $? 5 "/etc/$webServerName/sites-available"
|
|
@@ -974,13 +996,16 @@ configurarNginx() {
|
|
|
fi
|
|
|
fi
|
|
|
# Configuramos Usuario y Grupo
|
|
|
- if [ $debianOS = true ];then
|
|
|
- webServerUser="www-data"
|
|
|
- webServerGroup=$webServerUser
|
|
|
- elif [ $rhelOS = true ];then
|
|
|
- webServerUser="nginx"
|
|
|
- webServerGroup=$webServerUser
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ webServerUser="www-data"
|
|
|
+ webServerGroup=$webServerUser
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ webServerUser="nginx"
|
|
|
+ webServerGroup=$webServerUser
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
sed -i '/user /c\user '$webServerUser';' /etc/$webServerName/nginx.conf
|
|
|
comprobarError $? 107
|
|
|
unset nginxConfFile
|
|
@@ -1059,31 +1084,43 @@ instalarVirtualHost() {
|
|
|
|
|
|
mostrarDatabase() {
|
|
|
# Pantalla que permite escoger entre instalar MariaDB o MySQL
|
|
|
- if [ $debianOS = true ]; then
|
|
|
- database=$(whiptail --title "BASE DE DATOS" --radiolist "<ESPACIO>: seleccionar <TAB>: cambiar <FLECHAS>: moverse\n\nEscoge la base de datos que quieres usar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 2 \
|
|
|
+ case $ID in
|
|
|
+ debian)
|
|
|
+ whiptail --title "BASE DE DATOS" --yesno "Para su distribucion $OS $DIST $REV, sólo está disponible la base de datos MariaDB." $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --yes-button "Continuar" --no-button "Salir"
|
|
|
+ comprobarError $? 1
|
|
|
+ # Excepción: aunque es MariaDB (se instala con el nombre de mysql-server)
|
|
|
+ mySQLOn= true
|
|
|
+ dbType="mariadb"
|
|
|
+ ;;
|
|
|
+ ubuntu)
|
|
|
+ database=$(whiptail --title "BASE DE DATOS" --radiolist "<ESPACIO>: seleccionar <TAB>: cambiar <FLECHAS>: moverse\n\nEscoge la base de datos que quieres usar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 2 \
|
|
|
"MariaDB" "Instalar la base de datos MariaDB (fork de MySQL)" ON \
|
|
|
"MySQL" "Instalar la base de datos MySQL (uso no comercial)" OFF \
|
|
|
--ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
|
|
|
- comprobarError $? 1
|
|
|
- case $database in
|
|
|
- MariaDB)
|
|
|
- mariaDBOn=true
|
|
|
- ;;
|
|
|
- MySQL)
|
|
|
- mySQLOn=true
|
|
|
- ;;
|
|
|
- *)
|
|
|
- comprobarError 1 200
|
|
|
- ;;
|
|
|
- esac
|
|
|
- unset database
|
|
|
- elif [ $rhelOS = true ]; then
|
|
|
- whiptail --title "BASE DE DATOS" --yesno "Para su distribucion $OS $DIST $REV, sólo está disponible la base de datos MariaDB." $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --yes-button "Continuar" --no-button "Salir"
|
|
|
- comprobarError $? 1
|
|
|
- mariaDBOn=true
|
|
|
- else
|
|
|
- comprobarError 1 200
|
|
|
- fi
|
|
|
+ comprobarError $? 1
|
|
|
+ case $database in
|
|
|
+ MariaDB)
|
|
|
+ mariaDBOn=true
|
|
|
+ dbType="mariadb"
|
|
|
+ ;;
|
|
|
+ MySQL)
|
|
|
+ mySQLOn=true
|
|
|
+ dbType="mysqli"
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ comprobarError 1 200
|
|
|
+ ;;
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ whiptail --title "BASE DE DATOS" --yesno "Para su distribucion $OS $DIST $REV, sólo está disponible la base de datos MariaDB." $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --yes-button "Continuar" --no-button "Salir"
|
|
|
+ comprobarError $? 1
|
|
|
+ mariaDBOn=true
|
|
|
+ dbType="mariadb"
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ comprobarError 1 200
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
# Otras opciones (contraseña)
|
|
|
leerSQLPasswd
|
|
|
}
|
|
@@ -1149,47 +1186,56 @@ establecerSQLPasswd() {
|
|
|
instalarMySQL() {
|
|
|
# Instala MySQL (sólo para Debian)
|
|
|
sqlServerName=$mysqlName
|
|
|
- if [ $debianOS = true ];then
|
|
|
- result=$(apt-get -q -y install mysql-server mysql-client 2>&1)
|
|
|
- comprobarError $? 201 $result
|
|
|
- elif [ $rhelOS = true ];then
|
|
|
- # MySQL no disponible en RHEL. 2 opciones:
|
|
|
- # 1) Instalar un repositorio adicional
|
|
|
- # 2) No instalar MySQL en distribuciones RHEL
|
|
|
- comprobarError 1 205
|
|
|
- else
|
|
|
- comprobarError 1 203
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ result=$(apt-get -q -y install mysql-server mysql-client 2>&1)
|
|
|
+ comprobarError $? 201 $result
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ # MySQL no disponible en RHEL.
|
|
|
+ # No se instalará MySQL en distribuciones RHEL
|
|
|
+ comprobarError 1 205
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ comprobarError 1 203
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
deshabilitarServicio $sqlServerName
|
|
|
}
|
|
|
|
|
|
instalarMariaDB() {
|
|
|
# Instala MariaDB
|
|
|
sqlServerName=$mariadbName
|
|
|
- if [ $debianOS = true ];then
|
|
|
- result=$(apt-get -q -y install mariadb-server mariadb-client 2>&1)
|
|
|
- comprobarError $? 202 $result
|
|
|
- elif [ $rhelOS = true ];then
|
|
|
- result=$(yum -y install mariadb-server mariadb 2>&1)
|
|
|
- comprobarError $? 202 $result
|
|
|
- else
|
|
|
- comprobarError 1 204
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ result=$(apt-get -q -y install mariadb-server mariadb-client 2>&1)
|
|
|
+ comprobarError $? 202 $result
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ result=$(yum -y install mariadb-server mariadb 2>&1)
|
|
|
+ comprobarError $? 202 $result
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ comprobarError 1 204
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
deshabilitarServicio $sqlServerName
|
|
|
}
|
|
|
|
|
|
configurarSQL() {
|
|
|
# Configura BarracudaFS en mysql (necesario para Moodle)
|
|
|
# Configura MariaDB o MySQL
|
|
|
- if [ $mariaDBOn = true ] && [ $debianOS = true ];then
|
|
|
- sqlConfFile="/etc/mysql/my.cnf"
|
|
|
- elif [ $mariaDBOn = true ] && [ $rhelOS = true ];then
|
|
|
- sqlConfFile="/etc/my.cnf"
|
|
|
- elif [ $mySQLOn = true ] && [ $debianOS = true ];then
|
|
|
- sqlConfFile="/etc/mysql/my.cnf"
|
|
|
- else
|
|
|
- comprobarError 1 213
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ sqlConfFile="/etc/mysql/my.cnf"
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ sqlConfFile="/etc/my.cnf"
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ comprobarError 1 213
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
if [ ! -f $sqlConfFile ];then
|
|
|
comprobarError 1 213
|
|
|
fi
|
|
@@ -1274,13 +1320,19 @@ instalarPHP() {
|
|
|
|
|
|
configurarPHP() {
|
|
|
# Configura PHP para segurizarlo y establecer máximo de subida.
|
|
|
- if [ $debianOS = true ];then
|
|
|
- phpConfFile="./etc/php/php.ini.debian"
|
|
|
- #phpDest="/etc/php/7.2/cli/php.ini"
|
|
|
- elif [ $rhelOS = true ];then
|
|
|
- phpConfFile="./etc/php/php.ini.rhel"
|
|
|
- phpDest="/etc/php.ini"
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ phpConfFile="./etc/php/php.ini.debian"
|
|
|
+ #phpDest="/etc/php/7.2/cli/php.ini"
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ phpConfFile="./etc/php/php.ini.rhel"
|
|
|
+ phpDest="/etc/php.ini"
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ comprobarError 1 305
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
if [ ! -f $phpConfFile ];then
|
|
|
comprobarError 1 4 "$phpConfFile"
|
|
|
fi
|
|
@@ -1297,19 +1349,24 @@ configurarPHP() {
|
|
|
sed -i '/upload_max_filesize =/c\upload_max_filesize = '$maxUpload $phpDest
|
|
|
comprobarError $? 305
|
|
|
# Configurar php-fpm (sólo en RHEL con Nginx)
|
|
|
- if [ $rhelOS = true ] && [ $nginxOn = true ];then
|
|
|
- # Configurar Socket UNIX
|
|
|
- phpConfFile="./etc/php/php-fpm.d/www.conf"
|
|
|
- phpDest="/etc/php-fpm.d/www.conf"
|
|
|
- if [ ! -f $phpConfFile ];then
|
|
|
- comprobarError $? 4 "$phpConfFile"
|
|
|
- fi
|
|
|
- cp -f $phpConfFile $phpDest 2>/dev/null
|
|
|
- comprobarError $? 305
|
|
|
- # Configurar Permisos /var/lib/php
|
|
|
- chown -R $webServerUser:$webServerGroup /var/lib/php/
|
|
|
- comprobarError $? 305
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ centos|fedora)
|
|
|
+ if [ $nginxOn = true ];then
|
|
|
+ # Configurar Socket UNIX
|
|
|
+ phpConfFile="./etc/php/php-fpm.d/www.conf"
|
|
|
+ phpDest="/etc/php-fpm.d/www.conf"
|
|
|
+ if [ ! -f $phpConfFile ];then
|
|
|
+ comprobarError $? 4 "$phpConfFile"
|
|
|
+ fi
|
|
|
+ cp -f $phpConfFile $phpDest 2>/dev/null
|
|
|
+ comprobarError $? 305
|
|
|
+ # Configurar Permisos /var/lib/php
|
|
|
+ chown -R $webServerUser:$webServerGroup /var/lib/php/
|
|
|
+ comprobarError $? 305
|
|
|
+ fi
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
+
|
|
|
unset phpConfFile phpDest
|
|
|
}
|
|
|
|
|
@@ -1434,7 +1491,6 @@ generarDHParam() {
|
|
|
# Esto aumenta notablemente la seguridad de SSL/TLS
|
|
|
sslDir="/etc/$webServerName/ssl"
|
|
|
dhParamFile="$sslDir/dhparam.pem"
|
|
|
-# apacheConfFile=""
|
|
|
nginxConfFile="/etc/$webServerName/nginx.conf"
|
|
|
if [ ! -d "$sslDir" ];then
|
|
|
mkdir "$sslDir" 2>/dev/null
|
|
@@ -1443,19 +1499,6 @@ generarDHParam() {
|
|
|
openssl dhparam -out "$dhParamFile" 2048 >/dev/null 2>&1
|
|
|
comprobarError $? 403
|
|
|
# Configuramos Servidor Web
|
|
|
-# if [ $apacheOn = true ];then
|
|
|
-# if [ $debianOS = true ];then
|
|
|
-# apacheConfFile="/etc/$webServerName/apache2.conf"
|
|
|
-# elif [ $rhelOS = true ];then
|
|
|
-# # La version de httpd de RHEL no acepta SSLOpenSSLConfCmd
|
|
|
-# # Solución: añadirlo al certificado
|
|
|
-# apacheConfFile="/etc/$webServerName/conf/httpd.conf"
|
|
|
-# else
|
|
|
-# comprobarError 1 403
|
|
|
-# fi
|
|
|
-# echo -en "\n# Set Stronger Diffie-Hellman key exchange\n" >> $apacheConfFile
|
|
|
-# echo -en "SSLOpenSSLConfCmd DHParameters \"$dhParamFile\"\n" >> $apacheConfFile
|
|
|
-# el
|
|
|
if [ $nginxOn = true ];then
|
|
|
sed -i '/ssl_param /c\\tssl_dhparam '$dhParamFile';' $nginxConfFile
|
|
|
comprobarError $? 403
|
|
@@ -1594,35 +1637,38 @@ configurarCortafuegos() {
|
|
|
# Configuramos cortafuegos (añadir reglas y encender)
|
|
|
# Comprobamos si estamos usando SSH
|
|
|
esSSH $PPID
|
|
|
- if [ $debianOS = true ];then
|
|
|
- ufw allow 80/tcp >> $logFile 2>&1
|
|
|
- comprobarError $? 906 "80/tcp"
|
|
|
- if [ $sshControl = true ];then
|
|
|
- ufw allow 22/tcp >> $logFile 2>&1
|
|
|
- comprobarError $? 906 "22/tcp"
|
|
|
- fi
|
|
|
- if [ $sslOn = true ];then
|
|
|
- ufw allow 443/tcp >> $logFile 2>&1
|
|
|
- comprobarError $? 906 "443/tcp"
|
|
|
- fi
|
|
|
- ufw --force enable >> $logFile 2>&1
|
|
|
- comprobarError $? 907
|
|
|
- elif [ $rhelOS = true ];then
|
|
|
- firewall-cmd --add-port=80/tcp >> $logFile 2>&1
|
|
|
- comprobarError $? 906 "80/tcp"
|
|
|
- if [ $sshControl = true ];then
|
|
|
- firewall-cmd --add-port=22/tcp >> $logFile 2>&1
|
|
|
- comprobarError $? 906 "22/tcp"
|
|
|
- fi
|
|
|
- if [ $sslOn = true ];then
|
|
|
- firewall-cmd --add-port=443/tcp >> $logFile 2>&1
|
|
|
- comprobarError $? 906 "443/tcp"
|
|
|
- fi
|
|
|
- firewall-cmd --runtime-to-permanent >> $logFile 2>&1
|
|
|
- comprobarError $? 907
|
|
|
- habilitarServicio firewalld >> $logFile 2>&1
|
|
|
- comprobarError $? 907
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ debian|ubuntu)
|
|
|
+ ufw allow 80/tcp >> $logFile 2>&1
|
|
|
+ comprobarError $? 906 "80/tcp"
|
|
|
+ if [ $sshControl = true ];then
|
|
|
+ ufw allow 22/tcp >> $logFile 2>&1
|
|
|
+ comprobarError $? 906 "22/tcp"
|
|
|
+ fi
|
|
|
+ if [ $sslOn = true ];then
|
|
|
+ ufw allow 443/tcp >> $logFile 2>&1
|
|
|
+ comprobarError $? 906 "443/tcp"
|
|
|
+ fi
|
|
|
+ ufw --force enable >> $logFile 2>&1
|
|
|
+ comprobarError $? 907
|
|
|
+ ;;
|
|
|
+ centos|fedora)
|
|
|
+ firewall-cmd --add-port=80/tcp >> $logFile 2>&1
|
|
|
+ comprobarError $? 906 "80/tcp"
|
|
|
+ if [ $sshControl = true ];then
|
|
|
+ firewall-cmd --add-port=22/tcp >> $logFile 2>&1
|
|
|
+ comprobarError $? 906 "22/tcp"
|
|
|
+ fi
|
|
|
+ if [ $sslOn = true ];then
|
|
|
+ firewall-cmd --add-port=443/tcp >> $logFile 2>&1
|
|
|
+ comprobarError $? 906 "443/tcp"
|
|
|
+ fi
|
|
|
+ firewall-cmd --runtime-to-permanent >> $logFile 2>&1
|
|
|
+ comprobarError $? 907
|
|
|
+ habilitarServicio firewalld >> $logFile 2>&1
|
|
|
+ comprobarError $? 907
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
unset sshControl
|
|
|
}
|
|
|
|
|
@@ -1738,21 +1784,16 @@ configurarMoodle() {
|
|
|
else
|
|
|
wwwroot="http://$dominioMoodle"
|
|
|
fi
|
|
|
- if [ $mySQLOn = true ];then
|
|
|
- dbtype="mysqli"
|
|
|
- elif [ $mariaDBOn = true ];then
|
|
|
- dbtype="mariadb"
|
|
|
- else
|
|
|
- comprobarError 1 602
|
|
|
- fi
|
|
|
- php /var/www/$dominioMoodle/admin/cli/install.php --lang=es --wwwroot="$wwwroot" --dataroot="/var/www/moodledata" --dbtype="$dbtype" --dbname="$nombreDBMo" --dbuser="$userDBMo" --dbpass="$sqlPasswd" --fullname="$nombreMoodle" --shortname="$nombreCortoMoodle" --adminuser=admin --adminpass="$passwdMoodle" --adminemail="admin@$dominioMoodle" --agree-license --non-interactive >>$logFile 2>&1
|
|
|
+ php /var/www/$dominioMoodle/admin/cli/install.php --lang=es --wwwroot="$wwwroot" --dataroot="/var/www/moodledata" --dbtype="$dbType" --dbname="$nombreDBMo" --dbuser="$userDBMo" --dbpass="$sqlPasswd" --fullname="$nombreMoodle" --shortname="$nombreCortoMoodle" --adminuser=admin --adminpass="$passwdMoodle" --adminemail="admin@$dominioMoodle" --agree-license --non-interactive >>$logFile 2>&1
|
|
|
comprobarError $? 602
|
|
|
# Actualizamos permisos
|
|
|
chown -R $webServerUser:$webServerGroup /var/www/$dominioMoodle /var/www/moodledata
|
|
|
# Configurar SE-Linux (RHEL)
|
|
|
- if [ $rhelOS = true ];then
|
|
|
- configurarSELinux
|
|
|
- fi
|
|
|
+ case $ID in
|
|
|
+ centos|fedora)
|
|
|
+ configurarSELinux
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
# Configuramos VirtualHost
|
|
|
if [ $apacheOn = true ] && [ $sslOn = false ];then
|
|
|
virtualHost="./etc/apache2/sites-available/moodle.conf"
|
|
@@ -1766,7 +1807,7 @@ configurarMoodle() {
|
|
|
comprobarError 1 602
|
|
|
fi
|
|
|
instalarVirtualHost "/var/www/$dominioMoodle" $virtualHost $dominioMoodle
|
|
|
- unset virtualHost wwwroot dbtype
|
|
|
+ unset virtualHost wwwroot
|
|
|
else
|
|
|
comprobarError 1 603 $dominioMoodle
|
|
|
fi
|