install 33 KB

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