install 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  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)
  589. comprobarError $? 103 $result
  590. # Necesitamos un repositorio adicional para PHP-7 (REMI-RELEASE)
  591. if [ $VERSION = "7" ];then
  592. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-7.rpm 2>&1)
  593. comprobarError $? 303 $result
  594. elif [ $VERSION = "6" ];then
  595. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-6.rpm 2>&1)
  596. comprobarError $? 303 $result
  597. elif [ $VERSION = "28" ];then
  598. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-28.rpm 2>&1)
  599. comprobarError $? 303 $result
  600. elif [ $VERSION = "27" ];then
  601. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-27.rpm 2>&1)
  602. comprobarError $? 303 $result
  603. else
  604. comprobarError 1 304
  605. fi
  606. # Activamos repositorio remi-php72
  607. result=$(yum-config-manager --enable remi-php72 2>&1)
  608. comprobarError $? 303 $result
  609. # Instalamos PHP-7.2
  610. if [ $apacheOn = true ];then
  611. result=$(yum -y install php php-mysql php-intl php-mbstring php-mcrypt openssl 2>&1)
  612. comprobarError $? 302 $result
  613. elif [ $nginxOn = true ];then
  614. result=$(yum -y install php php-fpm php-mysql php-intl php-mbstring php-mcrypt openssl 2>&1)
  615. comprobarError $? 302 $result
  616. else
  617. comprobarError 1 301
  618. fi
  619. else
  620. comprobarError 1 300
  621. fi
  622. }
  623. configurarPHP() {
  624. # Configura PHP para segurizarlo y establecer máximo de subida.
  625. if [ $debianOS = true ];then
  626. phpConfFile="./etc/php/php.ini.debian"
  627. phpDest="/etc/php/7.2/cli/php.ini"
  628. elif [ $rhelOS = true ];then
  629. phpConfFile="./etc/php/php.ini.rhel"
  630. phpDest="/etc/php.ini"
  631. fi
  632. if [ ! -f $phpConfFile ];then
  633. comprobarError 1 305
  634. fi
  635. # Copiamos configuración
  636. cp $phpConfFile $phpDest 2>/dev/null
  637. comprobarError $? 305
  638. # Configuramos cgi.fix_pathinfo
  639. sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=0' $phpDest
  640. comprobarError $? 305
  641. # Configuramos post_max_size
  642. sed -i '/post_max_size =/c\post_max_size = '$maxUpload $phpDest
  643. comprobarError $? 305
  644. # Configuramos upload_max_filesize
  645. sed -i '/upload_max_filesize =/c\upload_max_filesize = '$maxUpload $phpDest
  646. comprobarError $? 305
  647. # Configurar php-fpm (sólo en RHEL con Nginx)
  648. if [ $rhelOS = true ] && [ $nginxOn = true ];then
  649. phpConfFile="./etc/php/php-fpm.d/www.conf"
  650. phpDest="/etc/php-fpm.d/www.conf"
  651. if [ ! -f $phpConfFile ];then
  652. comprobarError $? 305
  653. fi
  654. cp $phpConfFile $phpDest 2>/dev/null
  655. comprobarError $? 305
  656. fi
  657. unset phpConfFile phpDest
  658. }
  659. establecerMaxUpload() {
  660. control=false
  661. error=""
  662. while [ $control = false ];do
  663. 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)
  664. comprobarError $? 1
  665. if [ -z $maxUpload2 ];then
  666. error="ERROR: NO PUEDES DEJAR ESTE PARÁMETRO VACIO.\n"
  667. else
  668. control=true
  669. fi
  670. done
  671. maxUpload=$maxUpload2
  672. unset control maxUpload2
  673. }
  674. instalarPHPInfo() {
  675. infoFile="./var/www/info.php"
  676. if [ ! -f $infoFile ];then
  677. comprobarError 1 106
  678. fi
  679. cp $infoFile /var/www/html/ 2>/dev/null
  680. comprobarError $? 106
  681. unset infoFile
  682. }
  683. habilitarServicio() {
  684. # Arrancamos y habilitamos el servicio (con SystemD, Upstart o SystemV)
  685. # Intentamos con systemctl (SystemD)
  686. echo -en "Habilitando servicio $1" | tee -a $logFile
  687. if [ $# -le 0 ];then
  688. comprobarError 1 900
  689. fi
  690. which systemctl > /dev/null 2>&1
  691. if [ $? -eq 0 ]; then
  692. echo -en " (SystemD)..." | tee -a $logFile
  693. systemctl start $1 > /dev/null 2>&1
  694. comprobarError $? 901 $1
  695. systemctl enable $1 > /dev/null 2>&1
  696. comprobarError $? 902 $1
  697. else
  698. # Intentamos con service (Upstart)
  699. which service > /dev/null 2>&1
  700. if [ $? -eq 0 ]; then
  701. echo -en " (Upstart)..." | tee -a $logFile
  702. service $1 start > /dev/null 2>&1
  703. comprobarError $? 901 $1
  704. else
  705. # Intentamos con init.d (SystemV)
  706. echo -en " (SystemV)..." | tee -a $logFile
  707. /etc/init.d/$1 start > /dev/null 2>&1
  708. comprobarError $? 901 $1
  709. fi
  710. # Intentamos habilitar en el arranque (Upstart)
  711. which update-rc.d > /dev/null 2>&1
  712. if [ $? -eq 0 ];then
  713. update-rc.d $1 enable
  714. comprobarError $? 902 $1
  715. else
  716. # Intentamos habilitar en el arranque (SystemV)
  717. which chkconfig > /dev/null 2>&1
  718. if [ $? -eq 0 ];then
  719. chkconfig $1 on
  720. comprobarError $? 902 $1
  721. else
  722. # ¿Qué mas opciones nos quedan?
  723. comprobarError 1 902 $1
  724. fi
  725. fi
  726. fi
  727. # Mejora: comprobar si el servicio está funcionando
  728. echo -en " OK.\n" | tee -a $logFile
  729. }
  730. deshabilitarServicio() {
  731. # Paramos y deshabilitamos el servicio (con SystemD, Upstart o SystemV)
  732. # Intentamos con systemctl (SystemD)
  733. echo -en "Deshabilitando servicio $1" | tee -a $logFile
  734. if [ $# -le 0 ];then
  735. comprobarError 1 903
  736. fi
  737. which systemctl > /dev/null 2>&1
  738. if [ $? -eq 0 ]; then
  739. echo -en " (SystemD)..." | tee -a $logFile
  740. systemctl stop $1 > /dev/null 2>&1
  741. comprobarError $? 904 $1
  742. systemctl disable $1 > /dev/null 2>&1
  743. comprobarError $? 905 $1
  744. else
  745. # Intentamos con service (Upstart)
  746. which service > /dev/null 2>&1
  747. if [ $? -eq 0 ]; then
  748. echo -en " (Upstart)..." | tee -a $logFile
  749. service $1 stop > /dev/null 2>&1
  750. comprobarError $? 904 $1
  751. else
  752. # Intentamos con init.d (SystemV)
  753. echo -en " (SystemV)..." | tee -a $logFile
  754. /etc/init.d/$1 stop > /dev/null 2>&1
  755. comprobarError $? 904 $1
  756. fi
  757. # Intentamos habilitar en el arranque (Upstart)
  758. which update-rc.d > /dev/null 2>&1
  759. if [ $? -eq 0 ];then
  760. update-rc.d $1 disable
  761. comprobarError $? 905 $1
  762. else
  763. # Intentamos habilitar en el arranque (SystemV)
  764. which chkconfig > /dev/null 2>&1
  765. if [ $? -eq 0 ];then
  766. chkconfig $1 off
  767. comprobarError $? 905 $1
  768. else
  769. # ¿Qué mas opciones nos quedan?
  770. comprobarError 1 905 $1
  771. fi
  772. fi
  773. fi
  774. # Mejora: comprobar si el servicio está funcionando
  775. echo -en " OK.\n" | tee -a $logFile
  776. }
  777. configurarCortafuegos() {
  778. # Configuramos cortafuegos (añadir reglas y encender)
  779. # Comprobamos si estamos usando SSH
  780. esSSH $PPID
  781. if [ $debianOS = true ];then
  782. ufw allow 80/tcp 2>&1 >> $logFile
  783. comprobarError $? 906 "80/tcp"
  784. if [ $sshControl = true ];then
  785. ufw allow 22/tcp 2>&1 >> $logFile
  786. comprobarError $? 906 "22/tcp"
  787. fi
  788. if [ $sslOn = true ];then
  789. ufw allow 443/tcp 2>&1 >> $logFile
  790. comprobarError $? 906 "443/tcp"
  791. fi
  792. ufw --force enable 2>&1 >> $logFile
  793. comprobarError $= 907
  794. elif [ $rhelOS = true ];then
  795. firewall-cmd --add-port=80/tcp 2>&1 >> $logFile
  796. comprobarError $? 906 "80/tcp"
  797. if [ $sshControl = true ];then
  798. firewall-cmd --add-port=22/tcp 2>&1 >> $logFile
  799. comprobarError $? 906 "22/tcp"
  800. fi
  801. if [ $sslOn = true ];then
  802. firewall-cmd --add-port=443/tcp 2>&1 >> $logFile
  803. comprobarError $? 906 "443/tcp"
  804. fi
  805. firewall-cmd --runtime-to-permanent 2>&1 >> $logFile
  806. comprobarError $? 907
  807. habilitarServicio firewalld 2>&1 >> $logFile
  808. comprobarError $? 907
  809. fi
  810. unset sshControl
  811. }
  812. esSSH() {
  813. p=${1:-$PPID}
  814. #read pid name x ppid y < <( cat /proc/$p/stat )
  815. read pid name ppid < <( ps -o pid= -o comm= -o ppid= -p $p)
  816. [[ "$name" =~ sshd ]] && { sshControl=true; return 0; }
  817. [ "$ppid" -le 1 ] && { sshControl=false; return 1; }
  818. esSSH $ppid
  819. }
  820. # Comprobación del sistema e inicialización
  821. inicializarVariables
  822. comprobarRoot
  823. OSInfo
  824. comprobarDependencias
  825. # Bienvenida
  826. mostrarBienvenida
  827. # Selección de componentes (express vs avanzada)
  828. mostrarExpress
  829. # Pre-configuración
  830. # Habilitar cortafuegos -> PROBLEMA: se corta la conexión ssh
  831. # Instalación
  832. # FALTA: whiptail --gauge -> Más bonito
  833. # Servidor Web
  834. if [ $apacheOn = true ]; then
  835. echo -en "Instalando Web Server Apache..." | tee -a $logFile
  836. # {
  837. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  838. instalarApache
  839. progreso=$((progreso + 1))
  840. # } > >(whiptail --gauge "Instalando Web Server Apache..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  841. echo -en " OK.\n" | tee -a $logFile
  842. elif [ $nginxOn = true ]; then
  843. echo -en "Instalando Web Server Nginx..." | tee -a $logFile
  844. # {
  845. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  846. instalarNginx
  847. progreso=$((progreso + 1))
  848. # } > >(whiptail --gauge "Instalando Web Server Nginx..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  849. echo -en " OK.\n" | tee -a $logFile
  850. fi
  851. # Base de Datos
  852. if [ $mySQLOn = true ]; then
  853. echo -en "Instalando Base de Datos MySQL..." | tee -a $logFile
  854. # {
  855. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  856. instalarMySQL
  857. progreso=$((progreso + 1))
  858. # } > >(whiptail --gauge "Instalando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  859. echo -en " OK.\n" | tee -a $logFile
  860. elif [ $mariaDBOn = true ]; then
  861. echo -en "Instalando Base de Datos MariaDB..." | tee -a $logFile
  862. # {
  863. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  864. instalarMariaDB
  865. progreso=$((progreso + 1))
  866. # } > >(whiptail --gauge "Instalando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  867. echo -en " OK.\n" | tee -a $logFile
  868. fi
  869. # PHP
  870. if [ $phpOn = true ]; then
  871. echo -en "Instalando PHP-7..." | tee -a $logFile
  872. # {
  873. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  874. instalarPHP
  875. progreso=$((progreso + 1))
  876. # } > >(whiptail --gauge "Instalando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  877. echo -en " OK.\n" | tee -a $logFile
  878. fi
  879. # SSL/TLS
  880. # Falta por implementar
  881. # {
  882. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  883. sleep 2
  884. progreso=$((progreso + 1))
  885. # } > >(whiptail --gauge "Instalando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  886. # MediaWiki
  887. if [ $mediaWikiOn = true ]; then
  888. echo -en "Instalando MediaWiki..." | tee -a $logFile
  889. # {
  890. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  891. sleep 2
  892. progreso=$((progreso + 1))
  893. # } > >(whiptail --gauge "Instalando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  894. echo -en " OK.\n" | tee -a $logFile
  895. fi
  896. # Moodle
  897. if [ $moodleOn = true ]; then
  898. echo -en "Instalando Moodle..." | tee -a $logFile
  899. # {
  900. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  901. sleep 2
  902. progreso=$((progreso + 1))
  903. # } > >(whiptail --gauge "Instalando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  904. echo -en " OK.\n" | tee -a $logFile
  905. fi
  906. # PRECAUCION!!!! Hay que habilitar algunos servicios antes de configurarlos
  907. # Por ejemplo: para cambiar la contraseña de root en mysql
  908. # Configuración
  909. # Configuración Apache
  910. # Virtual Hosts
  911. if [ $nginxOn = true ]; then
  912. echo -en "Configurando Servidor Web Nginx..." | tee -a $logFile
  913. # {
  914. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  915. configurarNginx
  916. progreso=$((progreso + 1))
  917. # } > >(whiptail --gauge "Configurando Servidor Web..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  918. echo -en " OK.\n" | tee -a $logFile
  919. fi
  920. # Instalar info.php
  921. if [ $infoPHPOn = true ];then
  922. echo -en "Configurando 'info.php'..." | tee -a $logFile
  923. instalarPHPInfo
  924. echo -en " OK.\n" | tee -a $logFile
  925. fi
  926. # Configuración Database
  927. # Arrancar Base de Datos, establecer contraseña y configuración segura
  928. if [ $mySQLOn = true ];then
  929. habilitarServicio mysql
  930. echo -en "Configurando Base de Datos MySQL..." | tee -a $logFile
  931. # {
  932. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  933. establecerSQLPasswd
  934. progreso=$((progreso + 1))
  935. # } > >(whiptail --gauge "Configurando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  936. echo -en " OK.\n" | tee -a $logFile
  937. fi
  938. if [ $mariaDBOn = true ];then
  939. habilitarServicio mariadb
  940. echo -en "Configurando Base de Datos MariaDB..." | tee -a $logFile
  941. # {
  942. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  943. establecerSQLPasswd
  944. progreso=$((progreso + 1))
  945. # } > >(whiptail --gauge "Configurando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  946. echo -en " OK.\n" | tee -a $logFile
  947. fi
  948. # Configuración PHP
  949. # cgi.fix_pathinfo=0
  950. # Configurar máximo de subida de archivos
  951. if [ $phpOn = true ];then
  952. echo -en "Configurando PHP-7..." | tee -a $logFile
  953. # {
  954. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  955. configurarPHP
  956. progreso=$((progreso + 1))
  957. # } > >(whiptail --gauge "Configurando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  958. echo -en " OK.\n" | tee -a $logFile
  959. fi
  960. # Configuración MediWiki
  961. echo -en "Configurando MediaWiki..." | tee -a $logFile
  962. # {
  963. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  964. sleep 2
  965. progreso=$((progreso + 1))
  966. # } > >(whiptail --gauge "Configurando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  967. echo -en " OK.\n" | tee -a $logFile
  968. # Configuración Moodle
  969. echo -en "Configurando Moodle..." | tee -a $logFile
  970. # {
  971. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  972. sleep 2
  973. progreso=$((progreso + 1))
  974. # } > >(whiptail --gauge "Configurando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  975. echo -en " OK.\n" | tee -a $logFile
  976. # Arrancar y habilitar todos los servicios (SystemD, Service o SystemV)
  977. # {
  978. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  979. if [ $apacheOn = true ];then
  980. if [ $debianOS = true ];then
  981. habilitarServicio apache2
  982. elif [ $rhelOS = true ];then
  983. habilitarServicio httpd
  984. fi
  985. elif [ $nginxOn = true ];then
  986. habilitarServicio nginx
  987. if [ $phpOn = true ];then
  988. if [ $debianOS = true ];then
  989. habilitarServicio php7.2-fpm
  990. elif [ $rhelOS = true ];then
  991. habilitarServicio php-fpm
  992. fi
  993. fi
  994. fi
  995. progreso=$((progreso + 1))
  996. # } > >(whiptail --gauge "Arrancando Servicios..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  997. # Añadir reglas del cortafuegos
  998. echo -en "Configurando Cortafuegos..." | tee -a $logFile
  999. # {
  1000. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1001. sleep 2
  1002. progreso=$((progreso + 1))
  1003. # } > >(whiptail --gauge "Configurando Cortafuegos..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1004. echo -en " OK.\n" | tee -a $logFile
  1005. # Configuración SSL/TLS
  1006. # Generar certificados
  1007. # Configurar certificados
  1008. echo -en "Configurando SSL/TLS..." | tee -a $logFile
  1009. # {
  1010. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1011. sleep 2
  1012. progreso=$((progreso + 1))
  1013. # } > >(whiptail --gauge "Configurando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1014. echo -en " OK.\n" | tee -a $logFile
  1015. # Configurar actualizaciones
  1016. if [ $actualizacionesOn = true ]; then
  1017. echo -en "Configurando actualizaciones automáticas..." | tee -a $logFile
  1018. # {
  1019. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1020. sleep 2
  1021. progreso=$((progreso + 1))
  1022. # } > >(whiptail --gauge "Configurando actualizaciones automáticas..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1023. echo -en " OK.\n" | tee -a $logFile
  1024. fi