install 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479
  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 '"$(realpath $extraInfo)"' no existe.\n"
  39. ;;
  40. 5)
  41. error="\n$type $codeNum:\tEl directorio '"$(realpath $extraInfo)"' no existe.\n"
  42. ;;
  43. 6)
  44. error="$type $codeNum:\tError interno (selección SSL/TLS).\n"
  45. ;;
  46. 100)
  47. error="$type $codeNum:\tError interno (selección del servidor web).\n"
  48. ;;
  49. 101)
  50. error="\n$type $codeNum:\tError al instalar Apache2.\nDetalles:\n$extraInfo\n"
  51. ;;
  52. 102)
  53. error="\n$type $codeNum:\tError al instalar Nginx.\nDetalles:\n$extraInfo\n"
  54. ;;
  55. 103)
  56. error="\n$type $codeNum:\tError al nstalar repositorio 'epel-release'.\nDetalles:\n$extraInfo\n"
  57. ;;
  58. 104)
  59. error="\n$type $codeNum:\tError interno (instalación Apache2).\n"
  60. ;;
  61. 105)
  62. error="\n$type $codeNum:\tError interno (instalación Nginx).\n"
  63. ;;
  64. 106)
  65. type="WARNING"
  66. error="\n$type $codeNum:\tImposible instalar 'info.php'.\n"
  67. ;;
  68. 107)
  69. error="\n$type $codeNum:\tError al configurar Nginx.\n"
  70. ;;
  71. 108)
  72. error="\n$type $codeNum:\tError al configurar Apache2.\n"
  73. ;;
  74. 200)
  75. error="$type $codeNum:\tError interno (selección de base de datos).\n"
  76. ;;
  77. 201)
  78. error="\n$type $codeNum:\tError al instalar MySQL.\nDetalles:\n$extraInfo\n"
  79. ;;
  80. 202)
  81. error="\n$type $codeNum:\tError al instalar MariaDB.\nDetalles:\n$extraInfo\n"
  82. ;;
  83. 203)
  84. error="\n$type $codeNum:\tError interno (instalación MySQL).\n"
  85. ;;
  86. 204)
  87. error="\n$type $codeNum:\tError interno (instalación MariaDB).\n"
  88. ;;
  89. 205)
  90. error="\n$type $codeNum:\t$DIST no incluye MySQL en sus repositorios.\n"
  91. ;;
  92. 206)
  93. type="WARNING"
  94. error="\n$type $codeNum:\tUsuario 'root' ya dispone de contraseña."
  95. ;;
  96. 207)
  97. error="\n$type $codeNum:\tImposible cambiar la contraseña de 'root'."
  98. ;;
  99. 208)
  100. error="\n$type $codeNum:\tImposible desactivar acceso 'root' desde el exterior."
  101. ;;
  102. 209)
  103. error="\n$type $codeNum:\tImposible eliminar usuarios anónimos."
  104. ;;
  105. 210)
  106. type="WARNING"
  107. error="\n$type $codeNum:\tImposible eliminar bases de datos de pruebas."
  108. ;;
  109. 211)
  110. type="WARNING"
  111. error="\n$type $codeNum:\tImposible eliminar los permisos de las bases de datos de pruebas."
  112. ;;
  113. 212)
  114. error="\n$type $codeNum:\tImposible recargar base de datos."
  115. ;;
  116. 300)
  117. error="\n$type $codeNum:\tError interno (instalación PHP-7.2).\n"
  118. ;;
  119. 301)
  120. error="\n$type $codeNum:\tError interno (Web Server no seleccionado).\n"
  121. ;;
  122. 302)
  123. error="\n$type $codeNum:\tError al instalar PHP-7.2.\nDetalles:\n$extraInfo\n"
  124. ;;
  125. 303)
  126. error="\n$type $codeNum:\tError al instalar Repositorio Remi.\nDetalles:\n$extraInfo\n"
  127. ;;
  128. 304)
  129. error="\n$type $codeNum:\tSistema Operativo no compatible con PHP-7.2 ($OS $DIST $REV).\n"
  130. ;;
  131. 305)
  132. error="\n$type $codeNum:\tImposible configurar PHP-7.2.\n"
  133. ;;
  134. 501)
  135. error="\n$type $codeNum:\tImposible descargar MediaWiki-1.31.0.\n"
  136. ;;
  137. 502)
  138. error="\n$type $codeNum:\tImposible configurar MediaWiki-1.31.0.\n"
  139. ;;
  140. 503)
  141. error="\n$type $codeNum:\tImposible configurar Base de Datos para MediaWiki-1.31.0.\n"
  142. ;;
  143. 601)
  144. error="\n$type $codeNum:\tImposible descargar Moodle-3.5.1.\n"
  145. ;;
  146. 800)
  147. error="$type $codeNum:\tEs necesario ser root ('sudo $0').\n"
  148. ;;
  149. 801)
  150. error="$type $codeNum:\t'whiptail' no instalado.\n"
  151. ;;
  152. 802)
  153. error="$type $codeNum:\t'hostnamectl' no instalado.\n"
  154. ;;
  155. 803)
  156. error="$type $codeNum:\t'apt-get' no instalado.\n"
  157. ;;
  158. 804)
  159. error="$type $codeNum:\t'yum' no instalado.\n"
  160. ;;
  161. 805)
  162. error="\n$type $codeNum:\tImposible actualizar repositorio\nDetalles:\n$extraInfo.\n"
  163. ;;
  164. 806)
  165. error="$type $codeNum:\t'ufw' no instalado.\n"
  166. ;;
  167. 807)
  168. error="$type $codeNum:\t'firewall-cmd' no instalado.\n"
  169. ;;
  170. 808)
  171. error="$type $codeNum:\t'tput' no instalado.\nDetalles:\n$extraInfo\n"
  172. ;;
  173. 809)
  174. error="$type $codeNum:\t'sed' no instalado.\nDetalles:\n$extraInfo\n"
  175. ;;
  176. 810)
  177. error="$type $codeNum:\t'curl' no instalado.\nDetalles:\n$extraInfo\n"
  178. ;;
  179. 811)
  180. error="$type $codeNum:\t'tar' no instalado.\nDetalles:\n$extraInfo\n"
  181. ;;
  182. 812)
  183. error="$type $codeNum:\t'gzip' no instalado.\nDetalles:\n$extraInfo\n"
  184. ;;
  185. 813)
  186. error="$type $codeNum:\t'bzip2' no instalado.\nDetalles:\n$extraInfo\n"
  187. ;;
  188. 814)
  189. error="$type $codeNum:\t'xz' no instalado.\nDetalles:\n$extraInfo\n"
  190. ;;
  191. 815)
  192. error="$type $codeNum:\t'openssl' no instalado.\nDetalles:\n$extraInfo\n"
  193. ;;
  194. 816)
  195. error="$type $codeNum:\t'find' no instalado.\n"
  196. ;;
  197. 900)
  198. error="$type $codeNum:\tError interno (habilitar servicio).\n"
  199. ;;
  200. 901)
  201. error="$type $codeNum:\tImposible encender servicio '$extraInfo'.\n"
  202. ;;
  203. 902)
  204. error="$type $codeNum:\tImposible habilitar servicio '$extraInfo' durante el arranque.\n"
  205. ;;
  206. 903)
  207. error="$type $codeNum:\tError interno (deshabilitar servicio).\n"
  208. ;;
  209. 904)
  210. error="$type $codeNum:\tImposible parar servicio '$extraInfo'.\n"
  211. ;;
  212. 905)
  213. error="$type $codeNum:\tImposible deshabilitar servicio '$extraInfo' durante el arranque.\n"
  214. ;;
  215. 906)
  216. type="WARNING"
  217. error="\n$type $codeNum:\tImposible añadir regla al cortafuegos ('$extraInfo').\n"
  218. ;;
  219. 907)
  220. type="WARNING"
  221. error="\n$type $codeNum:\tImposible encender cortafuegos.\n"
  222. ;;
  223. 908)
  224. error="\n$type $codeNum:\tError interno (instalar Virtual Host).\n"
  225. ;;
  226. 909)
  227. error="\n$type $codeNum:\tVirtual Host '$extraInfo' no existe.\n"
  228. ;;
  229. 910)
  230. error="\n$type $codeNum:\tImposible copiar Virtual Host '$extraInfo'.\n"
  231. ;;
  232. 911)
  233. error="\n$type $codeNum:\tImposible activar Virtual Host '$extraInfo'.\n"
  234. ;;
  235. 912)
  236. error="\n$type $codeNum:\tError interno (recargar servicio).\n"
  237. ;;
  238. 913)
  239. error="\n$type $codeNum:\tImposible recargar servicio '$extraInfo'.\n"
  240. ;;
  241. *)
  242. error="ERROR 13:\tError interno (comprobación de errores)\n"
  243. exitNum=1
  244. codeNum=13
  245. ;;
  246. esac
  247. if [ $exitNum -ne 0 ];then
  248. echo -en "$error" | tee -a $logFile
  249. if [ $type = "ERROR" ];then
  250. exit $codeNum
  251. fi
  252. fi
  253. unset error exitNum codeNum type
  254. }
  255. OSInfo() {
  256. echo -en "Detectando SO..." >> $logFile
  257. OS=$(uname -s)
  258. if [ $OS = "Linux" ]; then
  259. OS="GNU/Linux"
  260. if [ -f /etc/os-release ]; then
  261. DIST=$(grep ^NAME= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
  262. REV=$(grep ^VERSION= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
  263. ID_LIKE=$(grep ^ID_LIKE= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
  264. VERSION=$(grep ^VERSION_ID= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
  265. for i in $ID_LIKE; do
  266. #echo -en "$i\n"
  267. case $i in
  268. debian|ubuntu)
  269. debianOS=true
  270. break
  271. ;;
  272. rhel|fedora)
  273. rhelOS=true
  274. break
  275. ;;
  276. *)
  277. debianOS=false
  278. rhelOS=false
  279. ;;
  280. esac
  281. done
  282. elif [ -f /etc/debian-version ]; then
  283. # Familia Debian (Debian, Ubuntu, Linux Mint, ...)
  284. DIST="Debian"
  285. REV=""
  286. ID_LIKE="debian"
  287. VERSION=""
  288. debianOS=true
  289. elif [ -f /etc/redhat-release ]; then
  290. # Familia Red-Hat (RHEL, Fedora, CentOS, ...)
  291. DIST="Red-Hat"
  292. REV=""
  293. ID_LIKE="rhel"
  294. VERSION=""
  295. rhelOS=true
  296. else
  297. # Other Linux (No Soportado)
  298. DIST=""
  299. REV=""
  300. ID_LIKE=""
  301. VERSION=""
  302. fi
  303. else
  304. # UNIX, OS X, ... (No Soportado)
  305. DIST=$OS
  306. REV=""
  307. ID_LIKE=""
  308. VERSION=""
  309. fi
  310. echo -en " $OS $DIST $REV\n" >> $logFile
  311. HDInfo=$(df -h | head -1)"\n"$(df -h | grep ^/dev/sd)"\n"$(df -h | grep ^/dev/mapper)
  312. echo -en "$HDInfo\n" >> $logFile
  313. }
  314. comprobarRoot() {
  315. comprobarError $(id -u) 800
  316. }
  317. comprobarDependencias() {
  318. # Comprobamos whiptail
  319. which whiptail > /dev/null 2>&1
  320. comprobarError $? 801
  321. # Comprobamos hostnamectl
  322. which hostnamectl > /dev/null 2>&1
  323. comprobarError $? 802
  324. which find > /dev/null 2>&1
  325. comprobarError $? 816
  326. if [ $debianOS = true ];then
  327. # Comprobamos apt-get
  328. which apt-get > /dev/null 2>&1
  329. comprobarError $? 803
  330. # Actualizamos base de datos del repositorio
  331. echo -en "Actualizando repositorio APT..." | tee -a $logFile
  332. result=$(apt-get -q -y update 2>&1)
  333. comprobarError $? 805 $result
  334. echo -en " OK.\n" | tee -a $logFile
  335. # Comprobamos Firewall (ufw)
  336. which ufw > /dev/null 2>&1
  337. comprobarError $? 806
  338. # Comprobamos tput
  339. which tput > /dev/null 2>&1
  340. if [ $? -ne 0 ];then
  341. result=$(apt-get -q -y ncurses-bin 2>&1)
  342. comprobarError $? 808 $result
  343. fi
  344. # Comprobar sed
  345. which sed > /dev/null 2>&1
  346. if [ $? -ne 0 ];then
  347. result=$(apt-get -q -y sed 2>&1)
  348. comprobarError $? 809 $result
  349. fi
  350. # Comprobar curl
  351. which curl > /dev/null 2>&1
  352. if [ $? -ne 0 ];then
  353. result=$(apt-get -q -y curl 2>&1)
  354. comprobarError $? 810 $result
  355. fi
  356. # Comprobamos tar, gzip, bzip2 y xz
  357. which tar > /dev/null 2>&1
  358. if [ $? -ne 0 ];then
  359. result=$(apt-get -q -y install tar 2>&1)
  360. comprobarError $? 811 $result
  361. fi
  362. which gzip > /dev/null 2>&1
  363. if [ $? -ne 0 ];then
  364. result=$(apt-get -q -y install gzip 2>&1)
  365. comprobarError $? 812 $result
  366. fi
  367. which bzip2 > /dev/null 2>&1
  368. if [ $? -ne 0 ];then
  369. result=$(apt-get -q -y install bzip2 2>&1)
  370. comprobarError $? 813 $result
  371. fi
  372. which xz > /dev/null 2>&1
  373. if [ $? -ne 0 ];then
  374. result=$(apt-get -q -y install xz-utils 2>&1)
  375. comprobarError $? 814 $result
  376. fi
  377. which openssl > /dev/null 2>&1
  378. if [ $? -ne 0 ];then
  379. result=$(apt-get -q -y install openssl 2>&1)
  380. comprobarError $? 815 $result
  381. fi
  382. fi
  383. if [ $rhelOS = true ]; then
  384. # Comprobamos yum
  385. which yum > /dev/null 2>&1
  386. comprobarError $? 804
  387. # Actualizamos base de datos del repositorio
  388. echo -en "Actualizando repositorio YUM..." | tee -a $logFile
  389. result=$(yum -y makecache 2>&1)
  390. comprobarError $? 805 $result
  391. echo -en " OK.\n" | tee -a $logFile
  392. # Comprobamos Firewall (firewall-cmd)
  393. which firewall-cmd > /dev/null 2>&1
  394. comprobarError $? 807
  395. # Comprobamos tput
  396. which tput > /dev/null 2>&1
  397. if [ $? -ne 0 ];then
  398. result=$(yum -y ncurses 2>&1)
  399. comprobarError $? 808 $result
  400. fi
  401. # Comprobar sed
  402. which sed > /dev/null 2>&1
  403. if [ $? -ne 0 ];then
  404. result=$(yum -y sed 2>&1)
  405. comprobarError $? 809 $result
  406. fi
  407. # Comprobar curl
  408. which curl > /dev/null 2>&1
  409. if [ $? -ne 0 ];then
  410. result=$(yum -y curl 2>&1)
  411. comprobarError $? 810 $result
  412. fi
  413. # Comprobamos tar, gzip, bzip2 y xz
  414. which tar > /dev/null 2>&1
  415. if [ $? -ne 0 ];then
  416. result=$(yum -y install tar 2>&1)
  417. comprobarError $? 811 $result
  418. fi
  419. which gzip > /dev/null 2>&1
  420. if [ $? -ne 0 ];then
  421. result=$(yum -y install gzip 2>&1)
  422. comprobarError $? 812 $result
  423. fi
  424. which bzip2 > /dev/null 2>&1
  425. if [ $? -ne 0 ];then
  426. result=$(yum -y install bzip2 2>&1)
  427. comprobarError $? 813 $result
  428. fi
  429. which xz > /dev/null 2>&1
  430. if [ $? -ne 0 ];then
  431. result=$(yum -y install xz 2>&1)
  432. comprobarError $? 814 $result
  433. fi
  434. which openssl > /dev/null 2>&1
  435. if [ $? -ne 0 ];then
  436. result=$(yum -y install openssl 2>&1)
  437. comprobarError $? 815 $result
  438. fi
  439. fi
  440. }
  441. inicializarVariables() {
  442. debianOS=false
  443. rhelOS=false
  444. apacheOn=false
  445. nginxOn=false
  446. mySQLOn=false
  447. mariaDBOn=false
  448. phpOn=false
  449. sslOn=false
  450. letsEncryptOn=false
  451. mediaWikiOn=false
  452. moodleOn=false
  453. infoPHPOn=false
  454. actualizacionesOn=false
  455. progreso=0
  456. progresoTotal=0
  457. hostname=""
  458. logFile="./."$(basename $0)".log"
  459. maxUpload="100M"
  460. webServerName=""
  461. webServerUser=""
  462. webServerGroup=""
  463. sqlServerName=""
  464. phpFPMName=""
  465. dominioMediaWiki=""
  466. }
  467. instalacionExpress() {
  468. apacheOn=true
  469. mariaDBOn=true
  470. phpOn=true
  471. sslOn=true
  472. letsEncryptOn=true
  473. mediaWikiOn=true
  474. moodleOn=true
  475. actualizacionesOn=true
  476. progresoTotal=15
  477. # Preguntas mínimas
  478. establecerFQDN
  479. leerSQLPasswd
  480. mostrarMediaWiki
  481. }
  482. mostrarBienvenida() {
  483. ANCHO=$(tput cols)
  484. ALTO=$(tput lines)
  485. if [ $debianOS = false ] && [ $rhelOS = false ]; then
  486. 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"
  487. exit 1
  488. fi
  489. 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"
  490. comprobarError $? 1
  491. }
  492. mostrarExpress() {
  493. 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 \
  494. "Express" "Instalación rápida" ON \
  495. "Avanzada" "Permite escoger todas las opciones disponibles" OFF \
  496. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  497. comprobarError $? 1
  498. case $express in
  499. Express)
  500. instalacionExpress
  501. # DECIDIR QUÉ OPCIONES SON LAS MÍNIMAS
  502. ;;
  503. Avanzada)
  504. mostrarAvanzada
  505. ;;
  506. *)
  507. comprobarError 1 2
  508. ;;
  509. esac
  510. unset express
  511. }
  512. mostrarAvanzada() {
  513. 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 \
  514. "LAMP" "GNU/Linux + Apache + MySQL/MariaDB + PHP-7" ON \
  515. "LEMP" "GNU/Linux + Nginx + MySQL/MariaDB + PHP-7" OFF \
  516. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  517. comprobarError $? 1
  518. for i in $webServer; do
  519. case $i in
  520. LAMP)
  521. apacheOn=true
  522. ;;
  523. LEMP)
  524. nginxOn=true
  525. ;;
  526. *)
  527. comprobarError 1 100
  528. ;;
  529. esac
  530. done
  531. # Opciones comunes
  532. establecerFQDN
  533. mostrarDatabase
  534. phpOn=true
  535. establecerMaxUpload
  536. progresoTotal=$((progresoTotal + 6))
  537. mostrarComponentes
  538. unset webServer
  539. }
  540. mostrarComponentes() {
  541. 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 \
  542. "SSL/TLS" "Instalar certificados para activar HTTPS" ON \
  543. "MediaWiki" "Instalar wiki con MediaWiki" ON \
  544. "Moodle" "Instalar campus virtual con Moodle" ON \
  545. "InfoPHP" "Instalar info.php (sólo para pruebas)" OFF \
  546. "Actualizaciones" "Programar actualizaciones automáticas" ON \
  547. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  548. comprobarError $? 1
  549. # Mejora: autodetección de componentes ya instalados
  550. for i in $componentes; do
  551. case $i in
  552. \"SSL/TLS\")
  553. # 2 Opciones: Let's Encrypt o Autofirmado
  554. mostrarSSL
  555. progresoTotal=$((progresoTotal + 2))
  556. ;;
  557. \"MediaWiki\")
  558. mediaWikiOn=true
  559. mostrarMediaWiki
  560. progresoTotal=$((progresoTotal + 2))
  561. ;;
  562. \"Moodle\")
  563. moodleOn=true
  564. progresoTotal=$((progresoTotal + 2))
  565. ;;
  566. \"InfoPHP\")
  567. infoPHPOn=true
  568. progresoTotal=$((progresoTotal + 2))
  569. ;;
  570. \"Actualizaciones\")
  571. actualizacionesOn=true
  572. progresoTotal=$((progresoTotal + 1))
  573. ;;
  574. *)
  575. comprobarError 1 3
  576. ;;
  577. esac
  578. done
  579. progresoTotal=$((progresoTotal + 2))
  580. unset componentes
  581. }
  582. mostrarSSL() {
  583. ssl=$(whiptail --title "INSTALACION SSL/TLS" --radiolist "<ESPACIO>: seleccionar <TAB>: cambiar <FLECHAS>: moverse\n\nEscoge el tipo de Certificado SSL/TLS que quieres instalar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 2 \
  584. "LetsEncrypt" "Compatible con todos los navegadores" ON \
  585. "Auto-Firmado" "Certificados auto-firmados (sólo para pruebas)" OFF \
  586. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  587. comprobarError $? 1
  588. for i in $ssl; do
  589. case $i in
  590. LetsEncrypt)
  591. sslOn=true
  592. letsEcnryptOn=true
  593. ;;
  594. Auto-Firmados)
  595. sslOn=true
  596. ;;
  597. *)
  598. comprobarError 1 6
  599. ;;
  600. esac
  601. done
  602. unset ssl
  603. }
  604. mostrarMediaWiki(){
  605. # Introducir nombre wiki
  606. while [ -z $nombreMediaWiki ]; do
  607. nombreMediaWiki=$(whiptail --title "CONFIGURACION MEDIAWIKI" --inputbox "Introduzca el nombre de la Wiki:." $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) wiki.$hostname --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  608. comprobarError $? 1
  609. # Mejora: comprobar si el dominio ya está en uso
  610. done
  611. # Introducir dominio
  612. while [ -z $dominioMediaWiki ]; do
  613. dominioMediaWiki=$(whiptail --title "CONFIGURACION MEDIAWIKI" --inputbox "Introduzca el dominio/subdominio de la Wiki.\nTenga en cuenta que debes apuntar este a la dirección IP de esta máquina mediante un registro DNS tipo CNAME." $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) wiki.$hostname --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  614. comprobarError $? 1
  615. # Mejora: comprobar si el dominio ya está en uso
  616. done
  617. # Introducir tipo de Wiki (abierta, creación de cuenta requerida, sólo editores autorizados o wiki privada)
  618. tipoMediaWiki=$(whiptail --tittle "CONFIGURACION MEDIAWIKI" --radiolist "<ESPACIO>: seleccionar <TAB>: cambiar <FLECHAS>: moverse\n\nEscoge el tipo de wiki que quieres instalar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 4 \
  619. "Abierta" "Wiki Abierta" ON \
  620. "CuentaRequerida" "Creación de cuenta requerida" OFF \
  621. "EditoresAutorizados" "Sólo editores autorizados" OFF \
  622. "Privada" "Wiki privada" OFF \
  623. --ok-button "Continuar" --cancel-button "Salir" --notags 3>&1 1>&2 2>&3)
  624. comprobarError $? 1
  625. # Introducir tipo de Licencia
  626. licenciaMediaWiki=$(whiptail --tittle "CONFIGURACION MEDIAWIKI" --radiolist "<ESPACIO>: seleccionar <TAB>: cambiar <FLECHAS>: moverse\n\nEscoge el tipo licencia para la wiki:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 4 \
  627. "Nada" "Sin Licencia" ON \
  628. "CC-BY-SA" "Creative Commons Atribución-CompartirIgual" OFF \
  629. "CC-BY-NC-SA" "Creative Commons Atribución-NoComercial-CompartirIgual" OFF \
  630. "Copyright" "Todos los derechos reservados" OFF \
  631. --ok-button "Continuar" --cancel-button "Salir" --notags 3>&1 1>&2 2>&3)
  632. comprobarError $? 1
  633. }
  634. establecerFQDN() {
  635. while [ -z $hostname ]; do
  636. 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)
  637. if [ $? -eq 0 ] && [ ! -z $hostname ]; then
  638. hostnamectl set-hostname $hostname
  639. else
  640. hostname=$(hostname)
  641. fi
  642. done
  643. echo -en "Hostname: $hostname\n" >> $logFile
  644. }
  645. instalarApache() {
  646. if [ $debianOS = true ];then
  647. webServerName="apache2"
  648. result=$(apt-get -q -y install apache2 2>&1)
  649. comprobarError $? 101 $result
  650. elif [ $rhelOS = true ]; then
  651. webServerName="httpd"
  652. result=$(yum -y install httpd 2>&1)
  653. comprobarError $? 101 $result
  654. else
  655. comprobarError 1 104
  656. fi
  657. deshabilitarServicio $webServerName
  658. }
  659. configurarApache() {
  660. if [ $debianOS = true ];then
  661. apacheConfFile="./etc/$webServerName-debian/apache2.conf"
  662. if [ ! -f $apacheConfFile ];then
  663. comprobarError 1 4 $apacheConfFile
  664. fi
  665. cp -f $apacheConfFile /etc/$webServerName/apache2.conf 2>/dev/null
  666. comprobarError $? 108
  667. webServerUser=$(grep ^User /etc/$webServerName/apache2.conf | cut -d ' ' -f 2)
  668. webServerGroup=$(grep ^Group /etc/$webServerName/apache2.conf | cut -d ' ' -f 2)
  669. elif [ $rhelOS = true ];then
  670. apacheConfFile="./etc/$webServerName-rhel/conf/httpd.conf"
  671. welcomeConfFile="/etc/$webServerName/conf.d/welcome.conf"
  672. if [ ! -f $apacheConfFile ];then
  673. comprobarError 1 4 $apacheConfFile
  674. fi
  675. cp -f $apacheConfFile /etc/$webServerName/conf/ 2>/dev/null
  676. comprobarError $? 108
  677. if [ -f $welcomeConfFile ];then
  678. sed -i -e 's/^/#/' $welcomeConfFile
  679. comprobarError $? 108
  680. fi
  681. webServerUser=$(grep ^User /etc/$webServerName/conf/httpd.conf | cut -d ' ' -f 2)
  682. webServerGroup=$(grep ^Group /etc/$webServerName/conf/httpd.conf | cut -d ' ' -f 2)
  683. unset apacheConfFile welcomeConfFile
  684. fi
  685. if [ ! -d "/etc/$webServerName/sites-available" ];then
  686. mkdir "/etc/$webServerName/sites-available" 2>/dev/null
  687. comprobarError $? 5 "/etc/$webServerName/sites-available"
  688. fi
  689. if [ ! -d "/etc/$webServerName/sites-enabled" ]; then
  690. mkdir "/etc/$webServerName/sites-enabled" 2>/dev/null
  691. comprobarError $? 5 "$webServerRoot/sites-enabled"
  692. fi
  693. }
  694. instalarNginx() {
  695. webServerName="nginx"
  696. if [ $debianOS = true ];then
  697. result=$(apt-get -q -y install nginx 2>&1)
  698. comprobarError $? 102 $result
  699. elif [ $rhelOS = true ]; then
  700. # Hay que instalar primero otro repositorio
  701. result=$(yum -y install epel-release)
  702. comprobarError $? 103 $result
  703. result=$(yum -y install nginx 2>&1)
  704. comprobarError $? 102 $result
  705. else
  706. comprobarError 1 105
  707. fi
  708. deshabilitarServicio $webServerName
  709. }
  710. configurarNginx() {
  711. # Configuramos Nginx
  712. rm -Rf /etc/$webServerName/* 2>/dev/null
  713. comprobarError $? 107
  714. nginxConfFile="./etc/$webServerName"
  715. if [ -d "$nginxConfFile" ];then
  716. cp -Rf $nginxConfFile/* /etc/$webServerName/ 2>/dev/null
  717. comprobarError $? 107
  718. else
  719. comprobarError 1 5 "$nginxConfFile"
  720. fi
  721. if [ ! -d "/etc/$webServerName/sites-available" ];then
  722. mkdir "/etc/$webServerName/sites-available" 2>/dev/null
  723. comprobarError $? 5 "/etc/$webServerName/sites-available"
  724. fi
  725. if [ ! -d "/etc/$webServerName/sites-enabled" ]; then
  726. mkdir "/etc/$webServerName/sites-enabled" 2>/dev/null
  727. comprobarError $? 5 "$webServerRoot/sites-enabled"
  728. fi
  729. # Configuramos Usuario y Grupo
  730. if [ $debianOS = true ];then
  731. webServerUser="www-data"
  732. webServerGroup=$webServerUser
  733. elif [ $rhelOS = true ];then
  734. webServerUser="nginx"
  735. webServerGroup=$webServerUser
  736. fi
  737. sed -i '/user /c\user '$webServerUser';' /etc/$webServerName/nginx.conf
  738. comprobarError $? 107
  739. unset nginxConfFile
  740. }
  741. instalarVirtualHost() {
  742. # Configuramos un Virtual Host para Apache o Nginx
  743. # Uso: instalarVirtualHost $root $dominio $virtualHost
  744. webServerRoot=$(realpath "/etc/$webServerName/")
  745. if [ $# -eq 3 ];then
  746. rootVirtualHost=$(realpath $1)
  747. dominioVirtualHost=$2
  748. virtualHostFile=$(realpath $3)
  749. virtualHostName=$dominioVirtualHost".conf"
  750. else
  751. comprobarError 1 908
  752. fi
  753. if [ ! -f $virtualHostFile ];then
  754. comprobarError 1 909 $virtualHostName
  755. fi
  756. if [ $nginxOn = true ];then
  757. # Configuramos root, dominio, logs y php-fpm.sock (NGINX)
  758. sed -i '/root/c\\troot '/var/www/$dominioVirtualHost';' $virtualHostFile
  759. comprobarError $? 502
  760. sed -i '/server_name/c\\tserver_name '$dominioVirtualHost';' $virtualHostFile
  761. comprobarError $? 502
  762. sed -i '/access_log/c\\taccess_log /var/log/nginx/'$dominioVirtualHost'-access.log;' $virtualHostFile
  763. comprobarError $? 502
  764. sed -i '/error_log/c\\terror_log /var/log/nginx/'$dominioVirtualHost'-error.log;' $virtualHostFile
  765. comprobarError $? 502
  766. socket=$(find /var/run/ -type s -name 'php*.sock')
  767. sed -i '/fastcgi_pass/c\\t\tfastcgi_pass unix:'$socket';' $virtualHostFile
  768. fi
  769. # Copiamos ficheros de configuración
  770. cp -f $virtualHostFile "$webServerRoot/sites-available/$virtualHostName" >> $logFile 2>&1
  771. comprobarError $? 910
  772. ln -s "$webServerRoot/sites-available/$virtualHostName" "$webServerRoot/sites-enabled/$virtualHostName" >> $logFile 2>&1
  773. comprobarError $? 911 $virtualHostName
  774. recargarServicio $webServerName
  775. unset webServerRoot rootVirtualHost dominioVirtualHost virtualHostFile virtualHostName
  776. }
  777. mostrarDatabase() {
  778. if [ $debianOS = true ]; then
  779. 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 \
  780. "MariaDB" "Instalar la base de datos MariaDB (fork de MySQL)" ON \
  781. "MySQL" "Instalar la base de datos MySQL (uso no comercial)" OFF \
  782. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  783. comprobarError $? 1
  784. case $database in
  785. MariaDB)
  786. mariaDBOn=true
  787. ;;
  788. MySQL)
  789. mySQLOn=true
  790. ;;
  791. *)
  792. comprobarError 1 200
  793. ;;
  794. esac
  795. unset database
  796. elif [ $rhelOS = true ]; then
  797. 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"
  798. comprobarError $? 1
  799. mariaDBOn=true
  800. else
  801. comprobarError 1 200
  802. fi
  803. # Otras opciones (contraseña)
  804. leerSQLPasswd
  805. }
  806. leerSQLPasswd() {
  807. control=false
  808. error=""
  809. # Leemos la contreseña (stdin) y confirmamos
  810. while [ $control = false ]; do
  811. 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)
  812. comprobarError $? 1
  813. 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)
  814. comprobarError $? 1
  815. #echo -en "SQL Password 1: $sqlPasswd\n"
  816. #echo -en "SQL Password 2: $sqlPasswd2\n"
  817. if [ -z $sqlPasswd ] || [ -z $sqlPasswd2 ]; then
  818. error="ERROR: LA CONTRASEÑA NO PUEDE ESTAR VACIA.\n"
  819. elif [ $sqlPasswd != $sqlPasswd2 ];then
  820. error="ERROR: LAS CONTRASEÑAS NO COINCIDEN.\n"
  821. else
  822. control=true
  823. fi
  824. done
  825. #echo -en "SQL Password: $sqlPasswd\n"
  826. unset control error sqlPasswd2
  827. }
  828. establecerSQLPasswd() {
  829. # Establecemos SQL root passwd y securizamos BD (mysql_secure_installation)
  830. # Comprobamos si ya tiene una contraseña asignada
  831. mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
  832. if [ $? -eq 0 ];then
  833. # Establecemos contraseña del usuario root (y desactivamos posibles plugins para forzar login por contraseña)
  834. mysql -e "UPDATE mysql.user SET plugin = '', Password = PASSWORD('$sqlPasswd') WHERE User = 'root'" >> $logFile 2>&1
  835. comprobarError $? 207
  836. # Desactivamos acceso root desde el exterior (solo localhost)
  837. mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" >> $logFile 2>&1
  838. comprobarError $? 208
  839. # Eliminamos todos los usuarios anónimos
  840. mysql -e "DELETE FROM mysql.user WHERE User=''" >> $logFile 2>&1
  841. comprobarError $? 209
  842. # Eliminamos bases de datos 'test'
  843. mysql -e "DROP DATABASE IF EXISTS test" >> $logFile 2>&1
  844. comprobarError $? 210
  845. # Eliminamos privilegios de la base de datos 'test'
  846. mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'" >> $logFile 2>&1
  847. comprobarError $? 211
  848. # Aplicamos los cambios
  849. mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
  850. comprobarError $? 212
  851. else
  852. comprobarError 1 206
  853. fi
  854. }
  855. instalarMySQL() {
  856. sqlServerName="mysql"
  857. if [ $debianOS = true ];then
  858. result=$(apt-get -q -y install mysql-server mysql-client 2>&1)
  859. comprobarError $? 201 $result
  860. elif [ $rhelOS = true ];then
  861. # MySQL no disponible en RHEL. 2 opciones:
  862. # 1) Instalar un repositorio adicional
  863. # 2) No instalar MySQL en distribuciones RHEL
  864. comprobarError 1 205
  865. else
  866. comprobarError 1 203
  867. fi
  868. }
  869. instalarMariaDB() {
  870. sqlServerName="mariadb"
  871. if [ $debianOS = true ];then
  872. result=$(apt-get -q -y install mariadb-server mariadb-client 2>&1)
  873. comprobarError $? 202 $result
  874. elif [ $rhelOS = true ];then
  875. result=$(yum -y install mariadb-server mariadb 2>&1)
  876. comprobarError $? 202 $result
  877. else
  878. comprobarError 1 204
  879. fi
  880. }
  881. instalarPHP() {
  882. # Instalamos PHP-7 de forma diferente si es junto a Apache o con Nginx
  883. if [ $debianOS = true ];then
  884. if [ $apacheOn = true ]; then
  885. result=$(apt-get -q -y install php libapache2-mod-php php-mysql php-intl php-mbstring php-xml php-apcu php-gd 2>&1)
  886. comprobarError $? 302 $result
  887. elif [ $nginxOn = true ];then
  888. phpFPMName="php7.2-fpm"
  889. result=$(apt-get -q -y install php-fpm php-mysql php-intl php-mbstring php-xml php-apcu php-gd 2>&1)
  890. comprobarError $? 302 $result
  891. deshabilitarServicio $phpFPMName
  892. else
  893. comprobarError 1 301
  894. fi
  895. elif [ $rhelOS = true ];then
  896. # Necesitamos un repositorio adicional para PHP-7 (EPEL-RELEASE)
  897. result=$(yum -y install epel-release yum-utils 2>&1)
  898. comprobarError $? 103 $result
  899. # Necesitamos un repositorio adicional para PHP-7 (REMI-RELEASE)
  900. if [ ! -f /etc/yum.repos.d/remi-php72.repo ];then
  901. if [ $VERSION = "7" ];then
  902. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-7.rpm 2>&1)
  903. comprobarError $? 303 $result
  904. elif [ $VERSION = "6" ];then
  905. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-6.rpm 2>&1)
  906. comprobarError $? 303 $result
  907. elif [ $VERSION = "28" ];then
  908. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-28.rpm 2>&1)
  909. comprobarError $? 303 $result
  910. elif [ $VERSION = "27" ];then
  911. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-27.rpm 2>&1)
  912. comprobarError $? 303 $result
  913. else
  914. comprobarError 1 304
  915. fi
  916. fi
  917. # Activamos repositorio remi-php72
  918. result=$(yum-config-manager --enable remi-php72 2>&1)
  919. comprobarError $? 303 $result
  920. # Instalamos PHP-7.2
  921. if [ $apacheOn = true ];then
  922. result=$(yum -y install php php-mysql php-intl php-mbstring php-mcrypt php-xml php-pecl-apcu php-gd 2>&1)
  923. comprobarError $? 302 $result
  924. elif [ $nginxOn = true ];then
  925. phpFPMName="php-fpm"
  926. result=$(yum -y install php php-fpm php-mysql php-intl php-mbstring php-mcrypt php-xml php-pecl-apcu php-gd 2>&1)
  927. comprobarError $? 302 $result
  928. deshabilitarServicio $phpFPMName
  929. else
  930. comprobarError 1 301
  931. fi
  932. else
  933. comprobarError 1 300
  934. fi
  935. }
  936. configurarPHP() {
  937. # Configura PHP para segurizarlo y establecer máximo de subida.
  938. if [ $debianOS = true ];then
  939. phpConfFile="./etc/php/php.ini.debian"
  940. phpDest="/etc/php/7.2/cli/php.ini"
  941. elif [ $rhelOS = true ];then
  942. phpConfFile="./etc/php/php.ini.rhel"
  943. phpDest="/etc/php.ini"
  944. fi
  945. if [ ! -f $phpConfFile ];then
  946. comprobarError 1 4 "$phpConfFile"
  947. fi
  948. # Copiamos configuración
  949. cp -f $phpConfFile $phpDest 2>/dev/null
  950. comprobarError $? 305
  951. # Configuramos cgi.fix_pathinfo
  952. sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=0' $phpDest
  953. comprobarError $? 305
  954. # Configuramos post_max_size
  955. sed -i '/post_max_size =/c\post_max_size = '$maxUpload $phpDest
  956. comprobarError $? 305
  957. # Configuramos upload_max_filesize
  958. sed -i '/upload_max_filesize =/c\upload_max_filesize = '$maxUpload $phpDest
  959. comprobarError $? 305
  960. # Configurar php-fpm (sólo en RHEL con Nginx)
  961. if [ $rhelOS = true ] && [ $nginxOn = true ];then
  962. # Configurar Socket UNIX
  963. phpConfFile="./etc/php/php-fpm.d/www.conf"
  964. phpDest="/etc/php-fpm.d/www.conf"
  965. if [ ! -f $phpConfFile ];then
  966. comprobarError $? 4 "$phpConfFile"
  967. fi
  968. cp -f $phpConfFile $phpDest 2>/dev/null
  969. comprobarError $? 305
  970. # Configurar Permisos /var/lib/php
  971. chown -R $webServerUser:$webServerGroup /var/lib/php/
  972. comprobarError $? 305
  973. fi
  974. unset phpConfFile phpDest
  975. }
  976. establecerMaxUpload() {
  977. control=false
  978. error=""
  979. while [ $control = false ];do
  980. 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)
  981. comprobarError $? 1
  982. if [ -z $maxUpload2 ];then
  983. error="ERROR: NO PUEDES DEJAR ESTE PARÁMETRO VACIO.\n"
  984. else
  985. control=true
  986. fi
  987. done
  988. maxUpload=$maxUpload2
  989. unset control maxUpload2
  990. }
  991. instalarPHPInfo() {
  992. # Instalar fichero php
  993. if [ ! -f /etc/$webServerName/sites-enabled/phpinfo.conf ];then
  994. infoFile="./var/www/info.php"
  995. if [ ! -f $infoFile ];then
  996. comprobarError 1 4 "$infoFile"
  997. fi
  998. cp -f $infoFile /var/www/html/ 2>/dev/null
  999. comprobarError $? 106
  1000. chown -R $webServerUser:$webServerGroup /var/www/html 2>/dev/null
  1001. comprobarError $? 106
  1002. unset infoFile
  1003. # Instalar VirtualHost
  1004. virtualHost="./etc/$webServerName/sites-available/phpinfo.conf"
  1005. instalarVirtualHost "/var/www/html" "localhost" $virtualHost
  1006. unset virtualHost
  1007. return 0
  1008. else
  1009. return 1
  1010. fi
  1011. }
  1012. habilitarServicio() {
  1013. # Arrancamos y habilitamos el servicio (con SystemD, Upstart o SystemV)
  1014. # Intentamos con systemctl (SystemD)
  1015. #echo -en "Habilitando Servicio '$1'" | tee -a $logFile
  1016. if [ $# -le 0 ];then
  1017. comprobarError 1 900
  1018. fi
  1019. which systemctl > /dev/null 2>&1
  1020. if [ $? -eq 0 ]; then
  1021. #echo -en " (SystemD)..." | tee -a $logFile
  1022. systemctl start $1 > /dev/null 2>&1
  1023. comprobarError $? 901 $1
  1024. systemctl enable $1 > /dev/null 2>&1
  1025. comprobarError $? 902 $1
  1026. else
  1027. # Intentamos con service (Upstart)
  1028. which service > /dev/null 2>&1
  1029. if [ $? -eq 0 ]; then
  1030. #echo -en " (Upstart)..." | tee -a $logFile
  1031. service $1 start > /dev/null 2>&1
  1032. comprobarError $? 901 $1
  1033. else
  1034. # Intentamos con init.d (SystemV)
  1035. #echo -en " (SystemV)..." | tee -a $logFile
  1036. /etc/init.d/$1 start > /dev/null 2>&1
  1037. comprobarError $? 901 $1
  1038. fi
  1039. # Intentamos habilitar en el arranque (Upstart)
  1040. which update-rc.d > /dev/null 2>&1
  1041. if [ $? -eq 0 ];then
  1042. update-rc.d $1 enable
  1043. comprobarError $? 902 $1
  1044. else
  1045. # Intentamos habilitar en el arranque (SystemV)
  1046. which chkconfig > /dev/null 2>&1
  1047. if [ $? -eq 0 ];then
  1048. chkconfig $1 on
  1049. comprobarError $? 902 $1
  1050. else
  1051. # ¿Qué mas opciones nos quedan?
  1052. comprobarError 1 902 $1
  1053. fi
  1054. fi
  1055. fi
  1056. # Mejora: comprobar si el servicio está parado
  1057. #echo -en " OK.\n" | tee -a $logFile
  1058. }
  1059. deshabilitarServicio() {
  1060. # Paramos y deshabilitamos el servicio (con SystemD, Upstart o SystemV)
  1061. # Intentamos con systemctl (SystemD)
  1062. #echo -en "Deshabilitando Servicio '$1'" | tee -a $logFile
  1063. if [ $# -le 0 ];then
  1064. comprobarError 1 903
  1065. fi
  1066. which systemctl > /dev/null 2>&1
  1067. if [ $? -eq 0 ]; then
  1068. #echo -en " (SystemD)..." | tee -a $logFile
  1069. systemctl stop $1 > /dev/null 2>&1
  1070. comprobarError $? 904 $1
  1071. systemctl disable $1 > /dev/null 2>&1
  1072. comprobarError $? 905 $1
  1073. else
  1074. # Intentamos con service (Upstart)
  1075. which service > /dev/null 2>&1
  1076. if [ $? -eq 0 ]; then
  1077. #echo -en " (Upstart)..." | tee -a $logFile
  1078. service $1 stop > /dev/null 2>&1
  1079. comprobarError $? 904 $1
  1080. else
  1081. # Intentamos con init.d (SystemV)
  1082. #echo -en " (SystemV)..." | tee -a $logFile
  1083. /etc/init.d/$1 stop > /dev/null 2>&1
  1084. comprobarError $? 904 $1
  1085. fi
  1086. # Intentamos habilitar en el arranque (Upstart)
  1087. which update-rc.d > /dev/null 2>&1
  1088. if [ $? -eq 0 ];then
  1089. update-rc.d $1 disable
  1090. comprobarError $? 905 $1
  1091. else
  1092. # Intentamos habilitar en el arranque (SystemV)
  1093. which chkconfig > /dev/null 2>&1
  1094. if [ $? -eq 0 ];then
  1095. chkconfig $1 off
  1096. comprobarError $? 905 $1
  1097. else
  1098. # ¿Qué mas opciones nos quedan?
  1099. comprobarError 1 905 $1
  1100. fi
  1101. fi
  1102. fi
  1103. # Mejora: comprobar si el servicio está funcionando
  1104. #echo -en " OK.\n" | tee -a $logFile
  1105. }
  1106. recargarServicio() {
  1107. # Recargamos el servicio (con SystemD, Upstart o SystemV)
  1108. # Intentamos con systemctl (SystemD)
  1109. #echo -en "Recargando Servicio '$1'" | tee -a $logFile
  1110. if [ $# -le 0 ];then
  1111. comprobarError 1 912
  1112. fi
  1113. which systemctl > /dev/null 2>&1
  1114. if [ $? -eq 0 ]; then
  1115. #echo -en " (SystemD)..." | tee -a $logFile
  1116. systemctl reload $1 > /dev/null 2>&1
  1117. comprobarError $? 913 $1
  1118. else
  1119. # Intentamos con service (Upstart)
  1120. which service > /dev/null 2>&1
  1121. if [ $? -eq 0 ]; then
  1122. #echo -en " (Upstart)..." | tee -a $logFile
  1123. service $1 reload > /dev/null 2>&1
  1124. comprobarError $? 913 $1
  1125. else
  1126. # Intentamos con init.d (SystemV)
  1127. #echo -en " (SystemV)..." | tee -a $logFile
  1128. /etc/init.d/$1 reload > /dev/null 2>&1
  1129. comprobarError $? 913 $1
  1130. fi
  1131. fi
  1132. # Mejora: comprobar si el servicio está funcionando
  1133. #echo -en " OK.\n" | tee -a $logFile
  1134. }
  1135. configurarCortafuegos() {
  1136. # Configuramos cortafuegos (añadir reglas y encender)
  1137. # Comprobamos si estamos usando SSH
  1138. esSSH $PPID
  1139. if [ $debianOS = true ];then
  1140. ufw allow 80/tcp >> $logFile 2>&1
  1141. comprobarError $? 906 "80/tcp"
  1142. if [ $sshControl = true ];then
  1143. ufw allow 22/tcp >> $logFile 2>&1
  1144. comprobarError $? 906 "22/tcp"
  1145. fi
  1146. if [ $sslOn = true ];then
  1147. ufw allow 443/tcp >> $logFile 2>&1
  1148. comprobarError $? 906 "443/tcp"
  1149. fi
  1150. ufw --force enable >> $logFile 2>&1
  1151. comprobarError $? 907
  1152. elif [ $rhelOS = true ];then
  1153. firewall-cmd --add-port=80/tcp >> $logFile 2>&1
  1154. comprobarError $? 906 "80/tcp"
  1155. if [ $sshControl = true ];then
  1156. firewall-cmd --add-port=22/tcp >> $logFile 2>&1
  1157. comprobarError $? 906 "22/tcp"
  1158. fi
  1159. if [ $sslOn = true ];then
  1160. firewall-cmd --add-port=443/tcp >> $logFile 2>&1
  1161. comprobarError $? 906 "443/tcp"
  1162. fi
  1163. firewall-cmd --runtime-to-permanent >> $logFile 2>&1
  1164. comprobarError $? 907
  1165. habilitarServicio firewalld >> $logFile 2>&1
  1166. comprobarError $? 907
  1167. fi
  1168. unset sshControl
  1169. }
  1170. esSSH() {
  1171. p=${1:-$PPID}
  1172. #read pid name x ppid y < <( cat /proc/$p/stat )
  1173. read pid name ppid < <( ps -o pid= -o comm= -o ppid= -p $p)
  1174. [[ "$name" =~ sshd ]] && { sshControl=true; return 0; }
  1175. [ "$ppid" -le 1 ] && { sshControl=false; return 1; }
  1176. esSSH $ppid
  1177. }
  1178. descargarMediaWiki() {
  1179. # Descargar la versión 1.31.0 de MediaWiki
  1180. if [ ! -d ./var ];then
  1181. comprobarError 1 5 "./var"
  1182. fi
  1183. #echo -en "Descargando MediaWiki-1.31.0..." | tee -a $logFile
  1184. #curl -o "./var/mediawiki-1.31.0.tar.gz" "https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.0.tar.gz" >> $logFile 2>&1
  1185. curl "https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.0.tar.gz" 2>$logFile | tar -xz -C "./var/"
  1186. comprobarError $? 501
  1187. #echo -en " Ok.\n" | tee -a $logFile
  1188. }
  1189. configurarMediaWiki() {
  1190. # Configuramos MediaWiki
  1191. # Copiamos archivos y permisos
  1192. cp -R ./var/mediawiki-1.31.0/ /var/www/$dominioMediaWiki
  1193. comprobarError $? 502
  1194. chown -R $webServerUser:$webServerGroup /var/www/$dominioMediaWiki
  1195. comprobarError $? 502
  1196. # Creamos DataBase
  1197. crearDBMediaWiki
  1198. # Configuramos LocalSettings.php
  1199. # Configuramos VirtualHost
  1200. if [ $nginxOn = true ];then
  1201. if [ $sslOn = true ];then
  1202. virtualHost="./etc/nginx/sites-available/mediawiki-ssl.conf"
  1203. else
  1204. virtualHost="./etc/nginx/sites-available/mediawiki.conf"
  1205. fi
  1206. if [ ! -f $virtualHost ];then
  1207. comprobarError $? 502
  1208. fi
  1209. comprobarError $? 502
  1210. fi
  1211. instalarVirtualHost "/etc/$webServerName/" $dominioMediaWiki $virtualHost
  1212. unset virtualHost socket
  1213. }
  1214. crearDBMediaWiki() {
  1215. # Creamos una base de datos para MediaWiki
  1216. dbDir="./etc/db"
  1217. if [ ! -d $dbDir ];then
  1218. mkdir $dbDir 2>/dev/null
  1219. comprobarError $? 503
  1220. fi
  1221. dbFile=$dbDir"/mediawiki.sql"
  1222. nombreDBMW=$(echo $dominioMediaWiki | sed -e 's/\./_/g')
  1223. userDBMW=$(echo $dominioMediaWiki | sed -e 's/\./_/g')
  1224. echo -en "CREATE DATABASE IF NOT EXISTS $nombreDBMW;\n" > $dbFile
  1225. echo -en "GRANT ALL PRIVILEGES ON $nombreDBMW.* TO '$userDBMW'@'localhost' IDENTIFIED BY '$sqlPasswd';\n" >> $dbFile
  1226. mysql -u root --password=$sqlPasswd < $dbFile
  1227. control=$?
  1228. rm -f $dbFile 2>/dev/null
  1229. comprobarError $? 503
  1230. comprobarError $control 503
  1231. unset control
  1232. }
  1233. descargarMoodle() {
  1234. # Descargar la versión 1.31.0 de MediaWiki
  1235. if [ ! -d ./var ];then
  1236. comprobarError 1 5 "./var"
  1237. fi
  1238. #echo -en "Descargando Moodle-3.5-1..." | tee -a $logFile
  1239. #curl -o "./var/moodle-3.5.1.tgz" "https://download.moodle.org/download.php/direct/stable35/moodle-latest-35.tgz" >> $logFile 2>&1
  1240. curl "https://download.moodle.org/download.php/direct/stable35/moodle-latest-35.tgz" 2>$logFile | tar -xz -C "./var/"
  1241. comprobarError $? 501
  1242. #echo -en " OK.\n" | tee -a $logFile
  1243. }
  1244. # Comprobación del sistema e inicialización
  1245. inicializarVariables
  1246. comprobarRoot
  1247. OSInfo
  1248. comprobarDependencias
  1249. # Bienvenida
  1250. mostrarBienvenida
  1251. # Selección de componentes (express vs avanzada)
  1252. mostrarExpress
  1253. # Instalación Servidor Web
  1254. if [ $apacheOn = true ]; then
  1255. echo -en "Instalando Servidor Web Apache..." | tee -a $logFile
  1256. # {
  1257. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1258. instalarApache
  1259. progreso=$((progreso + 1))
  1260. # } > >(whiptail --gauge "Instalando Web Server Apache..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1261. echo -en " OK.\n" | tee -a $logFile
  1262. elif [ $nginxOn = true ]; then
  1263. echo -en "Instalando Servidor Web Nginx..." | tee -a $logFile
  1264. # {
  1265. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1266. instalarNginx
  1267. progreso=$((progreso + 1))
  1268. # } > >(whiptail --gauge "Instalando Web Server Nginx..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1269. echo -en " OK.\n" | tee -a $logFile
  1270. fi
  1271. # Instalación Base de Datos
  1272. if [ $mySQLOn = true ]; then
  1273. echo -en "Instalando Base de Datos MySQL..." | tee -a $logFile
  1274. # {
  1275. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1276. instalarMySQL
  1277. progreso=$((progreso + 1))
  1278. # } > >(whiptail --gauge "Instalando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1279. echo -en " OK.\n" | tee -a $logFile
  1280. elif [ $mariaDBOn = true ]; then
  1281. echo -en "Instalando Base de Datos MariaDB..." | tee -a $logFile
  1282. # {
  1283. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1284. instalarMariaDB
  1285. progreso=$((progreso + 1))
  1286. # } > >(whiptail --gauge "Instalando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1287. echo -en " OK.\n" | tee -a $logFile
  1288. fi
  1289. # Instalación PHP-7.2
  1290. if [ $phpOn = true ]; then
  1291. echo -en "Instalando PHP-7..." | tee -a $logFile
  1292. # {
  1293. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1294. instalarPHP
  1295. progreso=$((progreso + 1))
  1296. # } > >(whiptail --gauge "Instalando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1297. echo -en " OK.\n" | tee -a $logFile
  1298. fi
  1299. # Instalación SSL/TLS
  1300. if [ $sslOn = true ];then
  1301. echo -en "Instalando SSL/TLS..." | tee -a $logfile
  1302. # {
  1303. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1304. sleep 2
  1305. progreso=$((progreso + 1))
  1306. # } > >(whiptail --gauge "Instalando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1307. echo -en " OK.\n" | tee -a $logFile
  1308. fi
  1309. # Configuración Web Server
  1310. if [ $apacheOn = true ];then
  1311. echo -en "Configurando Servidor Web Apache..." | tee -a $logFile
  1312. # {
  1313. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1314. configurarApache
  1315. progreso=$((progreso + 1))
  1316. # } > >(whiptail --gauge "Configurando Servidor Web..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1317. echo -en " OK.\n" | tee -a $logFile
  1318. elif [ $nginxOn = true ]; then
  1319. echo -en "Configurando Servidor Web Nginx..." | tee -a $logFile
  1320. # {
  1321. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1322. configurarNginx
  1323. progreso=$((progreso + 1))
  1324. # } > >(whiptail --gauge "Configurando Servidor Web..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1325. echo -en " OK.\n" | tee -a $logFile
  1326. fi
  1327. # Configuración Database (Arrancar Base de Datos, establecer contraseña y configuración segura)
  1328. if [ $mySQLOn = true ] || [ $mariaDBOn = true ];then
  1329. habilitarServicio "$sqlServerName"
  1330. echo -en "Configurando Base de Datos MySQL..." | tee -a $logFile
  1331. # {
  1332. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1333. establecerSQLPasswd
  1334. progreso=$((progreso + 1))
  1335. # } > >(whiptail --gauge "Configurando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1336. echo -en " OK.\n" | tee -a $logFile
  1337. fi
  1338. # Configuración PHP (cgi.fix_pathinfo=0 y Configurar máximo de subida de archivos)
  1339. if [ $phpOn = true ];then
  1340. echo -en "Configurando PHP-7..." | tee -a $logFile
  1341. # {
  1342. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1343. configurarPHP
  1344. progreso=$((progreso + 1))
  1345. # } > >(whiptail --gauge "Configurando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1346. echo -en " OK.\n" | tee -a $logFile
  1347. fi
  1348. # Configuración SSL/TLS
  1349. # Generar certificados
  1350. # Configurar certificados
  1351. if [ $sslOn = true ];then
  1352. echo -en "Configurando SSL/TLS..." | tee -a $logFile
  1353. # {
  1354. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1355. sleep 2
  1356. progreso=$((progreso + 1))
  1357. # } > >(whiptail --gauge "Configurando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1358. echo -en " OK.\n" | tee -a $logFile
  1359. fi
  1360. # Arrancar y habilitar todos los servicios (SystemD, Service o SystemV)
  1361. # {
  1362. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1363. if [ $apacheOn = true ];then
  1364. habilitarServicio $webServerName
  1365. elif [ $nginxOn = true ];then
  1366. habilitarServicio $webServerName
  1367. if [ $phpOn = true ];then
  1368. habilitarServicio $phpFPMName
  1369. fi
  1370. fi
  1371. progreso=$((progreso + 1))
  1372. # } > >(whiptail --gauge "Arrancando Servicios..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1373. # MediaWiki
  1374. if [ $mediaWikiOn = true ]; then
  1375. # Descargar MediaWiki
  1376. echo -en "Descargando MediaWiki-1.31.0..." | tee -a $logFile
  1377. # {
  1378. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1379. descargarMediaWiki
  1380. progreso=$((progreso + 1))
  1381. # } > >(whiptail --gauge "Instalando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1382. echo -en " OK.\n" | tee -a $logFile
  1383. # Configurar MediWiki
  1384. echo -en "Configurando MediaWiki..." | tee -a $logFile
  1385. # {
  1386. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1387. configurarMediaWiki
  1388. progreso=$((progreso + 1))
  1389. # } > >(whiptail --gauge "Configurando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1390. echo -en " OK.\n" | tee -a $logFile
  1391. fi
  1392. # Moodle
  1393. if [ $moodleOn = true ]; then
  1394. # Descargar Moodle
  1395. echo -en "Descargando Moodle-3.5.1..." | tee -a $logFile
  1396. # {
  1397. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1398. descargarMoodle
  1399. progreso=$((progreso + 1))
  1400. # } > >(whiptail --gauge "Instalando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1401. echo -en " OK.\n" | tee -a $logFile
  1402. # Configuración Moodle
  1403. echo -en "Configurando Moodle..." | tee -a $logFile
  1404. # {
  1405. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1406. sleep 2
  1407. progreso=$((progreso + 1))
  1408. # } > >(whiptail --gauge "Configurando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1409. echo -en " OK.\n" | tee -a $logFile
  1410. fi
  1411. # Configurar Virtual Hosts
  1412. # Instalar info.php
  1413. if [ $infoPHPOn = true ];then
  1414. echo -en "Configurando 'info.php'..." | tee -a $logFile
  1415. instalarPHPInfo
  1416. if [ $? -eq 0 ];then
  1417. echo -en " OK.\n" | tee -a $logFile
  1418. else
  1419. echo -en " Ya se encuentra configurado.\n" | tee -a $logFile
  1420. fi
  1421. fi
  1422. # Añadir reglas del cortafuegos
  1423. echo -en "Configurando Cortafuegos..." | tee -a $logFile
  1424. # {
  1425. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1426. configurarCortafuegos
  1427. progreso=$((progreso + 1))
  1428. # } > >(whiptail --gauge "Configurando Cortafuegos..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1429. echo -en " OK.\n" | tee -a $logFile
  1430. # Configurar actualizaciones
  1431. if [ $actualizacionesOn = true ]; then
  1432. echo -en "Configurando Actualizaciones Automáticas..." | tee -a $logFile
  1433. # {
  1434. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1435. sleep 2
  1436. progreso=$((progreso + 1))
  1437. # } > >(whiptail --gauge "Configurando actualizaciones automáticas..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1438. echo -en " OK.\n" | tee -a $logFile
  1439. fi