install 32 KB

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