install 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  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. cp -R $nginxConfFile /etc/nginx/ 2>/dev/null
  468. comprobarError $? 107
  469. else
  470. comprobarError 1 107
  471. fi
  472. unset nginxConfFile
  473. }
  474. mostrarDatabase() {
  475. if [ $debianOS = true ]; then
  476. 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 \
  477. "MariaDB" "Instalar la base de datos MariaDB (fork de MySQL)" ON \
  478. "MySQL" "Instalar la base de datos MySQL (uso no comercial)" OFF \
  479. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  480. comprobarError $? 1
  481. case $database in
  482. MariaDB)
  483. mariaDBOn=true
  484. ;;
  485. MySQL)
  486. mySQLOn=true
  487. ;;
  488. *)
  489. comprobarError 1 200
  490. ;;
  491. esac
  492. elif [ $rhelOS = true ]; then
  493. 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"
  494. comprobarError $? 1
  495. mariaDBOn=true
  496. else
  497. comprobarError 1 200
  498. fi
  499. # Otras opciones (contraseña)
  500. leerSQLPasswd
  501. }
  502. leerSQLPasswd() {
  503. control=false
  504. error=""
  505. # Leemos la contreseña (stdin) y confirmamos
  506. while [ $control = false ]; do
  507. 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)
  508. comprobarError $? 1
  509. 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)
  510. comprobarError $? 1
  511. #echo -en "SQL Password 1: $sqlPasswd\n"
  512. #echo -en "SQL Password 2: $sqlPasswd2\n"
  513. if [ -z $sqlPasswd ] || [ -z $sqlPasswd2 ]; then
  514. error="ERROR: LA CONTRASEÑA NO PUEDE ESTAR VACIA.\n"
  515. elif [ $sqlPasswd != $sqlPasswd2 ];then
  516. error="ERROR: LAS CONTRASEÑAS NO COINCIDEN.\n"
  517. else
  518. control=true
  519. fi
  520. done
  521. #echo -en "SQL Password: $sqlPasswd\n"
  522. unset control error sqlPasswd2
  523. }
  524. establecerSQLPasswd() {
  525. # Establecemos SQL root passwd y securizamos BD (mysql_secure_installation)
  526. # Comprobamos si ya tiene una contraseña asignada
  527. mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
  528. if [ $? -eq 0 ];then
  529. # Establecemos contraseña del usuario root
  530. mysql -e "UPDATE mysql.user SET Password = PASSWORD('$sqlPasswd') WHERE User = 'root'" >> $logFile 2>&1
  531. comprobarError $? 207
  532. # Desactivamos acceso root desde el exterior (solo localhost)
  533. mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" >> $logFile 2>&1
  534. comprobarError $? 208
  535. # Eliminamos todos los usuarios anónimos
  536. mysql -e "DELETE FROM mysql.user WHERE User=''" >> $logFile 2>&1
  537. comprobarError $? 209
  538. # Eliminamos bases de datos 'test'
  539. mysql -e "DROP DATABASE IF EXISTS test" >> $logFile 2>&1
  540. comprobarError $? 210
  541. # Eliminamos privilegios de la base de datos 'test'
  542. mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'" >> $logFile 2>&1
  543. comprobarError $? 211
  544. # Aplicamos los cambios
  545. mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
  546. comprobarError $? 212
  547. else
  548. comprobarError 1 206
  549. fi
  550. }
  551. instalarMySQL() {
  552. if [ $debianOS = true ];then
  553. result=$(apt-get -q -y install mysql-server mysql-client 2>&1)
  554. comprobarError $? 201 $result
  555. elif [ $rhelOS = true ];then
  556. # MySQL no disponible en RHEL. 2 opciones:
  557. # 1) Instalar un repositorio adicional
  558. # 2) No instalar MySQL en distribuciones RHEL
  559. comprobarError 1 205
  560. else
  561. comprobarError 1 203
  562. fi
  563. }
  564. instalarMariaDB() {
  565. if [ $debianOS = true ];then
  566. result=$(apt-get -q -y install mariadb-server mariadb-client 2>&1)
  567. comprobarError $? 202 $result
  568. elif [ $rhelOS = true ];then
  569. result=$(yum -y install mariadb-server mariadb 2>&1)
  570. comprobarError $? 202 $result
  571. else
  572. comprobarError 1 204
  573. fi
  574. }
  575. instalarPHP() {
  576. # Instalamos PHP-7 de forma diferente si es junto a Apache o con Nginx
  577. if [ $debianOS = true ];then
  578. if [ $apacheOn = true ]; then
  579. result=$(apt-get -q -y install php libapache2-mod-php php-mysql php-intl php-mbstring openssl 2>&1)
  580. comprobarError $? 302 $result
  581. elif [ $nginxOn = true ];then
  582. result=$(apt-get -q -y install php-fpm libapache2-mod-php php-mysql php-intl php-mbstring openssl 2>&1)
  583. comprobarError $? 302 $result
  584. else
  585. comprobarError 1 301
  586. fi
  587. elif [ $rhelOS = true ];then
  588. # Necesitamos un repositorio adicional para PHP-7 (EPEL-RELEASE)
  589. result=$(yum -y install epel-release yum-utils 2>&1)
  590. comprobarError $? 103 $result
  591. # Necesitamos un repositorio adicional para PHP-7 (REMI-RELEASE)
  592. if [ ! -f /etc/yum.repos.d/remi-php72.repo ];then
  593. if [ $VERSION = "7" ];then
  594. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-7.rpm 2>&1)
  595. comprobarError $? 303 $result
  596. elif [ $VERSION = "6" ];then
  597. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-6.rpm 2>&1)
  598. comprobarError $? 303 $result
  599. elif [ $VERSION = "28" ];then
  600. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-28.rpm 2>&1)
  601. comprobarError $? 303 $result
  602. elif [ $VERSION = "27" ];then
  603. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-27.rpm 2>&1)
  604. comprobarError $? 303 $result
  605. else
  606. comprobarError 1 304
  607. fi
  608. fi
  609. # Activamos repositorio remi-php72
  610. result=$(yum-config-manager --enable remi-php72 2>&1)
  611. comprobarError $? 303 $result
  612. # Instalamos PHP-7.2
  613. if [ $apacheOn = true ];then
  614. result=$(yum -y install php php-mysql php-intl php-mbstring php-mcrypt openssl 2>&1)
  615. comprobarError $? 302 $result
  616. elif [ $nginxOn = true ];then
  617. result=$(yum -y install php php-fpm php-mysql php-intl php-mbstring php-mcrypt openssl 2>&1)
  618. comprobarError $? 302 $result
  619. else
  620. comprobarError 1 301
  621. fi
  622. else
  623. comprobarError 1 300
  624. fi
  625. }
  626. configurarPHP() {
  627. # Configura PHP para segurizarlo y establecer máximo de subida.
  628. if [ $debianOS = true ];then
  629. phpConfFile="./etc/php/php.ini.debian"
  630. phpDest="/etc/php/7.2/cli/php.ini"
  631. elif [ $rhelOS = true ];then
  632. phpConfFile="./etc/php/php.ini.rhel"
  633. phpDest="/etc/php.ini"
  634. fi
  635. if [ ! -f $phpConfFile ];then
  636. comprobarError 1 305
  637. fi
  638. # Copiamos configuración
  639. cp $phpConfFile $phpDest 2>/dev/null
  640. comprobarError $? 305
  641. # Configuramos cgi.fix_pathinfo
  642. sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=0' $phpDest
  643. comprobarError $? 305
  644. # Configuramos post_max_size
  645. sed -i '/post_max_size =/c\post_max_size = '$maxUpload $phpDest
  646. comprobarError $? 305
  647. # Configuramos upload_max_filesize
  648. sed -i '/upload_max_filesize =/c\upload_max_filesize = '$maxUpload $phpDest
  649. comprobarError $? 305
  650. # Configurar php-fpm (sólo en RHEL con Nginx)
  651. if [ $rhelOS = true ] && [ $nginxOn = true ];then
  652. phpConfFile="./etc/php/php-fpm.d/www.conf"
  653. phpDest="/etc/php-fpm.d/www.conf"
  654. if [ ! -f $phpConfFile ];then
  655. comprobarError $? 305
  656. fi
  657. cp $phpConfFile $phpDest 2>/dev/null
  658. comprobarError $? 305
  659. fi
  660. unset phpConfFile phpDest
  661. }
  662. establecerMaxUpload() {
  663. control=false
  664. error=""
  665. while [ $control = false ];do
  666. 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)
  667. comprobarError $? 1
  668. if [ -z $maxUpload2 ];then
  669. error="ERROR: NO PUEDES DEJAR ESTE PARÁMETRO VACIO.\n"
  670. else
  671. control=true
  672. fi
  673. done
  674. maxUpload=$maxUpload2
  675. unset control maxUpload2
  676. }
  677. instalarPHPInfo() {
  678. infoFile="./var/www/info.php"
  679. if [ ! -f $infoFile ];then
  680. comprobarError 1 106
  681. fi
  682. cp $infoFile /var/www/html/ 2>/dev/null
  683. comprobarError $? 106
  684. unset infoFile
  685. }
  686. habilitarServicio() {
  687. # Arrancamos y habilitamos el servicio (con SystemD, Upstart o SystemV)
  688. # Intentamos con systemctl (SystemD)
  689. echo -en "Habilitando servicio $1" | tee -a $logFile
  690. if [ $# -le 0 ];then
  691. comprobarError 1 900
  692. fi
  693. which systemctl > /dev/null 2>&1
  694. if [ $? -eq 0 ]; then
  695. echo -en " (SystemD)..." | tee -a $logFile
  696. systemctl start $1 > /dev/null 2>&1
  697. comprobarError $? 901 $1
  698. systemctl enable $1 > /dev/null 2>&1
  699. comprobarError $? 902 $1
  700. else
  701. # Intentamos con service (Upstart)
  702. which service > /dev/null 2>&1
  703. if [ $? -eq 0 ]; then
  704. echo -en " (Upstart)..." | tee -a $logFile
  705. service $1 start > /dev/null 2>&1
  706. comprobarError $? 901 $1
  707. else
  708. # Intentamos con init.d (SystemV)
  709. echo -en " (SystemV)..." | tee -a $logFile
  710. /etc/init.d/$1 start > /dev/null 2>&1
  711. comprobarError $? 901 $1
  712. fi
  713. # Intentamos habilitar en el arranque (Upstart)
  714. which update-rc.d > /dev/null 2>&1
  715. if [ $? -eq 0 ];then
  716. update-rc.d $1 enable
  717. comprobarError $? 902 $1
  718. else
  719. # Intentamos habilitar en el arranque (SystemV)
  720. which chkconfig > /dev/null 2>&1
  721. if [ $? -eq 0 ];then
  722. chkconfig $1 on
  723. comprobarError $? 902 $1
  724. else
  725. # ¿Qué mas opciones nos quedan?
  726. comprobarError 1 902 $1
  727. fi
  728. fi
  729. fi
  730. # Mejora: comprobar si el servicio está funcionando
  731. echo -en " OK.\n" | tee -a $logFile
  732. }
  733. deshabilitarServicio() {
  734. # Paramos y deshabilitamos el servicio (con SystemD, Upstart o SystemV)
  735. # Intentamos con systemctl (SystemD)
  736. echo -en "Deshabilitando servicio $1" | tee -a $logFile
  737. if [ $# -le 0 ];then
  738. comprobarError 1 903
  739. fi
  740. which systemctl > /dev/null 2>&1
  741. if [ $? -eq 0 ]; then
  742. echo -en " (SystemD)..." | tee -a $logFile
  743. systemctl stop $1 > /dev/null 2>&1
  744. comprobarError $? 904 $1
  745. systemctl disable $1 > /dev/null 2>&1
  746. comprobarError $? 905 $1
  747. else
  748. # Intentamos con service (Upstart)
  749. which service > /dev/null 2>&1
  750. if [ $? -eq 0 ]; then
  751. echo -en " (Upstart)..." | tee -a $logFile
  752. service $1 stop > /dev/null 2>&1
  753. comprobarError $? 904 $1
  754. else
  755. # Intentamos con init.d (SystemV)
  756. echo -en " (SystemV)..." | tee -a $logFile
  757. /etc/init.d/$1 stop > /dev/null 2>&1
  758. comprobarError $? 904 $1
  759. fi
  760. # Intentamos habilitar en el arranque (Upstart)
  761. which update-rc.d > /dev/null 2>&1
  762. if [ $? -eq 0 ];then
  763. update-rc.d $1 disable
  764. comprobarError $? 905 $1
  765. else
  766. # Intentamos habilitar en el arranque (SystemV)
  767. which chkconfig > /dev/null 2>&1
  768. if [ $? -eq 0 ];then
  769. chkconfig $1 off
  770. comprobarError $? 905 $1
  771. else
  772. # ¿Qué mas opciones nos quedan?
  773. comprobarError 1 905 $1
  774. fi
  775. fi
  776. fi
  777. # Mejora: comprobar si el servicio está funcionando
  778. echo -en " OK.\n" | tee -a $logFile
  779. }
  780. configurarCortafuegos() {
  781. # Configuramos cortafuegos (añadir reglas y encender)
  782. # Comprobamos si estamos usando SSH
  783. esSSH $PPID
  784. if [ $debianOS = true ];then
  785. ufw allow 80/tcp 2>&1 >> $logFile
  786. comprobarError $? 906 "80/tcp"
  787. if [ $sshControl = true ];then
  788. ufw allow 22/tcp 2>&1 >> $logFile
  789. comprobarError $? 906 "22/tcp"
  790. fi
  791. if [ $sslOn = true ];then
  792. ufw allow 443/tcp 2>&1 >> $logFile
  793. comprobarError $? 906 "443/tcp"
  794. fi
  795. ufw --force enable 2>&1 >> $logFile
  796. comprobarError $= 907
  797. elif [ $rhelOS = true ];then
  798. firewall-cmd --add-port=80/tcp 2>&1 >> $logFile
  799. comprobarError $? 906 "80/tcp"
  800. if [ $sshControl = true ];then
  801. firewall-cmd --add-port=22/tcp 2>&1 >> $logFile
  802. comprobarError $? 906 "22/tcp"
  803. fi
  804. if [ $sslOn = true ];then
  805. firewall-cmd --add-port=443/tcp 2>&1 >> $logFile
  806. comprobarError $? 906 "443/tcp"
  807. fi
  808. firewall-cmd --runtime-to-permanent 2>&1 >> $logFile
  809. comprobarError $? 907
  810. habilitarServicio firewalld 2>&1 >> $logFile
  811. comprobarError $? 907
  812. fi
  813. unset sshControl
  814. }
  815. esSSH() {
  816. p=${1:-$PPID}
  817. #read pid name x ppid y < <( cat /proc/$p/stat )
  818. read pid name ppid < <( ps -o pid= -o comm= -o ppid= -p $p)
  819. [[ "$name" =~ sshd ]] && { sshControl=true; return 0; }
  820. [ "$ppid" -le 1 ] && { sshControl=false; return 1; }
  821. esSSH $ppid
  822. }
  823. # Comprobación del sistema e inicialización
  824. inicializarVariables
  825. comprobarRoot
  826. OSInfo
  827. comprobarDependencias
  828. # Bienvenida
  829. mostrarBienvenida
  830. # Selección de componentes (express vs avanzada)
  831. mostrarExpress
  832. # Pre-configuración
  833. # Habilitar cortafuegos -> PROBLEMA: se corta la conexión ssh
  834. # Instalación
  835. # FALTA: whiptail --gauge -> Más bonito
  836. # Servidor Web
  837. if [ $apacheOn = true ]; then
  838. echo -en "Instalando Web Server Apache..." | tee -a $logFile
  839. # {
  840. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  841. instalarApache
  842. progreso=$((progreso + 1))
  843. # } > >(whiptail --gauge "Instalando Web Server Apache..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  844. echo -en " OK.\n" | tee -a $logFile
  845. elif [ $nginxOn = true ]; then
  846. echo -en "Instalando Web Server Nginx..." | tee -a $logFile
  847. # {
  848. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  849. instalarNginx
  850. progreso=$((progreso + 1))
  851. # } > >(whiptail --gauge "Instalando Web Server Nginx..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  852. echo -en " OK.\n" | tee -a $logFile
  853. fi
  854. # Base de Datos
  855. if [ $mySQLOn = true ]; then
  856. echo -en "Instalando Base de Datos MySQL..." | tee -a $logFile
  857. # {
  858. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  859. instalarMySQL
  860. progreso=$((progreso + 1))
  861. # } > >(whiptail --gauge "Instalando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  862. echo -en " OK.\n" | tee -a $logFile
  863. elif [ $mariaDBOn = true ]; then
  864. echo -en "Instalando Base de Datos MariaDB..." | tee -a $logFile
  865. # {
  866. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  867. instalarMariaDB
  868. progreso=$((progreso + 1))
  869. # } > >(whiptail --gauge "Instalando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  870. echo -en " OK.\n" | tee -a $logFile
  871. fi
  872. # PHP
  873. if [ $phpOn = true ]; then
  874. echo -en "Instalando PHP-7..." | tee -a $logFile
  875. # {
  876. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  877. instalarPHP
  878. progreso=$((progreso + 1))
  879. # } > >(whiptail --gauge "Instalando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  880. echo -en " OK.\n" | tee -a $logFile
  881. fi
  882. # SSL/TLS
  883. # Falta por implementar
  884. # {
  885. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  886. sleep 2
  887. progreso=$((progreso + 1))
  888. # } > >(whiptail --gauge "Instalando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  889. # MediaWiki
  890. if [ $mediaWikiOn = true ]; then
  891. echo -en "Instalando MediaWiki..." | tee -a $logFile
  892. # {
  893. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  894. sleep 2
  895. progreso=$((progreso + 1))
  896. # } > >(whiptail --gauge "Instalando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  897. echo -en " OK.\n" | tee -a $logFile
  898. fi
  899. # Moodle
  900. if [ $moodleOn = true ]; then
  901. echo -en "Instalando Moodle..." | tee -a $logFile
  902. # {
  903. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  904. sleep 2
  905. progreso=$((progreso + 1))
  906. # } > >(whiptail --gauge "Instalando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  907. echo -en " OK.\n" | tee -a $logFile
  908. fi
  909. # PRECAUCION!!!! Hay que habilitar algunos servicios antes de configurarlos
  910. # Por ejemplo: para cambiar la contraseña de root en mysql
  911. # Configuración
  912. # Configuración Apache
  913. # Virtual Hosts
  914. if [ $nginxOn = true ]; then
  915. echo -en "Configurando Servidor Web Nginx..." | tee -a $logFile
  916. # {
  917. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  918. configurarNginx
  919. progreso=$((progreso + 1))
  920. # } > >(whiptail --gauge "Configurando Servidor Web..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  921. echo -en " OK.\n" | tee -a $logFile
  922. fi
  923. # Instalar info.php
  924. if [ $infoPHPOn = true ];then
  925. echo -en "Configurando 'info.php'..." | tee -a $logFile
  926. instalarPHPInfo
  927. echo -en " OK.\n" | tee -a $logFile
  928. fi
  929. # Configuración Database
  930. # Arrancar Base de Datos, establecer contraseña y configuración segura
  931. if [ $mySQLOn = true ];then
  932. habilitarServicio mysql
  933. echo -en "Configurando Base de Datos MySQL..." | tee -a $logFile
  934. # {
  935. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  936. establecerSQLPasswd
  937. progreso=$((progreso + 1))
  938. # } > >(whiptail --gauge "Configurando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  939. echo -en " OK.\n" | tee -a $logFile
  940. fi
  941. if [ $mariaDBOn = true ];then
  942. habilitarServicio mariadb
  943. echo -en "Configurando Base de Datos MariaDB..." | tee -a $logFile
  944. # {
  945. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  946. establecerSQLPasswd
  947. progreso=$((progreso + 1))
  948. # } > >(whiptail --gauge "Configurando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  949. echo -en " OK.\n" | tee -a $logFile
  950. fi
  951. # Configuración PHP
  952. # cgi.fix_pathinfo=0
  953. # Configurar máximo de subida de archivos
  954. if [ $phpOn = true ];then
  955. echo -en "Configurando PHP-7..." | tee -a $logFile
  956. # {
  957. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  958. configurarPHP
  959. progreso=$((progreso + 1))
  960. # } > >(whiptail --gauge "Configurando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  961. echo -en " OK.\n" | tee -a $logFile
  962. fi
  963. # Configuración MediWiki
  964. echo -en "Configurando MediaWiki..." | tee -a $logFile
  965. # {
  966. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  967. sleep 2
  968. progreso=$((progreso + 1))
  969. # } > >(whiptail --gauge "Configurando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  970. echo -en " OK.\n" | tee -a $logFile
  971. # Configuración Moodle
  972. echo -en "Configurando Moodle..." | tee -a $logFile
  973. # {
  974. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  975. sleep 2
  976. progreso=$((progreso + 1))
  977. # } > >(whiptail --gauge "Configurando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  978. echo -en " OK.\n" | tee -a $logFile
  979. # Arrancar y habilitar todos los servicios (SystemD, Service o SystemV)
  980. # {
  981. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  982. if [ $apacheOn = true ];then
  983. if [ $debianOS = true ];then
  984. habilitarServicio apache2
  985. elif [ $rhelOS = true ];then
  986. habilitarServicio httpd
  987. fi
  988. elif [ $nginxOn = true ];then
  989. habilitarServicio nginx
  990. if [ $phpOn = true ];then
  991. if [ $debianOS = true ];then
  992. habilitarServicio php7.2-fpm
  993. elif [ $rhelOS = true ];then
  994. habilitarServicio php-fpm
  995. fi
  996. fi
  997. fi
  998. progreso=$((progreso + 1))
  999. # } > >(whiptail --gauge "Arrancando Servicios..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1000. # Añadir reglas del cortafuegos
  1001. echo -en "Configurando Cortafuegos..." | tee -a $logFile
  1002. # {
  1003. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1004. sleep 2
  1005. progreso=$((progreso + 1))
  1006. # } > >(whiptail --gauge "Configurando Cortafuegos..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1007. echo -en " OK.\n" | tee -a $logFile
  1008. # Configuración SSL/TLS
  1009. # Generar certificados
  1010. # Configurar certificados
  1011. echo -en "Configurando SSL/TLS..." | tee -a $logFile
  1012. # {
  1013. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1014. sleep 2
  1015. progreso=$((progreso + 1))
  1016. # } > >(whiptail --gauge "Configurando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1017. echo -en " OK.\n" | tee -a $logFile
  1018. # Configurar actualizaciones
  1019. if [ $actualizacionesOn = true ]; then
  1020. echo -en "Configurando actualizaciones automáticas..." | tee -a $logFile
  1021. # {
  1022. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1023. sleep 2
  1024. progreso=$((progreso + 1))
  1025. # } > >(whiptail --gauge "Configurando actualizaciones automáticas..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1026. echo -en " OK.\n" | tee -a $logFile
  1027. fi