install 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. #!/bin/bash
  2. #################################################################
  3. # auto-mediawiki #
  4. # Instala un servidor LAMP (Linux+Apache+MySQL+PHP) e instala #
  5. # MediaWiki y lo configura. #
  6. # #
  7. # Guzman Castanedo Villalba (guzman@castanedo.es) Junio 2018 #
  8. # GPLv3 (https://www.gnu.org/licenses/gpl.html) #
  9. #################################################################
  10. comprobarError() {
  11. # comprobarError exitNum codeNum extraInfo
  12. # 1xx: Servidor Web
  13. # 2xx: Base de Datos
  14. # 3xx: PHP
  15. # 4xx: SSL/TLS
  16. # 5xx: MediaWiki
  17. # 6xx: Moodle
  18. # 7xx: Actualizaciones automáticas
  19. # 8xx: Dependencias
  20. # 9xx: Servicios & Firewall
  21. type="ERROR"
  22. exitNum=$1
  23. shift
  24. codeNum=$1
  25. shift
  26. extraInfo=$@
  27. case $codeNum in
  28. 1)
  29. error="$type $codeNum:\tInstalación interrumpida por el usuario.\n"
  30. ;;
  31. 2)
  32. error="$type $codeNum:\tError interno (selección express).\n"
  33. ;;
  34. 3)
  35. error="$type $codeNum:\tError interno (selección avanzada).\n"
  36. ;;
  37. 100)
  38. error="$type $codeNum:\tError interno (selección del servidor web).\n"
  39. ;;
  40. 101)
  41. error="\n$type $codeNum:\tError al instalar Apache2.\nDetalles:\n$extraInfo\n"
  42. ;;
  43. 102)
  44. error="\n$type $codeNum:\tError al instalar Nginx.\nDetalles:\n$extraInfo\n"
  45. ;;
  46. 103)
  47. error="\n$type $codeNum:\tError al nstalar repositorio 'epel-release'.\nDetalles:\n$extraInfo\n"
  48. ;;
  49. 104)
  50. error="\n$type $codeNum:\tError interno (instalación Apache2).\n"
  51. ;;
  52. 105)
  53. error="\n$type $codeNum:\tError interno (instalación Nginx).\n"
  54. ;;
  55. 106)
  56. type="WARNING"
  57. error="\n$type $codeNum:\tImposible instalar 'info.php'.\n"
  58. ;;
  59. 107)
  60. error="\n$type $codeNum:\tError al configurar Nginx.\n"
  61. ;;
  62. 200)
  63. error="$type $codeNum:\tError interno (selección de base de datos).\n"
  64. ;;
  65. 201)
  66. error="\n$type $codeNum:\tError al instalar MySQL.\nDetalles:\n$extraInfo\n"
  67. ;;
  68. 202)
  69. error="\n$type $codeNum:\tError al instalar MariaDB.\nDetalles:\n$extraInfo\n"
  70. ;;
  71. 203)
  72. error="\n$type $codeNum:\tError interno (instalación MySQL).\n"
  73. ;;
  74. 204)
  75. error="\n$type $codeNum:\tError interno (instalación MariaDB).\n"
  76. ;;
  77. 205)
  78. error="\n$type $codeNum:\t$DIST no incluye MySQL en sus repositorios.\n"
  79. ;;
  80. 206)
  81. type="WARNING"
  82. error="$type $codeNum:\tUsuario 'root' ya dispone de contraseña.\n"
  83. ;;
  84. 207)
  85. error="$type $codeNum:\tImposible cambiar la contraseña de 'root'.\n"
  86. ;;
  87. 208)
  88. error="$type $codeNum:\tImposible desactivar acceso 'root' desde el exterior.\n"
  89. ;;
  90. 209)
  91. error="$type $codeNum:\tImposible eliminar usuarios anónimos.\n"
  92. ;;
  93. 210)
  94. type="WARNING"
  95. error="$type $codeNum:\tImposible eliminar bases de datos de pruebas.\n"
  96. ;;
  97. 211)
  98. type="WARNING"
  99. error="$type $codeNum:\tImposible eliminar los permisos de las bases de datos de pruebas.\n"
  100. ;;
  101. 212)
  102. error="$type $codeNum:\tImposible recargar base de datos.\n"
  103. ;;
  104. 300)
  105. error="\n$type $codeNum:\tError interno (instalación PHP-7.2).\n"
  106. ;;
  107. 301)
  108. error="\n$type $codeNum:\tError interno (Web Server no seleccionado).\n"
  109. ;;
  110. 302)
  111. error="\n$type $codeNum:\tError al instalar PHP-7.2.\nDetalles:\n$extraInfo\n"
  112. ;;
  113. 303)
  114. error="\n$type $codeNum:\tError al instalar Repositorio Remi.\nDetalles:\n$extraInfo\n"
  115. ;;
  116. 304)
  117. error="\n$type $codeNum:\tSistema Operativo no compatible con PHP-7.2 ($OS $DIST $REV).\n"
  118. ;;
  119. 305)
  120. error="\n$type $codeNum:\tImposible configurar PHP-7.2.\n"
  121. ;;
  122. 800)
  123. error="$type $codeNum:\tEs necesario ser root ('sudo $0').\n"
  124. ;;
  125. 801)
  126. error="$type $codeNum:\t'whiptail' no instalado.\n"
  127. ;;
  128. 802)
  129. error="$type $codeNum:\t'hostnamectl' no instalado.\n"
  130. ;;
  131. 803)
  132. error="$type $codeNum:\t'apt-get' no instalado.\n"
  133. ;;
  134. 804)
  135. error="$type $codeNum:\t'yum' no instalado.\n"
  136. ;;
  137. 805)
  138. error="\n$type $codeNum:\tImposible actualizar repositorio\nDetalles:\n$extraInfo.\n"
  139. ;;
  140. 806)
  141. error="$type $codeNum:\t'ufw' no instalado.\n"
  142. ;;
  143. 807)
  144. error="$type $codeNum:\t'firewall-cmd' no instalado.\n"
  145. ;;
  146. 808)
  147. error="$type $codeNum:\t'tput' no instalado.\n"
  148. ;;
  149. 809)
  150. error="$type $codeNum:\t'sed' no instalado.\n"
  151. ;;
  152. 900)
  153. error="$type $codeNum:\tError interno (habilitar servicio).\n"
  154. ;;
  155. 901)
  156. error="$type $codeNum:\tImposible encender servicio '$extraInfo'.\n"
  157. ;;
  158. 902)
  159. error="$type $codeNum:\tImposible habilitar servicio '$extraInfo' durante el arranque.\n"
  160. ;;
  161. 903)
  162. error="$type $codeNum:\tError interno (deshabilitar servicio).\n"
  163. ;;
  164. 904)
  165. error="$type $codeNum:\tImposible parar servicio '$extraInfo'.\n"
  166. ;;
  167. 905)
  168. error="$type $codeNum:\tImposible deshabilitar servicio '$extraInfo' durante el arranque.\n"
  169. ;;
  170. 906)
  171. type="WARNING"
  172. error="\n$type $codeNum:\tImposible añadir regla al cortafuegos ('$extraInfo').\n"
  173. ;;
  174. 907)
  175. type="WARNING"
  176. error="\n$type $codeNum:\tImposible encender cortafuegos.\n"
  177. ;;
  178. *)
  179. error="ERROR 13:\tError interno (comprobación de errores)\n"
  180. exitNum=1
  181. codeNum=13
  182. ;;
  183. esac
  184. if [ $exitNum -ne 0 ];then
  185. echo -en "$error" | tee -a $logFile
  186. if [ $type = "ERROR" ];then
  187. exit $codeNum
  188. fi
  189. fi
  190. unset error exitNum codeNum type
  191. }
  192. OSInfo() {
  193. echo -en "Detectando SO..." >> $logFile
  194. OS=$(uname -s)
  195. if [ $OS = "Linux" ]; then
  196. OS="GNU/Linux"
  197. if [ -f /etc/os-release ]; then
  198. DIST=$(grep ^NAME= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
  199. REV=$(grep ^VERSION= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
  200. ID_LIKE=$(grep ^ID_LIKE= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
  201. VERSION=$(grep ^VERSION_ID= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
  202. for i in $ID_LIKE; do
  203. #echo -en "$i\n"
  204. case $i in
  205. debian|ubuntu)
  206. debianOS=true
  207. break
  208. ;;
  209. rhel|fedora)
  210. rhelOS=true
  211. break
  212. ;;
  213. *)
  214. debianOS=false
  215. rhelOS=false
  216. ;;
  217. esac
  218. done
  219. elif [ -f /etc/debian-version ]; then
  220. # Familia Debian (Debian, Ubuntu, Linux Mint, ...)
  221. DIST="Debian"
  222. REV=""
  223. ID_LIKE="debian"
  224. VERSION=""
  225. debianOS=true
  226. elif [ -f /etc/redhat-release ]; then
  227. # Familia Red-Hat (RHEL, Fedora, CentOS, ...)
  228. DIST="Red-Hat"
  229. REV=""
  230. ID_LIKE="rhel"
  231. VERSION=""
  232. rhelOS=true
  233. else
  234. # Other Linux (No Soportado)
  235. DIST=""
  236. REV=""
  237. ID_LIKE=""
  238. VERSION=""
  239. fi
  240. else
  241. # UNIX, OS X, ... (No Soportado)
  242. DIST=$OS
  243. REV=""
  244. ID_LIKE=""
  245. VERSION=""
  246. fi
  247. echo -en " $OS $DIST $REV\n" >> $logFile
  248. HDInfo=$(df -h | head -1)"\n"$(df -h | grep ^/dev/sd)"\n"$(df -h | grep ^/dev/mapper)
  249. echo -en "$HDInfo\n" >> $logFile
  250. }
  251. comprobarRoot() {
  252. comprobarError $(id -u) 800
  253. }
  254. comprobarDependencias() {
  255. # Comprobamos whiptail
  256. which whiptail > /dev/null 2>&1
  257. comprobarError $? 801
  258. # Comprobamos hostnamectl
  259. which hostnamectl > /dev/null 2>&1
  260. comprobarError $? 802
  261. # Comprobamos tput
  262. which tput > /dev/null 2>&1
  263. comprobarError $? 808
  264. # Comprobamso sed
  265. which sed > /dev/null 2>&1
  266. comprobarError $? 809
  267. if [ $debianOS = true ];then
  268. # Comprobamos apt-get
  269. which apt-get > /dev/null 2>&1
  270. comprobarError $? 803
  271. # Actualizamos base de datos del repositorio
  272. echo -en "Actualizando repositorio APT..." | tee -a $logFile
  273. result=$(apt-get -q -y update)
  274. comprobarError $? 805 $result
  275. echo -en " OK.\n" | tee -a $logFile
  276. # Comprobamos Firewall (ufw)
  277. which ufw > /dev/null 2>&1
  278. comprobarError $? 806
  279. fi
  280. if [ $rhelOS = true ]; then
  281. # Comprobamos yum
  282. which yum > /dev/null 2>&1
  283. comprobarError $? 804
  284. # Actualizamos base de datos del repositorio
  285. echo -en "Actualizando repositorio YUM..." | tee -a $logFile
  286. result=$(yum -y makecache 2>&1)
  287. comprobarError $? 805 $result
  288. echo -en " OK.\n" | tee -a $logFile
  289. # Comprobamos Firewall (firewall-cmd)
  290. which firewall-cmd > /dev/null 2>&1
  291. comprobarError $? 807
  292. fi
  293. }
  294. inicializarVariables() {
  295. debianOS=false
  296. rhelOS=false
  297. apacheOn=false
  298. nginxOn=false
  299. mySQLOn=false
  300. mariaDBOn=false
  301. phpOn=false
  302. sslOn=false
  303. mediaWikiOn=false
  304. moodleOn=false
  305. infoPHPOn=false
  306. actualizacionesOn=false
  307. progreso=0
  308. progresoTotal=0
  309. logFile="./."$(basename $0)".log"
  310. maxUpload="100M"
  311. }
  312. instalacionExpress() {
  313. apacheOn=true
  314. mariaDBOn=true
  315. phpOn=true
  316. sslOn=true
  317. mediaWikiOn=true
  318. moodleOn=true
  319. actualizacionesOn=true
  320. progresoTotal=15
  321. # Preguntas mínimas
  322. establecerFQDN
  323. leerSQLPasswd
  324. }
  325. mostrarBienvenida() {
  326. ANCHO=$(tput cols)
  327. ALTO=$(tput lines)
  328. if [ $debianOS = false ] && [ $rhelOS = false ]; then
  329. whiptail --title "ERROR S.O. NO SOPORTADO" --msgbox "Este script automatiza la creación de una web MediaWiki SOLO para distribuciones Linux de la familia Debian (Ubuntu, Linux Mint, ...) y de la familia Red-Hat (CentOS, Fedora, ...).\n\nInformación del sistema:\nOS: $OS $DIST $REV\n$HDInfo" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --ok-button "Salir"
  330. exit 1
  331. fi
  332. whiptail --title "INSTALACION MEDIAWIKI" --yesno "Este script automatiza completamente la instalación de una wiki.\nPara ello instala un servidor LAMP, el software MediaWiki y lo configura todo.\n\nInformación del sistema:\nOS: $OS $DIST $REV\n$HDInfo" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --yes-button "Continuar" --no-button "Salir"
  333. comprobarError $? 1
  334. }
  335. mostrarExpress() {
  336. express=$(whiptail --title "INSTALACION EXPRESS" --radiolist "<ESPACIO>: seleccionar <TAB>: cambiar <FLECHAS>: moverse\n\nLa instalación express instala Apache2, MariaDB, PHP-7, Let's Encrypt, MediaWiki, Moodle y actualizaciones automáticas.\nSeleccione el tipo de instalación que desee:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 2 \
  337. "Express" "Instalación rápida" ON \
  338. "Avanzada" "Permite escoger todas las opciones disponibles" OFF \
  339. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  340. comprobarError $? 1
  341. case $express in
  342. Express)
  343. instalacionExpress
  344. # DECIDIR QUÉ OPCIONES SON LAS MÍNIMAS
  345. ;;
  346. Avanzada)
  347. mostrarAvanzada
  348. ;;
  349. *)
  350. comprobarError 1 2
  351. ;;
  352. esac
  353. }
  354. mostrarAvanzada() {
  355. webServer=$(whiptail --title "INSTALACION AVANZADA" --radiolist "<ESPACIO>: seleccionar <TAB>: cambiar <FLECHAS>: moverse\n\nEscoge el tipo de Servidor Web que quieres instalar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 2 \
  356. "LAMP" "GNU/Linux + Apache + MySQL/MariaDB + PHP-7" ON \
  357. "LEMP" "GNU/Linux + Nginx + MySQL/MariaDB + PHP-7" OFF \
  358. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  359. comprobarError $? 1
  360. for i in $webServer; do
  361. case $i in
  362. LAMP)
  363. apacheOn=true
  364. ;;
  365. LEMP)
  366. nginxOn=true
  367. ;;
  368. *)
  369. comprobarError 1 100
  370. ;;
  371. esac
  372. done
  373. # Opciones comunes
  374. establecerFQDN
  375. mostrarDatabase
  376. phpOn=true
  377. establecerMaxUpload
  378. progresoTotal=$((progresoTotal + 6))
  379. mostrarComponentes
  380. }
  381. mostrarComponentes() {
  382. componentes=$(whiptail --title "INSTALACION AVANZADA" --checklist "<ESPACIO>: seleccionar <TAB>: cambiar <FLECHAS>: moverse\n\nEscoge los componentes que quieres instalar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 5 \
  383. "SSL/TLS" "Instalar certificados para activar HTTPS" ON \
  384. "MediaWiki" "Instalar wiki con MediaWiki" ON \
  385. "Moodle" "Instalar campus virtual con Moodle" ON \
  386. "InfoPHP" "Instalar info.php (sólo para pruebas)" OFF \
  387. "Actualizaciones" "Programar actualizaciones automáticas" ON \
  388. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  389. comprobarError $? 1
  390. # Mejora: autodetección de componentes ya instalados
  391. for i in $componentes; do
  392. case $i in
  393. \"SSL/TLS\")
  394. # 2 Opciones: Let's Encrypt o Autofirmado
  395. sslOn=true
  396. progresoTotal=$((progresoTotal + 2))
  397. ;;
  398. \"MediaWiki\")
  399. mediaWikiOn=true
  400. progresoTotal=$((progresoTotal + 2))
  401. ;;
  402. \"Moodle\")
  403. moodleOn=true
  404. progresoTotal=$((progresoTotal + 2))
  405. ;;
  406. \"InfoPHP\")
  407. infoPHPOn=true
  408. progresoTotal=$((progresoTotal + 2))
  409. ;;
  410. \"Actualizaciones\")
  411. actualizacionesOn=true
  412. progresoTotal=$((progresoTotal + 1))
  413. ;;
  414. *)
  415. comprobarError 1 3
  416. ;;
  417. esac
  418. done
  419. progresoTotal=$((progresoTotal + 2))
  420. }
  421. establecerFQDN() {
  422. while [ -z $hostname ]; do
  423. hostname=$(whiptail --title "FQDN" --inputbox "El nombre de dominio principal (FQDN) de este servidor es:\n"$(hostname)"\n\nQuieres cambiarlo por otro?" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --ok-button "Cambiar" --cancel-button "No Cambiar" 3>&1 1>&2 2>&3)
  424. if [ $? -eq 0 ] && [ ! -z $hostname ]; then
  425. hostnamectl set-hostname $hostname
  426. else
  427. hostname=$(hostname)
  428. fi
  429. done
  430. echo -en "Hostname: $hostname\n" >> $logFile
  431. }
  432. instalarApache() {
  433. if [ $debianOS = true ];then
  434. result=$(apt-get -q -y install apache2 2>&1)
  435. comprobarError $? 101 $result
  436. elif [ $rhelOS = true ]; then
  437. result=$(yum -y install httpd 2>&1)
  438. comprobarError $? 101 $result
  439. else
  440. comprobarError 1 104
  441. fi
  442. }
  443. instalarNginx() {
  444. if [ $debianOS = true ];then
  445. result=$(apt-get -q -y install nginx 2>&1)
  446. comprobarError $? 102 $result
  447. elif [ $rhelOS = true ]; then
  448. # Hay que instalar primero otro repositorio
  449. result=$(yum -y install epel-release)
  450. comprobarError $? 103 $result
  451. result=$(yum -y install nginx 2>&1)
  452. comprobarError $? 102 $result
  453. else
  454. comprobarError 1 105
  455. fi
  456. }
  457. configurarNginx() {
  458. # Configuramos Nginx
  459. rm -Rf /etc/nginx/* 2>/dev/null
  460. comprobarError $? 107
  461. if [ $debianOS = true ];then
  462. nginxConfFile="./etc/nginx-debian/*"
  463. elif [ $rhelOS = true ];then
  464. nginxConfFile="./etc/nginx-rhel/*"
  465. fi
  466. if [ ! -d $nginxConfFile ];then
  467. comprobarError 1 107
  468. fi
  469. cp -R $nginxConfFile /etc/nginx/ 2>/dev/null
  470. comprobarError $? 107
  471. unset nginxConfFile
  472. }
  473. mostrarDatabase() {
  474. if [ $debianOS = true ]; then
  475. 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 \
  476. "MariaDB" "Instalar la base de datos MariaDB (fork de MySQL)" ON \
  477. "MySQL" "Instalar la base de datos MySQL (no para uso comercial)" OFF \
  478. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  479. comprobarError $? 1
  480. case $database in
  481. MariaDB)
  482. mariaDBOn=true
  483. ;;
  484. MySQL)
  485. mySQLOn=true
  486. ;;
  487. *)
  488. comprobarError 1 200
  489. ;;
  490. esac
  491. elif [ $rhelOS = true ]; then
  492. 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"
  493. comprobarError $? 1
  494. mariaDBOn=true
  495. else
  496. comprobarError 1 200
  497. fi
  498. # Otras opciones (contraseña)
  499. leerSQLPasswd
  500. }
  501. leerSQLPasswd() {
  502. control=false
  503. error=""
  504. # Leemos la contreseña (stdin) y confirmamos
  505. while [ $control = false ]; do
  506. sqlPasswd=$(whiptail --title "CONTRASEÑA SQL" --passwordbox "$error""Introduzca la contraseña para el usuario 'root' de la base de datos:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --ok-button "Continuar" --nocancel 3>&1 1>&2 2>&3)
  507. comprobarError $? 1
  508. 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)
  509. comprobarError $? 1
  510. #echo -en "SQL Password 1: $sqlPasswd\n"
  511. #echo -en "SQL Password 2: $sqlPasswd2\n"
  512. if [ -z $sqlPasswd ] || [ -z $sqlPasswd2 ]; then
  513. error="ERROR: LA CONTRASEÑA NO PUEDE ESTAR VACIA.\n"
  514. elif [ $sqlPasswd != $sqlPasswd2 ];then
  515. error="ERROR: LAS CONTRASEÑAS NO COINCIDEN.\n"
  516. else
  517. control=true
  518. fi
  519. done
  520. #echo -en "SQL Password: $sqlPasswd\n"
  521. unset control error sqlPasswd2
  522. }
  523. establecerSQLPasswd() {
  524. # Establecemos SQL root passwd y securizamos BD (mysql_secure_installation)
  525. # Comprobamos si ya tiene una contraseña asignada
  526. mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
  527. if [ $? -eq 0 ];then
  528. # Establecemos contraseña del usuario root
  529. mysql -e "UPDATE mysql.user SET Password = PASSWORD('$sqlPasswd') WHERE User = 'root'" >> $logFile 2>&1
  530. comprobarError $? 207
  531. # Desactivamos acceso root desde el exterior (solo localhost)
  532. mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" >> $logFile 2>&1
  533. comprobarError $? 208
  534. # Eliminamos todos los usuarios anónimos
  535. mysql -e "DELETE FROM mysql.user WHERE User=''" >> $logFile 2>&1
  536. comprobarError $? 209
  537. # Eliminamos bases de datos 'test'
  538. mysql -e "DROP DATABASE IF EXISTS test" >> $logFile 2>&1
  539. comprobarError $? 210
  540. # Eliminamos privilegios de la base de datos 'test'
  541. mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'" >> $logFile 2>&1
  542. comprobarError $? 211
  543. # Aplicamos los cambios
  544. mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
  545. comprobarError $? 212
  546. else
  547. comprobarError 1 206
  548. fi
  549. }
  550. instalarMySQL() {
  551. if [ $debianOS = true ];then
  552. result=$(apt-get -q -y install mysql-server mysql-client 2>&1)
  553. comprobarError $? 201 $result
  554. elif [ $rhelOS = true ];then
  555. # MySQL no disponible en RHEL. 2 opciones:
  556. # 1) Instalar un repositorio adicional
  557. # 2) No instalar MySQL en distribuciones RHEL
  558. comprobarError 1 205
  559. else
  560. comprobarError 1 203
  561. fi
  562. }
  563. instalarMariaDB() {
  564. if [ $debianOS = true ];then
  565. result=$(apt-get -q -y install mariadb-server mariadb-client 2>&1)
  566. comprobarError $? 202 $result
  567. elif [ $rhelOS = true ];then
  568. result=$(yum -y install mariadb-server mariadb 2>&1)
  569. comprobarError $? 202 $result
  570. else
  571. comprobarError 1 204
  572. fi
  573. }
  574. instalarPHP() {
  575. # Instalamos PHP-7 de forma diferente si es junto a Apache o con Nginx
  576. if [ $debianOS = true ];then
  577. if [ $apacheOn = true ]; then
  578. result=$(apt-get -q -y install php libapache2-mod-php php-mysql php-intl php-mbstring openssl 2>&1)
  579. comprobarError $? 302 $result
  580. elif [ $nginxOn = true ];then
  581. result=$(apt-get -q -y install php-fpm libapache2-mod-php php-mysql php-intl php-mbstring openssl 2>&1)
  582. comprobarError $? 302 $result
  583. else
  584. comprobarError 1 301
  585. fi
  586. elif [ $rhelOS = true ];then
  587. # Necesitamos un repositorio adicional para PHP-7 (EPEL-RELEASE)
  588. result=$(yum -y install epel-release yum-utils 2>&1)
  589. comprobarError $? 103 $result
  590. # Necesitamos un repositorio adicional para PHP-7 (REMI-RELEASE)
  591. if [ ! -f /etc/yum.repos.d/remi-php72.repo ];then
  592. if [ $VERSION = "7" ];then
  593. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-7.rpm 2>&1)
  594. comprobarError $? 303 $result
  595. elif [ $VERSION = "6" ];then
  596. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-6.rpm 2>&1)
  597. comprobarError $? 303 $result
  598. elif [ $VERSION = "28" ];then
  599. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-28.rpm 2>&1)
  600. comprobarError $? 303 $result
  601. elif [ $VERSION = "27" ];then
  602. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-27.rpm 2>&1)
  603. comprobarError $? 303 $result
  604. else
  605. comprobarError 1 304
  606. fi
  607. fi
  608. # Activamos repositorio remi-php72
  609. result=$(yum-config-manager --enable remi-php72 2>&1)
  610. comprobarError $? 303 $result
  611. # Instalamos PHP-7.2
  612. if [ $apacheOn = true ];then
  613. result=$(yum -y install php php-mysql php-intl php-mbstring php-mcrypt openssl 2>&1)
  614. comprobarError $? 302 $result
  615. elif [ $nginxOn = true ];then
  616. result=$(yum -y install php php-fpm php-mysql php-intl php-mbstring php-mcrypt openssl 2>&1)
  617. comprobarError $? 302 $result
  618. else
  619. comprobarError 1 301
  620. fi
  621. else
  622. comprobarError 1 300
  623. fi
  624. }
  625. configurarPHP() {
  626. # Configura PHP para segurizarlo y establecer máximo de subida.
  627. if [ $debianOS = true ];then
  628. phpConfFile="./etc/php/php.ini.debian"
  629. phpDest="/etc/php/7.2/cli/php.ini"
  630. elif [ $rhelOS = true ];then
  631. phpConfFile="./etc/php/php.ini.rhel"
  632. phpDest="/etc/php.ini"
  633. fi
  634. if [ ! -f $phpConfFile ];then
  635. comprobarError 1 305
  636. fi
  637. # Copiamos configuración
  638. cp $phpConfFile $phpDest 2>/dev/null
  639. comprobarError $? 305
  640. # Configuramos cgi.fix_pathinfo
  641. sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=0' $phpDest
  642. comprobarError $? 305
  643. # Configuramos post_max_size
  644. sed -i '/post_max_size =/c\post_max_size = '$maxUpload $phpDest
  645. comprobarError $? 305
  646. # Configuramos upload_max_filesize
  647. sed -i '/upload_max_filesize =/c\upload_max_filesize = '$maxUpload $phpDest
  648. comprobarError $? 305
  649. # Configurar php-fpm (sólo en RHEL con Nginx)
  650. if [ $rhelOS = true ] && [ $nginxOn = true ];then
  651. phpConfFile="./etc/php/php-fpm.d/www.conf"
  652. phpDest="/etc/php-fpm.d/www.conf"
  653. if [ ! -f $phpConfFile ];then
  654. comprobarError $? 305
  655. fi
  656. cp $phpConfFile $phpDest 2>/dev/null
  657. comprobarError $? 305
  658. fi
  659. unset phpConfFile phpDest
  660. }
  661. establecerMaxUpload() {
  662. control=false
  663. error=""
  664. while [ $control = false ];do
  665. maxUpload2=$(whiptail --title "PHP MAX UPLOAD" --inputbox "$error""Introduzca el tamaño máximo permitido de los ficheros subidos al servidor:\n(<K:Kilobyte> <M:Megabyte> <G:Gigabyte>)" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) $maxUpload --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  666. comprobarError $? 1
  667. if [ -z $maxUpload2 ];then
  668. error="ERROR: NO PUEDES DEJAR ESTE PARÁMETRO VACIO.\n"
  669. else
  670. control=true
  671. fi
  672. done
  673. maxUpload=$maxUpload2
  674. unset control maxUpload2
  675. }
  676. instalarPHPInfo() {
  677. infoFile="./var/www/info.php"
  678. if [ ! -f $infoFile ];then
  679. comprobarError 1 106
  680. fi
  681. cp $infoFile /var/www/html/ 2>/dev/null
  682. comprobarError $? 106
  683. unset infoFile
  684. }
  685. habilitarServicio() {
  686. # Arrancamos y habilitamos el servicio (con SystemD, Upstart o SystemV)
  687. # Intentamos con systemctl (SystemD)
  688. echo -en "Habilitando servicio $1" | tee -a $logFile
  689. if [ $# -le 0 ];then
  690. comprobarError 1 900
  691. fi
  692. which systemctl > /dev/null 2>&1
  693. if [ $? -eq 0 ]; then
  694. echo -en " (SystemD)..." | tee -a $logFile
  695. systemctl start $1 > /dev/null 2>&1
  696. comprobarError $? 901 $1
  697. systemctl enable $1 > /dev/null 2>&1
  698. comprobarError $? 902 $1
  699. else
  700. # Intentamos con service (Upstart)
  701. which service > /dev/null 2>&1
  702. if [ $? -eq 0 ]; then
  703. echo -en " (Upstart)..." | tee -a $logFile
  704. service $1 start > /dev/null 2>&1
  705. comprobarError $? 901 $1
  706. else
  707. # Intentamos con init.d (SystemV)
  708. echo -en " (SystemV)..." | tee -a $logFile
  709. /etc/init.d/$1 start > /dev/null 2>&1
  710. comprobarError $? 901 $1
  711. fi
  712. # Intentamos habilitar en el arranque (Upstart)
  713. which update-rc.d > /dev/null 2>&1
  714. if [ $? -eq 0 ];then
  715. update-rc.d $1 enable
  716. comprobarError $? 902 $1
  717. else
  718. # Intentamos habilitar en el arranque (SystemV)
  719. which chkconfig > /dev/null 2>&1
  720. if [ $? -eq 0 ];then
  721. chkconfig $1 on
  722. comprobarError $? 902 $1
  723. else
  724. # ¿Qué mas opciones nos quedan?
  725. comprobarError 1 902 $1
  726. fi
  727. fi
  728. fi
  729. # Mejora: comprobar si el servicio está funcionando
  730. echo -en " OK.\n" | tee -a $logFile
  731. }
  732. deshabilitarServicio() {
  733. # Paramos y deshabilitamos el servicio (con SystemD, Upstart o SystemV)
  734. # Intentamos con systemctl (SystemD)
  735. echo -en "Deshabilitando servicio $1" | tee -a $logFile
  736. if [ $# -le 0 ];then
  737. comprobarError 1 903
  738. fi
  739. which systemctl > /dev/null 2>&1
  740. if [ $? -eq 0 ]; then
  741. echo -en " (SystemD)..." | tee -a $logFile
  742. systemctl stop $1 > /dev/null 2>&1
  743. comprobarError $? 904 $1
  744. systemctl disable $1 > /dev/null 2>&1
  745. comprobarError $? 905 $1
  746. else
  747. # Intentamos con service (Upstart)
  748. which service > /dev/null 2>&1
  749. if [ $? -eq 0 ]; then
  750. echo -en " (Upstart)..." | tee -a $logFile
  751. service $1 stop > /dev/null 2>&1
  752. comprobarError $? 904 $1
  753. else
  754. # Intentamos con init.d (SystemV)
  755. echo -en " (SystemV)..." | tee -a $logFile
  756. /etc/init.d/$1 stop > /dev/null 2>&1
  757. comprobarError $? 904 $1
  758. fi
  759. # Intentamos habilitar en el arranque (Upstart)
  760. which update-rc.d > /dev/null 2>&1
  761. if [ $? -eq 0 ];then
  762. update-rc.d $1 disable
  763. comprobarError $? 905 $1
  764. else
  765. # Intentamos habilitar en el arranque (SystemV)
  766. which chkconfig > /dev/null 2>&1
  767. if [ $? -eq 0 ];then
  768. chkconfig $1 off
  769. comprobarError $? 905 $1
  770. else
  771. # ¿Qué mas opciones nos quedan?
  772. comprobarError 1 905 $1
  773. fi
  774. fi
  775. fi
  776. # Mejora: comprobar si el servicio está funcionando
  777. echo -en " OK.\n" | tee -a $logFile
  778. }
  779. configurarCortafuegos() {
  780. # Configuramos cortafuegos (añadir reglas y encender)
  781. # Comprobamos si estamos usando SSH
  782. esSSH $PPID
  783. if [ $debianOS = true ];then
  784. ufw allow 80/tcp 2>&1 >> $logFile
  785. comprobarError $? 906 "80/tcp"
  786. if [ $sshControl = true ];then
  787. ufw allow 22/tcp 2>&1 >> $logFile
  788. comprobarError $? 906 "22/tcp"
  789. fi
  790. if [ $sslOn = true ];then
  791. ufw allow 443/tcp 2>&1 >> $logFile
  792. comprobarError $? 906 "443/tcp"
  793. fi
  794. ufw --force enable 2>&1 >> $logFile
  795. comprobarError $= 907
  796. elif [ $rhelOS = true ];then
  797. firewall-cmd --add-port=80/tcp 2>&1 >> $logFile
  798. comprobarError $? 906 "80/tcp"
  799. if [ $sshControl = true ];then
  800. firewall-cmd --add-port=22/tcp 2>&1 >> $logFile
  801. comprobarError $? 906 "22/tcp"
  802. fi
  803. if [ $sslOn = true ];then
  804. firewall-cmd --add-port=443/tcp 2>&1 >> $logFile
  805. comprobarError $? 906 "443/tcp"
  806. fi
  807. firewall-cmd --runtime-to-permanent 2>&1 >> $logFile
  808. comprobarError $? 907
  809. habilitarServicio firewalld 2>&1 >> $logFile
  810. comprobarError $? 907
  811. fi
  812. unset sshControl
  813. }
  814. esSSH() {
  815. p=${1:-$PPID}
  816. #read pid name x ppid y < <( cat /proc/$p/stat )
  817. read pid name ppid < <( ps -o pid= -o comm= -o ppid= -p $p)
  818. [[ "$name" =~ sshd ]] && { sshControl=true; return 0; }
  819. [ "$ppid" -le 1 ] && { sshControl=false; return 1; }
  820. esSSH $ppid
  821. }
  822. # Comprobación del sistema e inicialización
  823. inicializarVariables
  824. comprobarRoot
  825. OSInfo
  826. comprobarDependencias
  827. # Bienvenida
  828. mostrarBienvenida
  829. # Selección de componentes (express vs avanzada)
  830. mostrarExpress
  831. # Pre-configuración
  832. # Habilitar cortafuegos -> PROBLEMA: se corta la conexión ssh
  833. # Instalación
  834. # FALTA: whiptail --gauge -> Más bonito
  835. # Servidor Web
  836. if [ $apacheOn = true ]; then
  837. echo -en "Instalando Web Server Apache..." | tee -a $logFile
  838. # {
  839. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  840. instalarApache
  841. progreso=$((progreso + 1))
  842. # } > >(whiptail --gauge "Instalando Web Server Apache..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  843. echo -en " OK.\n" | tee -a $logFile
  844. elif [ $nginxOn = true ]; then
  845. echo -en "Instalando Web Server Nginx..." | tee -a $logFile
  846. # {
  847. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  848. instalarNginx
  849. progreso=$((progreso + 1))
  850. # } > >(whiptail --gauge "Instalando Web Server Nginx..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  851. echo -en " OK.\n" | tee -a $logFile
  852. fi
  853. # Base de Datos
  854. if [ $mySQLOn = true ]; then
  855. echo -en "Instalando Base de Datos MySQL..." | tee -a $logFile
  856. # {
  857. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  858. instalarMySQL
  859. progreso=$((progreso + 1))
  860. # } > >(whiptail --gauge "Instalando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  861. echo -en " OK.\n" | tee -a $logFile
  862. elif [ $mariaDBOn = true ]; then
  863. echo -en "Instalando Base de Datos MariaDB..." | tee -a $logFile
  864. # {
  865. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  866. instalarMariaDB
  867. progreso=$((progreso + 1))
  868. # } > >(whiptail --gauge "Instalando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  869. echo -en " OK.\n" | tee -a $logFile
  870. fi
  871. # PHP
  872. if [ $phpOn = true ]; then
  873. echo -en "Instalando PHP-7..." | tee -a $logFile
  874. # {
  875. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  876. instalarPHP
  877. progreso=$((progreso + 1))
  878. # } > >(whiptail --gauge "Instalando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  879. echo -en " OK.\n" | tee -a $logFile
  880. fi
  881. # SSL/TLS
  882. # Falta por implementar
  883. # {
  884. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  885. sleep 2
  886. progreso=$((progreso + 1))
  887. # } > >(whiptail --gauge "Instalando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  888. # MediaWiki
  889. if [ $mediaWikiOn = true ]; then
  890. echo -en "Instalando MediaWiki..." | tee -a $logFile
  891. # {
  892. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  893. sleep 2
  894. progreso=$((progreso + 1))
  895. # } > >(whiptail --gauge "Instalando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  896. echo -en " OK.\n" | tee -a $logFile
  897. fi
  898. # Moodle
  899. if [ $moodleOn = true ]; then
  900. echo -en "Instalando Moodle..." | tee -a $logFile
  901. # {
  902. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  903. sleep 2
  904. progreso=$((progreso + 1))
  905. # } > >(whiptail --gauge "Instalando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  906. echo -en " OK.\n" | tee -a $logFile
  907. fi
  908. # PRECAUCION!!!! Hay que habilitar algunos servicios antes de configurarlos
  909. # Por ejemplo: para cambiar la contraseña de root en mysql
  910. # Configuración
  911. # Configuración Apache
  912. # Virtual Hosts
  913. if [ $nginxOn = true ]; then
  914. echo -en "Configurando Servidor Web Nginx..." | tee -a $logFile
  915. # {
  916. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  917. configurarNginx
  918. progreso=$((progreso + 1))
  919. # } > >(whiptail --gauge "Configurando Servidor Web..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  920. echo -en " OK.\n" | tee -a $logFile
  921. fi
  922. # Instalar info.php
  923. if [ $infoPHPOn = true ];then
  924. echo -en "Configurando 'info.php'..." | tee -a $logFile
  925. instalarPHPInfo
  926. echo -en " OK.\n" | tee -a $logFile
  927. fi
  928. # Configuración Database
  929. # Arrancar Base de Datos, establecer contraseña y configuración segura
  930. if [ $mySQLOn = true ];then
  931. habilitarServicio mysql
  932. echo -en "Configurando Base de Datos MySQL..." | tee -a $logFile
  933. # {
  934. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  935. establecerSQLPasswd
  936. progreso=$((progreso + 1))
  937. # } > >(whiptail --gauge "Configurando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  938. echo -en " OK.\n" | tee -a $logFile
  939. fi
  940. if [ $mariaDBOn = true ];then
  941. habilitarServicio mariadb
  942. echo -en "Configurando Base de Datos MariaDB..." | tee -a $logFile
  943. # {
  944. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  945. establecerSQLPasswd
  946. progreso=$((progreso + 1))
  947. # } > >(whiptail --gauge "Configurando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  948. echo -en " OK.\n" | tee -a $logFile
  949. fi
  950. # Configuración PHP
  951. # cgi.fix_pathinfo=0
  952. # Configurar máximo de subida de archivos
  953. if [ $phpOn = true ];then
  954. echo -en "Configurando PHP-7..." | tee -a $logFile
  955. # {
  956. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  957. configurarPHP
  958. progreso=$((progreso + 1))
  959. # } > >(whiptail --gauge "Configurando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  960. echo -en " OK.\n" | tee -a $logFile
  961. fi
  962. # Configuración MediWiki
  963. echo -en "Configurando MediaWiki..." | tee -a $logFile
  964. # {
  965. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  966. sleep 2
  967. progreso=$((progreso + 1))
  968. # } > >(whiptail --gauge "Configurando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  969. echo -en " OK.\n" | tee -a $logFile
  970. # Configuración Moodle
  971. echo -en "Configurando Moodle..." | tee -a $logFile
  972. # {
  973. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  974. sleep 2
  975. progreso=$((progreso + 1))
  976. # } > >(whiptail --gauge "Configurando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  977. echo -en " OK.\n" | tee -a $logFile
  978. # Arrancar y habilitar todos los servicios (SystemD, Service o SystemV)
  979. # {
  980. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  981. if [ $apacheOn = true ];then
  982. if [ $debianOS = true ];then
  983. habilitarServicio apache2
  984. elif [ $rhelOS = true ];then
  985. habilitarServicio httpd
  986. fi
  987. elif [ $nginxOn = true ];then
  988. habilitarServicio nginx
  989. if [ $phpOn = true ];then
  990. if [ $debianOS = true ];then
  991. habilitarServicio php7.2-fpm
  992. elif [ $rhelOS = true ];then
  993. habilitarServicio php-fpm
  994. fi
  995. fi
  996. fi
  997. progreso=$((progreso + 1))
  998. # } > >(whiptail --gauge "Arrancando Servicios..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  999. # Añadir reglas del cortafuegos
  1000. echo -en "Configurando Cortafuegos..." | tee -a $logFile
  1001. # {
  1002. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1003. sleep 2
  1004. progreso=$((progreso + 1))
  1005. # } > >(whiptail --gauge "Configurando Cortafuegos..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1006. echo -en " OK.\n" | tee -a $logFile
  1007. # Configuración SSL/TLS
  1008. # Generar certificados
  1009. # Configurar certificados
  1010. echo -en "Configurando SSL/TLS..." | tee -a $logFile
  1011. # {
  1012. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1013. sleep 2
  1014. progreso=$((progreso + 1))
  1015. # } > >(whiptail --gauge "Configurando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1016. echo -en " OK.\n" | tee -a $logFile
  1017. # Configurar actualizaciones
  1018. if [ $actualizacionesOn = true ]; then
  1019. echo -en "Configurando actualizaciones automáticas..." | tee -a $logFile
  1020. # {
  1021. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1022. sleep 2
  1023. progreso=$((progreso + 1))
  1024. # } > >(whiptail --gauge "Configurando actualizaciones automáticas..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1025. echo -en " OK.\n" | tee -a $logFile
  1026. fi