install 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495
  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. nombreMediaWiki=""
  466. dominioMediaWiki=""
  467. }
  468. instalacionExpress() {
  469. apacheOn=true
  470. mariaDBOn=true
  471. phpOn=true
  472. sslOn=true
  473. letsEncryptOn=true
  474. mediaWikiOn=true
  475. moodleOn=true
  476. actualizacionesOn=true
  477. progresoTotal=15
  478. # Preguntas mínimas
  479. establecerFQDN
  480. leerSQLPasswd
  481. mostrarMediaWiki
  482. }
  483. mostrarBienvenida() {
  484. ANCHO=$(tput cols)
  485. ALTO=$(tput lines)
  486. if [ $debianOS = false ] && [ $rhelOS = false ]; then
  487. 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"
  488. exit 1
  489. fi
  490. 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"
  491. comprobarError $? 1
  492. }
  493. mostrarExpress() {
  494. 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 \
  495. "Express" "Instalación rápida" ON \
  496. "Avanzada" "Permite escoger todas las opciones disponibles" OFF \
  497. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  498. comprobarError $? 1
  499. case $express in
  500. Express)
  501. instalacionExpress
  502. # DECIDIR QUÉ OPCIONES SON LAS MÍNIMAS
  503. ;;
  504. Avanzada)
  505. mostrarAvanzada
  506. ;;
  507. *)
  508. comprobarError 1 2
  509. ;;
  510. esac
  511. unset express
  512. }
  513. mostrarAvanzada() {
  514. 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 \
  515. "LAMP" "GNU/Linux + Apache + MySQL/MariaDB + PHP-7" ON \
  516. "LEMP" "GNU/Linux + Nginx + MySQL/MariaDB + PHP-7" OFF \
  517. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  518. comprobarError $? 1
  519. for i in $webServer; do
  520. case $i in
  521. LAMP)
  522. apacheOn=true
  523. ;;
  524. LEMP)
  525. nginxOn=true
  526. ;;
  527. *)
  528. comprobarError 1 100
  529. ;;
  530. esac
  531. done
  532. # Opciones comunes
  533. establecerFQDN
  534. mostrarDatabase
  535. phpOn=true
  536. establecerMaxUpload
  537. progresoTotal=$((progresoTotal + 6))
  538. mostrarComponentes
  539. unset webServer
  540. }
  541. mostrarComponentes() {
  542. 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 \
  543. "SSL/TLS" "Instalar certificados para activar HTTPS" ON \
  544. "MediaWiki" "Instalar wiki con MediaWiki" ON \
  545. "Moodle" "Instalar campus virtual con Moodle" ON \
  546. "InfoPHP" "Instalar info.php (sólo para pruebas)" OFF \
  547. "Actualizaciones" "Programar actualizaciones automáticas" ON \
  548. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  549. comprobarError $? 1
  550. # Mejora: autodetección de componentes ya instalados
  551. for i in $componentes; do
  552. case $i in
  553. \"SSL/TLS\")
  554. # 2 Opciones: Let's Encrypt o Autofirmado
  555. mostrarSSL
  556. progresoTotal=$((progresoTotal + 2))
  557. ;;
  558. \"MediaWiki\")
  559. mediaWikiOn=true
  560. mostrarMediaWiki
  561. progresoTotal=$((progresoTotal + 2))
  562. ;;
  563. \"Moodle\")
  564. moodleOn=true
  565. progresoTotal=$((progresoTotal + 2))
  566. ;;
  567. \"InfoPHP\")
  568. infoPHPOn=true
  569. progresoTotal=$((progresoTotal + 2))
  570. ;;
  571. \"Actualizaciones\")
  572. actualizacionesOn=true
  573. progresoTotal=$((progresoTotal + 1))
  574. ;;
  575. *)
  576. comprobarError 1 3
  577. ;;
  578. esac
  579. done
  580. progresoTotal=$((progresoTotal + 2))
  581. unset componentes
  582. }
  583. mostrarSSL() {
  584. 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 \
  585. "LetsEncrypt" "Compatible con todos los navegadores" ON \
  586. "Auto-Firmado" "Certificados auto-firmados (sólo para pruebas)" OFF \
  587. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  588. comprobarError $? 1
  589. for i in $ssl; do
  590. case $i in
  591. LetsEncrypt)
  592. sslOn=true
  593. letsEcnryptOn=true
  594. ;;
  595. Auto-Firmados)
  596. sslOn=true
  597. ;;
  598. *)
  599. comprobarError 1 6
  600. ;;
  601. esac
  602. done
  603. unset ssl
  604. }
  605. mostrarMediaWiki(){
  606. # Introducir nombre wiki
  607. while [ -z $nombreMediaWiki ]; do
  608. nombreMediaWiki=$(whiptail --title "CONFIGURACION MEDIAWIKI" --inputbox "Introduzca el nombre de la Wiki:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  609. comprobarError $? 1
  610. # Mejora: comprobar si el dominio ya está en uso
  611. done
  612. # Introducir dominio
  613. while [ -z $dominioMediaWiki ]; do
  614. 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)
  615. comprobarError $? 1
  616. # Mejora: comprobar si el dominio ya está en uso
  617. done
  618. # Introducir contraseña
  619. control=false
  620. error=""
  621. while [ $control = false ]; do
  622. passwdMediaWiki=$(whiptail --title "CONFIGURACION MEDIAWIKI" --passwordbox "$error""Introduzca la contraseña para el usuario administrador 'admin':" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) --ok-button "Continuar" --nocancel 3>&1 1>&2 2>&3)
  623. comprobarError $? 1
  624. passwdMediaWiki2=$(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)
  625. comprobarError $? 1
  626. if [ -z $passwdMediaWiki ] || [ -z $passwdMediaWiki2 ]; then
  627. error="ERROR: LA CONTRASEÑA NO PUEDE ESTAR VACIA.\n"
  628. elif [ $passwdMediaWiki != $passwdMediaWiki2 ];then
  629. error="ERROR: LAS CONTRASEÑAS NO COINCIDEN.\n"
  630. else
  631. control=true
  632. fi
  633. done
  634. unset control error passwdMediaWiki2
  635. }
  636. establecerFQDN() {
  637. while [ -z $hostname ]; do
  638. 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)
  639. if [ $? -eq 0 ] && [ ! -z $hostname ]; then
  640. hostnamectl set-hostname $hostname
  641. else
  642. hostname=$(hostname)
  643. fi
  644. done
  645. echo -en "Hostname: $hostname\n" >> $logFile
  646. }
  647. instalarApache() {
  648. if [ $debianOS = true ];then
  649. webServerName="apache2"
  650. result=$(apt-get -q -y install apache2 2>&1)
  651. comprobarError $? 101 $result
  652. elif [ $rhelOS = true ]; then
  653. webServerName="httpd"
  654. result=$(yum -y install httpd 2>&1)
  655. comprobarError $? 101 $result
  656. else
  657. comprobarError 1 104
  658. fi
  659. deshabilitarServicio $webServerName
  660. }
  661. configurarApache() {
  662. if [ $debianOS = true ];then
  663. apacheConfFile="./etc/$webServerName-debian/apache2.conf"
  664. if [ ! -f $apacheConfFile ];then
  665. comprobarError 1 4 $apacheConfFile
  666. fi
  667. cp -f $apacheConfFile /etc/$webServerName/apache2.conf 2>/dev/null
  668. comprobarError $? 108
  669. webServerUser=$(grep ^User /etc/$webServerName/apache2.conf | cut -d ' ' -f 2)
  670. webServerGroup=$(grep ^Group /etc/$webServerName/apache2.conf | cut -d ' ' -f 2)
  671. elif [ $rhelOS = true ];then
  672. apacheConfFile="./etc/$webServerName-rhel/conf/httpd.conf"
  673. welcomeConfFile="/etc/$webServerName/conf.d/welcome.conf"
  674. if [ ! -f $apacheConfFile ];then
  675. comprobarError 1 4 $apacheConfFile
  676. fi
  677. cp -f $apacheConfFile /etc/$webServerName/conf/ 2>/dev/null
  678. comprobarError $? 108
  679. if [ -f $welcomeConfFile ];then
  680. sed -i -e 's/^/#/' $welcomeConfFile
  681. comprobarError $? 108
  682. fi
  683. webServerUser=$(grep ^User /etc/$webServerName/conf/httpd.conf | cut -d ' ' -f 2)
  684. webServerGroup=$(grep ^Group /etc/$webServerName/conf/httpd.conf | cut -d ' ' -f 2)
  685. unset apacheConfFile welcomeConfFile
  686. fi
  687. if [ ! -d "/etc/$webServerName/sites-available" ];then
  688. mkdir "/etc/$webServerName/sites-available" 2>/dev/null
  689. comprobarError $? 5 "/etc/$webServerName/sites-available"
  690. fi
  691. if [ ! -d "/etc/$webServerName/sites-enabled" ]; then
  692. mkdir "/etc/$webServerName/sites-enabled" 2>/dev/null
  693. comprobarError $? 5 "$webServerRoot/sites-enabled"
  694. fi
  695. }
  696. instalarNginx() {
  697. webServerName="nginx"
  698. if [ $debianOS = true ];then
  699. result=$(apt-get -q -y install nginx 2>&1)
  700. comprobarError $? 102 $result
  701. elif [ $rhelOS = true ]; then
  702. # Hay que instalar primero otro repositorio
  703. result=$(yum -y install epel-release)
  704. comprobarError $? 103 $result
  705. result=$(yum -y install nginx 2>&1)
  706. comprobarError $? 102 $result
  707. else
  708. comprobarError 1 105
  709. fi
  710. deshabilitarServicio $webServerName
  711. }
  712. configurarNginx() {
  713. # Configuramos Nginx
  714. rm -Rf /etc/$webServerName/* 2>/dev/null
  715. comprobarError $? 107
  716. nginxConfFile="./etc/$webServerName"
  717. if [ -d "$nginxConfFile" ];then
  718. cp -Rf $nginxConfFile/* /etc/$webServerName/ 2>/dev/null
  719. comprobarError $? 107
  720. else
  721. comprobarError 1 5 "$nginxConfFile"
  722. fi
  723. if [ ! -d "/etc/$webServerName/sites-available" ];then
  724. mkdir "/etc/$webServerName/sites-available" 2>/dev/null
  725. comprobarError $? 5 "/etc/$webServerName/sites-available"
  726. fi
  727. if [ ! -d "/etc/$webServerName/sites-enabled" ]; then
  728. mkdir "/etc/$webServerName/sites-enabled" 2>/dev/null
  729. comprobarError $? 5 "$webServerRoot/sites-enabled"
  730. fi
  731. # Configuramos Usuario y Grupo
  732. if [ $debianOS = true ];then
  733. webServerUser="www-data"
  734. webServerGroup=$webServerUser
  735. elif [ $rhelOS = true ];then
  736. webServerUser="nginx"
  737. webServerGroup=$webServerUser
  738. fi
  739. sed -i '/user /c\user '$webServerUser';' /etc/$webServerName/nginx.conf
  740. comprobarError $? 107
  741. unset nginxConfFile
  742. }
  743. instalarVirtualHost() {
  744. # Configuramos un Virtual Host para Apache o Nginx
  745. # Uso: instalarVirtualHost $root $dominio $virtualHost
  746. webServerRoot=$(realpath "/etc/$webServerName/")
  747. if [ $# -eq 3 ];then
  748. rootVirtualHost=$(realpath $1)
  749. dominioVirtualHost=$2
  750. virtualHostFile=$(realpath $3)
  751. virtualHostName=$dominioVirtualHost".conf"
  752. else
  753. comprobarError 1 908
  754. fi
  755. if [ ! -f $virtualHostFile ];then
  756. comprobarError 1 909 $virtualHostName
  757. fi
  758. if [ $nginxOn = true ];then
  759. # Configuramos root, dominio, logs y php-fpm.sock (NGINX)
  760. sed -i '/root /c\\troot '/var/www/$dominioVirtualHost';' $virtualHostFile
  761. comprobarError $? 502
  762. sed -i '/server_name /c\\tserver_name '$dominioVirtualHost';' $virtualHostFile
  763. comprobarError $? 502
  764. sed -i '/access_log /c\\taccess_log /var/log/nginx/'$dominioVirtualHost'-access.log;' $virtualHostFile
  765. comprobarError $? 502
  766. sed -i '/error_log /c\\terror_log /var/log/nginx/'$dominioVirtualHost'-error.log;' $virtualHostFile
  767. comprobarError $? 502
  768. socket=$(find /var/run/ -type s -name 'php*.sock')
  769. sed -i '/fastcgi_pass /c\\t\tfastcgi_pass unix:'$socket';' $virtualHostFile
  770. fi
  771. # Copiamos ficheros de configuración
  772. cp -f $virtualHostFile "$webServerRoot/sites-available/$virtualHostName" >> $logFile 2>&1
  773. comprobarError $? 910
  774. ln -s "$webServerRoot/sites-available/$virtualHostName" "$webServerRoot/sites-enabled/$virtualHostName" >> $logFile 2>&1
  775. comprobarError $? 911 $virtualHostName
  776. recargarServicio $webServerName
  777. unset webServerRoot rootVirtualHost dominioVirtualHost virtualHostFile virtualHostName
  778. }
  779. mostrarDatabase() {
  780. if [ $debianOS = true ]; then
  781. 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 \
  782. "MariaDB" "Instalar la base de datos MariaDB (fork de MySQL)" ON \
  783. "MySQL" "Instalar la base de datos MySQL (uso no comercial)" OFF \
  784. --ok-button "Continuar" --cancel-button "Salir" 3>&1 1>&2 2>&3)
  785. comprobarError $? 1
  786. case $database in
  787. MariaDB)
  788. mariaDBOn=true
  789. ;;
  790. MySQL)
  791. mySQLOn=true
  792. ;;
  793. *)
  794. comprobarError 1 200
  795. ;;
  796. esac
  797. unset database
  798. elif [ $rhelOS = true ]; then
  799. 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"
  800. comprobarError $? 1
  801. mariaDBOn=true
  802. else
  803. comprobarError 1 200
  804. fi
  805. # Otras opciones (contraseña)
  806. leerSQLPasswd
  807. }
  808. leerSQLPasswd() {
  809. control=false
  810. error=""
  811. # Leemos la contreseña (stdin) y confirmamos
  812. while [ $control = false ]; do
  813. 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)
  814. comprobarError $? 1
  815. 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)
  816. comprobarError $? 1
  817. #echo -en "SQL Password 1: $sqlPasswd\n"
  818. #echo -en "SQL Password 2: $sqlPasswd2\n"
  819. if [ -z $sqlPasswd ] || [ -z $sqlPasswd2 ]; then
  820. error="ERROR: LA CONTRASEÑA NO PUEDE ESTAR VACIA.\n"
  821. elif [ $sqlPasswd != $sqlPasswd2 ];then
  822. error="ERROR: LAS CONTRASEÑAS NO COINCIDEN.\n"
  823. else
  824. control=true
  825. fi
  826. done
  827. #echo -en "SQL Password: $sqlPasswd\n"
  828. unset control error sqlPasswd2
  829. }
  830. establecerSQLPasswd() {
  831. # Establecemos SQL root passwd y securizamos BD (mysql_secure_installation)
  832. # Comprobamos si ya tiene una contraseña asignada
  833. mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
  834. if [ $? -eq 0 ];then
  835. # Establecemos contraseña del usuario root (y desactivamos posibles plugins para forzar login por contraseña)
  836. mysql -e "UPDATE mysql.user SET plugin = '', Password = PASSWORD('$sqlPasswd') WHERE User = 'root'" >> $logFile 2>&1
  837. comprobarError $? 207
  838. # Desactivamos acceso root desde el exterior (solo localhost)
  839. mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" >> $logFile 2>&1
  840. comprobarError $? 208
  841. # Eliminamos todos los usuarios anónimos
  842. mysql -e "DELETE FROM mysql.user WHERE User=''" >> $logFile 2>&1
  843. comprobarError $? 209
  844. # Eliminamos bases de datos 'test'
  845. mysql -e "DROP DATABASE IF EXISTS test" >> $logFile 2>&1
  846. comprobarError $? 210
  847. # Eliminamos privilegios de la base de datos 'test'
  848. mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'" >> $logFile 2>&1
  849. comprobarError $? 211
  850. # Aplicamos los cambios
  851. mysql -e "FLUSH PRIVILEGES" >> $logFile 2>&1
  852. comprobarError $? 212
  853. else
  854. comprobarError 1 206
  855. fi
  856. }
  857. instalarMySQL() {
  858. sqlServerName="mysql"
  859. if [ $debianOS = true ];then
  860. result=$(apt-get -q -y install mysql-server mysql-client 2>&1)
  861. comprobarError $? 201 $result
  862. elif [ $rhelOS = true ];then
  863. # MySQL no disponible en RHEL. 2 opciones:
  864. # 1) Instalar un repositorio adicional
  865. # 2) No instalar MySQL en distribuciones RHEL
  866. comprobarError 1 205
  867. else
  868. comprobarError 1 203
  869. fi
  870. }
  871. instalarMariaDB() {
  872. sqlServerName="mariadb"
  873. if [ $debianOS = true ];then
  874. result=$(apt-get -q -y install mariadb-server mariadb-client 2>&1)
  875. comprobarError $? 202 $result
  876. elif [ $rhelOS = true ];then
  877. result=$(yum -y install mariadb-server mariadb 2>&1)
  878. comprobarError $? 202 $result
  879. else
  880. comprobarError 1 204
  881. fi
  882. }
  883. instalarPHP() {
  884. # Instalamos PHP-7 de forma diferente si es junto a Apache o con Nginx
  885. if [ $debianOS = true ];then
  886. if [ $apacheOn = true ]; then
  887. result=$(apt-get -q -y install php libapache2-mod-php php-mysql php-intl php-mbstring php-xml php-apcu php-gd 2>&1)
  888. comprobarError $? 302 $result
  889. elif [ $nginxOn = true ];then
  890. phpFPMName="php7.2-fpm"
  891. result=$(apt-get -q -y install php-fpm php-mysql php-intl php-mbstring php-xml php-apcu php-gd 2>&1)
  892. comprobarError $? 302 $result
  893. deshabilitarServicio $phpFPMName
  894. else
  895. comprobarError 1 301
  896. fi
  897. elif [ $rhelOS = true ];then
  898. # Necesitamos un repositorio adicional para PHP-7 (EPEL-RELEASE)
  899. result=$(yum -y install epel-release yum-utils 2>&1)
  900. comprobarError $? 103 $result
  901. # Necesitamos un repositorio adicional para PHP-7 (REMI-RELEASE)
  902. if [ ! -f /etc/yum.repos.d/remi-php72.repo ];then
  903. if [ $VERSION = "7" ];then
  904. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-7.rpm 2>&1)
  905. comprobarError $? 303 $result
  906. elif [ $VERSION = "6" ];then
  907. result=$(yum -y install http://remi.mirrors.cu.be/enterprise/remi-release-6.rpm 2>&1)
  908. comprobarError $? 303 $result
  909. elif [ $VERSION = "28" ];then
  910. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-28.rpm 2>&1)
  911. comprobarError $? 303 $result
  912. elif [ $VERSION = "27" ];then
  913. result=$(yum -y install http://remi.mirrors.cu.be/fedora/remi-release-27.rpm 2>&1)
  914. comprobarError $? 303 $result
  915. else
  916. comprobarError 1 304
  917. fi
  918. fi
  919. # Activamos repositorio remi-php72
  920. result=$(yum-config-manager --enable remi-php72 2>&1)
  921. comprobarError $? 303 $result
  922. # Instalamos PHP-7.2
  923. if [ $apacheOn = true ];then
  924. result=$(yum -y install php php-mysql php-intl php-mbstring php-mcrypt php-xml php-pecl-apcu php-gd 2>&1)
  925. comprobarError $? 302 $result
  926. elif [ $nginxOn = true ];then
  927. phpFPMName="php-fpm"
  928. result=$(yum -y install php php-fpm php-mysql php-intl php-mbstring php-mcrypt php-xml php-pecl-apcu php-gd 2>&1)
  929. comprobarError $? 302 $result
  930. deshabilitarServicio $phpFPMName
  931. else
  932. comprobarError 1 301
  933. fi
  934. else
  935. comprobarError 1 300
  936. fi
  937. }
  938. configurarPHP() {
  939. # Configura PHP para segurizarlo y establecer máximo de subida.
  940. if [ $debianOS = true ];then
  941. phpConfFile="./etc/php/php.ini.debian"
  942. phpDest="/etc/php/7.2/cli/php.ini"
  943. elif [ $rhelOS = true ];then
  944. phpConfFile="./etc/php/php.ini.rhel"
  945. phpDest="/etc/php.ini"
  946. fi
  947. if [ ! -f $phpConfFile ];then
  948. comprobarError 1 4 "$phpConfFile"
  949. fi
  950. # Copiamos configuración
  951. cp -f $phpConfFile $phpDest 2>/dev/null
  952. comprobarError $? 305
  953. # Configuramos cgi.fix_pathinfo
  954. sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=0' $phpDest
  955. comprobarError $? 305
  956. # Configuramos post_max_size
  957. sed -i '/post_max_size =/c\post_max_size = '$maxUpload $phpDest
  958. comprobarError $? 305
  959. # Configuramos upload_max_filesize
  960. sed -i '/upload_max_filesize =/c\upload_max_filesize = '$maxUpload $phpDest
  961. comprobarError $? 305
  962. # Configurar php-fpm (sólo en RHEL con Nginx)
  963. if [ $rhelOS = true ] && [ $nginxOn = true ];then
  964. # Configurar Socket UNIX
  965. phpConfFile="./etc/php/php-fpm.d/www.conf"
  966. phpDest="/etc/php-fpm.d/www.conf"
  967. if [ ! -f $phpConfFile ];then
  968. comprobarError $? 4 "$phpConfFile"
  969. fi
  970. cp -f $phpConfFile $phpDest 2>/dev/null
  971. comprobarError $? 305
  972. # Configurar Permisos /var/lib/php
  973. chown -R $webServerUser:$webServerGroup /var/lib/php/
  974. comprobarError $? 305
  975. fi
  976. unset phpConfFile phpDest
  977. }
  978. establecerMaxUpload() {
  979. control=false
  980. error=""
  981. while [ $control = false ];do
  982. 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)
  983. comprobarError $? 1
  984. if [ -z $maxUpload2 ];then
  985. error="ERROR: NO PUEDES DEJAR ESTE PARÁMETRO VACIO.\n"
  986. else
  987. control=true
  988. fi
  989. done
  990. maxUpload=$maxUpload2
  991. unset control maxUpload2
  992. }
  993. instalarPHPInfo() {
  994. # Instalar fichero php
  995. if [ ! -f /etc/$webServerName/sites-enabled/phpinfo.conf ];then
  996. infoFile="./var/www/info.php"
  997. if [ ! -f $infoFile ];then
  998. comprobarError 1 4 "$infoFile"
  999. fi
  1000. cp -f $infoFile /var/www/html/ 2>/dev/null
  1001. comprobarError $? 106
  1002. chown -R $webServerUser:$webServerGroup /var/www/html 2>/dev/null
  1003. comprobarError $? 106
  1004. unset infoFile
  1005. # Instalar VirtualHost
  1006. virtualHost="./etc/$webServerName/sites-available/phpinfo.conf"
  1007. instalarVirtualHost "/var/www/html" "localhost" $virtualHost
  1008. unset virtualHost
  1009. return 0
  1010. else
  1011. return 1
  1012. fi
  1013. }
  1014. habilitarServicio() {
  1015. # Arrancamos y habilitamos el servicio (con SystemD, Upstart o SystemV)
  1016. # Intentamos con systemctl (SystemD)
  1017. #echo -en "Habilitando Servicio '$1'" | tee -a $logFile
  1018. if [ $# -le 0 ];then
  1019. comprobarError 1 900
  1020. fi
  1021. which systemctl > /dev/null 2>&1
  1022. if [ $? -eq 0 ]; then
  1023. #echo -en " (SystemD)..." | tee -a $logFile
  1024. systemctl start $1 > /dev/null 2>&1
  1025. comprobarError $? 901 $1
  1026. systemctl enable $1 > /dev/null 2>&1
  1027. comprobarError $? 902 $1
  1028. else
  1029. # Intentamos con service (Upstart)
  1030. which service > /dev/null 2>&1
  1031. if [ $? -eq 0 ]; then
  1032. #echo -en " (Upstart)..." | tee -a $logFile
  1033. service $1 start > /dev/null 2>&1
  1034. comprobarError $? 901 $1
  1035. else
  1036. # Intentamos con init.d (SystemV)
  1037. #echo -en " (SystemV)..." | tee -a $logFile
  1038. /etc/init.d/$1 start > /dev/null 2>&1
  1039. comprobarError $? 901 $1
  1040. fi
  1041. # Intentamos habilitar en el arranque (Upstart)
  1042. which update-rc.d > /dev/null 2>&1
  1043. if [ $? -eq 0 ];then
  1044. update-rc.d $1 enable
  1045. comprobarError $? 902 $1
  1046. else
  1047. # Intentamos habilitar en el arranque (SystemV)
  1048. which chkconfig > /dev/null 2>&1
  1049. if [ $? -eq 0 ];then
  1050. chkconfig $1 on
  1051. comprobarError $? 902 $1
  1052. else
  1053. # ¿Qué mas opciones nos quedan?
  1054. comprobarError 1 902 $1
  1055. fi
  1056. fi
  1057. fi
  1058. # Mejora: comprobar si el servicio está parado
  1059. #echo -en " OK.\n" | tee -a $logFile
  1060. }
  1061. deshabilitarServicio() {
  1062. # Paramos y deshabilitamos el servicio (con SystemD, Upstart o SystemV)
  1063. # Intentamos con systemctl (SystemD)
  1064. #echo -en "Deshabilitando Servicio '$1'" | tee -a $logFile
  1065. if [ $# -le 0 ];then
  1066. comprobarError 1 903
  1067. fi
  1068. which systemctl > /dev/null 2>&1
  1069. if [ $? -eq 0 ]; then
  1070. #echo -en " (SystemD)..." | tee -a $logFile
  1071. systemctl stop $1 > /dev/null 2>&1
  1072. comprobarError $? 904 $1
  1073. systemctl disable $1 > /dev/null 2>&1
  1074. comprobarError $? 905 $1
  1075. else
  1076. # Intentamos con service (Upstart)
  1077. which service > /dev/null 2>&1
  1078. if [ $? -eq 0 ]; then
  1079. #echo -en " (Upstart)..." | tee -a $logFile
  1080. service $1 stop > /dev/null 2>&1
  1081. comprobarError $? 904 $1
  1082. else
  1083. # Intentamos con init.d (SystemV)
  1084. #echo -en " (SystemV)..." | tee -a $logFile
  1085. /etc/init.d/$1 stop > /dev/null 2>&1
  1086. comprobarError $? 904 $1
  1087. fi
  1088. # Intentamos habilitar en el arranque (Upstart)
  1089. which update-rc.d > /dev/null 2>&1
  1090. if [ $? -eq 0 ];then
  1091. update-rc.d $1 disable
  1092. comprobarError $? 905 $1
  1093. else
  1094. # Intentamos habilitar en el arranque (SystemV)
  1095. which chkconfig > /dev/null 2>&1
  1096. if [ $? -eq 0 ];then
  1097. chkconfig $1 off
  1098. comprobarError $? 905 $1
  1099. else
  1100. # ¿Qué mas opciones nos quedan?
  1101. comprobarError 1 905 $1
  1102. fi
  1103. fi
  1104. fi
  1105. # Mejora: comprobar si el servicio está funcionando
  1106. #echo -en " OK.\n" | tee -a $logFile
  1107. }
  1108. recargarServicio() {
  1109. # Recargamos el servicio (con SystemD, Upstart o SystemV)
  1110. # Intentamos con systemctl (SystemD)
  1111. #echo -en "Recargando Servicio '$1'" | tee -a $logFile
  1112. if [ $# -le 0 ];then
  1113. comprobarError 1 912
  1114. fi
  1115. which systemctl > /dev/null 2>&1
  1116. if [ $? -eq 0 ]; then
  1117. #echo -en " (SystemD)..." | tee -a $logFile
  1118. systemctl reload $1 > /dev/null 2>&1
  1119. comprobarError $? 913 $1
  1120. else
  1121. # Intentamos con service (Upstart)
  1122. which service > /dev/null 2>&1
  1123. if [ $? -eq 0 ]; then
  1124. #echo -en " (Upstart)..." | tee -a $logFile
  1125. service $1 reload > /dev/null 2>&1
  1126. comprobarError $? 913 $1
  1127. else
  1128. # Intentamos con init.d (SystemV)
  1129. #echo -en " (SystemV)..." | tee -a $logFile
  1130. /etc/init.d/$1 reload > /dev/null 2>&1
  1131. comprobarError $? 913 $1
  1132. fi
  1133. fi
  1134. # Mejora: comprobar si el servicio está funcionando
  1135. #echo -en " OK.\n" | tee -a $logFile
  1136. }
  1137. configurarCortafuegos() {
  1138. # Configuramos cortafuegos (añadir reglas y encender)
  1139. # Comprobamos si estamos usando SSH
  1140. esSSH $PPID
  1141. if [ $debianOS = true ];then
  1142. ufw allow 80/tcp >> $logFile 2>&1
  1143. comprobarError $? 906 "80/tcp"
  1144. if [ $sshControl = true ];then
  1145. ufw allow 22/tcp >> $logFile 2>&1
  1146. comprobarError $? 906 "22/tcp"
  1147. fi
  1148. if [ $sslOn = true ];then
  1149. ufw allow 443/tcp >> $logFile 2>&1
  1150. comprobarError $? 906 "443/tcp"
  1151. fi
  1152. ufw --force enable >> $logFile 2>&1
  1153. comprobarError $? 907
  1154. elif [ $rhelOS = true ];then
  1155. firewall-cmd --add-port=80/tcp >> $logFile 2>&1
  1156. comprobarError $? 906 "80/tcp"
  1157. if [ $sshControl = true ];then
  1158. firewall-cmd --add-port=22/tcp >> $logFile 2>&1
  1159. comprobarError $? 906 "22/tcp"
  1160. fi
  1161. if [ $sslOn = true ];then
  1162. firewall-cmd --add-port=443/tcp >> $logFile 2>&1
  1163. comprobarError $? 906 "443/tcp"
  1164. fi
  1165. firewall-cmd --runtime-to-permanent >> $logFile 2>&1
  1166. comprobarError $? 907
  1167. habilitarServicio firewalld >> $logFile 2>&1
  1168. comprobarError $? 907
  1169. fi
  1170. unset sshControl
  1171. }
  1172. esSSH() {
  1173. p=${1:-$PPID}
  1174. #read pid name x ppid y < <( cat /proc/$p/stat )
  1175. read pid name ppid < <( ps -o pid= -o comm= -o ppid= -p $p)
  1176. [[ "$name" =~ sshd ]] && { sshControl=true; return 0; }
  1177. [ "$ppid" -le 1 ] && { sshControl=false; return 1; }
  1178. esSSH $ppid
  1179. }
  1180. descargarMediaWiki() {
  1181. # Descargar la versión 1.31.0 de MediaWiki
  1182. if [ ! -d ./var ];then
  1183. comprobarError 1 5 "./var"
  1184. fi
  1185. #echo -en "Descargando MediaWiki-1.31.0..." | tee -a $logFile
  1186. #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
  1187. curl "https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.0.tar.gz" 2>/dev/null | tar -xz -C "./var/"
  1188. comprobarError $? 501
  1189. #echo -en " Ok.\n" | tee -a $logFile
  1190. }
  1191. configurarMediaWiki() {
  1192. # Configuramos MediaWiki
  1193. # Copiamos archivos y permisos
  1194. cp -R ./var/mediawiki-1.31.0/ /var/www/$dominioMediaWiki
  1195. comprobarError $? 502
  1196. # Configuramos LocalSettings.php (y crea la base de datos por nosotros)
  1197. nombreDBMW=$(echo $dominioMediaWiki | sed -e 's/\./_/g')
  1198. userDBMW=$(echo $dominioMediaWiki | sed -e 's/\./_/g')
  1199. php /var/www/$dominioMediaWiki/maintenance/install.php --dbname=$nombreDBMW --dbserver="localhost" --installdbuser=root --installdbpass=$sqlPasswd --dbuser=$userDBMW --dbpass=$sqlPasswd --scriptpath="" --lang=es --pass=$passwdMediaWiki "$nombreMediaWiki" "admin" >> $logFile 2>&1
  1200. comprobarError $? 502
  1201. # Configuraciones adicionales
  1202. sed -i '/$wgEnableEmail =/c\$wgEnableEmail = false;' /var/www/$dominioMediaWiki/LocalSettings.php
  1203. comprobarError $? 502
  1204. sed -i '/$wgEnableUploads =/c\$wgEnableUploads = true;' /var/www/$dominioMediaWiki/LocalSettings.php
  1205. comprobarError $? 502
  1206. echo -en "\$wgArticlePath = \"/wiki/\$1\";\n" >> /var/www/$dominioMediaWiki/LocalSettings.php
  1207. echo -en "\$wgUsePathInfo = true;\n" >> /var/www/$dominioMediaWiki/LocalSettings.php
  1208. echo -en "\$wgGroupPermissions['*']['createaccount'] = false;\n" >> /var/www/$dominioMediaWiki/LocalSettings.php
  1209. echo -en "\$wgGroupPermissions['*']['edit'] = true;\n" >> /var/www/$dominioMediaWiki/LocalSettings.php
  1210. echo -en "\$wgGroupPermissions['*']['read'] = true;\n" >> /var/www/$dominioMediaWiki/LocalSettings.php
  1211. # Actualizamos permisos
  1212. chown -R $webServerUser:$webServerGroup /var/www/$dominioMediaWiki
  1213. comprobarError $? 502
  1214. # Configuramos VirtualHost
  1215. if [ $nginxOn = true ];then
  1216. if [ $sslOn = true ];then
  1217. virtualHost="./etc/nginx/sites-available/mediawiki-ssl.conf"
  1218. else
  1219. virtualHost="./etc/nginx/sites-available/mediawiki.conf"
  1220. fi
  1221. if [ ! -f $virtualHost ];then
  1222. comprobarError $? 502
  1223. fi
  1224. comprobarError $? 502
  1225. fi
  1226. instalarVirtualHost "/etc/$webServerName/" $dominioMediaWiki $virtualHost
  1227. unset virtualHost socket
  1228. }
  1229. crearDBMediaWiki() {
  1230. # DEPRECATED: Borrar
  1231. # Creamos una base de datos para MediaWiki
  1232. dbDir="./etc/db"
  1233. if [ ! -d $dbDir ];then
  1234. mkdir $dbDir 2>/dev/null
  1235. comprobarError $? 503
  1236. fi
  1237. dbFile=$dbDir"/mediawiki.sql"
  1238. nombreDBMW=$(echo $dominioMediaWiki | sed -e 's/\./_/g')
  1239. userDBMW=$(echo $dominioMediaWiki | sed -e 's/\./_/g')
  1240. echo -en "CREATE DATABASE IF NOT EXISTS $nombreDBMW;\n" > $dbFile
  1241. echo -en "GRANT ALL PRIVILEGES ON $nombreDBMW.* TO '$userDBMW'@'localhost' IDENTIFIED BY '$sqlPasswd';\n" >> $dbFile
  1242. mysql -u root --password=$sqlPasswd < $dbFile
  1243. control=$?
  1244. rm -f $dbFile 2>/dev/null
  1245. comprobarError $? 503
  1246. comprobarError $control 503
  1247. unset control dbFile
  1248. }
  1249. descargarMoodle() {
  1250. # Descargar la versión 1.31.0 de MediaWiki
  1251. if [ ! -d ./var ];then
  1252. comprobarError 1 5 "./var"
  1253. fi
  1254. #echo -en "Descargando Moodle-3.5-1..." | tee -a $logFile
  1255. #curl -o "./var/moodle-3.5.1.tgz" "https://download.moodle.org/download.php/direct/stable35/moodle-latest-35.tgz" >> $logFile 2>&1
  1256. curl "https://download.moodle.org/download.php/direct/stable35/moodle-latest-35.tgz" 2>$logFile | tar -xz -C "./var/"
  1257. comprobarError $? 501
  1258. #echo -en " OK.\n" | tee -a $logFile
  1259. }
  1260. # Comprobación del sistema e inicialización
  1261. inicializarVariables
  1262. comprobarRoot
  1263. OSInfo
  1264. comprobarDependencias
  1265. # Bienvenida
  1266. mostrarBienvenida
  1267. # Selección de componentes (express vs avanzada)
  1268. mostrarExpress
  1269. # Instalación Servidor Web
  1270. if [ $apacheOn = true ]; then
  1271. echo -en "Instalando Servidor Web Apache..." | tee -a $logFile
  1272. # {
  1273. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1274. instalarApache
  1275. progreso=$((progreso + 1))
  1276. # } > >(whiptail --gauge "Instalando Web Server Apache..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1277. echo -en " OK.\n" | tee -a $logFile
  1278. elif [ $nginxOn = true ]; then
  1279. echo -en "Instalando Servidor Web Nginx..." | tee -a $logFile
  1280. # {
  1281. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1282. instalarNginx
  1283. progreso=$((progreso + 1))
  1284. # } > >(whiptail --gauge "Instalando Web Server Nginx..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1285. echo -en " OK.\n" | tee -a $logFile
  1286. fi
  1287. # Instalación Base de Datos
  1288. if [ $mySQLOn = true ]; then
  1289. echo -en "Instalando Base de Datos MySQL..." | tee -a $logFile
  1290. # {
  1291. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1292. instalarMySQL
  1293. progreso=$((progreso + 1))
  1294. # } > >(whiptail --gauge "Instalando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1295. echo -en " OK.\n" | tee -a $logFile
  1296. elif [ $mariaDBOn = true ]; then
  1297. echo -en "Instalando Base de Datos MariaDB..." | tee -a $logFile
  1298. # {
  1299. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1300. instalarMariaDB
  1301. progreso=$((progreso + 1))
  1302. # } > >(whiptail --gauge "Instalando Base de Datos MariaDB..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1303. echo -en " OK.\n" | tee -a $logFile
  1304. fi
  1305. # Instalación PHP-7.2
  1306. if [ $phpOn = true ]; then
  1307. echo -en "Instalando PHP-7..." | tee -a $logFile
  1308. # {
  1309. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1310. instalarPHP
  1311. progreso=$((progreso + 1))
  1312. # } > >(whiptail --gauge "Instalando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1313. echo -en " OK.\n" | tee -a $logFile
  1314. fi
  1315. # Instalación SSL/TLS
  1316. if [ $sslOn = true ];then
  1317. echo -en "Instalando SSL/TLS..." | tee -a $logfile
  1318. # {
  1319. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1320. sleep 2
  1321. progreso=$((progreso + 1))
  1322. # } > >(whiptail --gauge "Instalando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1323. echo -en " OK.\n" | tee -a $logFile
  1324. fi
  1325. # Configuración Web Server
  1326. if [ $apacheOn = true ];then
  1327. echo -en "Configurando Servidor Web Apache..." | tee -a $logFile
  1328. # {
  1329. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1330. configurarApache
  1331. progreso=$((progreso + 1))
  1332. # } > >(whiptail --gauge "Configurando Servidor Web..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1333. echo -en " OK.\n" | tee -a $logFile
  1334. elif [ $nginxOn = true ]; then
  1335. echo -en "Configurando Servidor Web Nginx..." | tee -a $logFile
  1336. # {
  1337. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1338. configurarNginx
  1339. progreso=$((progreso + 1))
  1340. # } > >(whiptail --gauge "Configurando Servidor Web..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1341. echo -en " OK.\n" | tee -a $logFile
  1342. fi
  1343. # Configuración Database (Arrancar Base de Datos, establecer contraseña y configuración segura)
  1344. if [ $mySQLOn = true ] || [ $mariaDBOn = true ];then
  1345. habilitarServicio "$sqlServerName"
  1346. echo -en "Configurando Base de Datos MySQL..." | tee -a $logFile
  1347. # {
  1348. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1349. establecerSQLPasswd
  1350. progreso=$((progreso + 1))
  1351. # } > >(whiptail --gauge "Configurando Base de Datos MySQL..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1352. echo -en " OK.\n" | tee -a $logFile
  1353. fi
  1354. # Configuración PHP (cgi.fix_pathinfo=0 y Configurar máximo de subida de archivos)
  1355. if [ $phpOn = true ];then
  1356. echo -en "Configurando PHP-7..." | tee -a $logFile
  1357. # {
  1358. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1359. configurarPHP
  1360. progreso=$((progreso + 1))
  1361. # } > >(whiptail --gauge "Configurando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1362. echo -en " OK.\n" | tee -a $logFile
  1363. fi
  1364. # Configuración SSL/TLS
  1365. # Generar certificados
  1366. # Configurar certificados
  1367. if [ $sslOn = true ];then
  1368. echo -en "Configurando SSL/TLS..." | tee -a $logFile
  1369. # {
  1370. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1371. sleep 2
  1372. progreso=$((progreso + 1))
  1373. # } > >(whiptail --gauge "Configurando SSL/TLS..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1374. echo -en " OK.\n" | tee -a $logFile
  1375. fi
  1376. # Arrancar y habilitar todos los servicios (SystemD, Service o SystemV)
  1377. # {
  1378. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1379. if [ $apacheOn = true ];then
  1380. habilitarServicio $webServerName
  1381. elif [ $nginxOn = true ];then
  1382. habilitarServicio $webServerName
  1383. if [ $phpOn = true ];then
  1384. habilitarServicio $phpFPMName
  1385. fi
  1386. fi
  1387. progreso=$((progreso + 1))
  1388. # } > >(whiptail --gauge "Arrancando Servicios..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1389. # MediaWiki
  1390. if [ $mediaWikiOn = true ]; then
  1391. # Descargar MediaWiki
  1392. echo -en "Descargando MediaWiki-1.31.0..." | tee -a $logFile
  1393. # {
  1394. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1395. descargarMediaWiki
  1396. progreso=$((progreso + 1))
  1397. # } > >(whiptail --gauge "Instalando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1398. echo -en " OK.\n" | tee -a $logFile
  1399. # Configurar MediWiki
  1400. echo -en "Configurando MediaWiki..." | tee -a $logFile
  1401. # {
  1402. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1403. configurarMediaWiki
  1404. progreso=$((progreso + 1))
  1405. # } > >(whiptail --gauge "Configurando MediaWiki..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1406. echo -en " OK.\n" | tee -a $logFile
  1407. fi
  1408. # Moodle
  1409. if [ $moodleOn = true ]; then
  1410. # Descargar Moodle
  1411. echo -en "Descargando Moodle-3.5.1..." | tee -a $logFile
  1412. # {
  1413. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1414. descargarMoodle
  1415. progreso=$((progreso + 1))
  1416. # } > >(whiptail --gauge "Instalando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1417. echo -en " OK.\n" | tee -a $logFile
  1418. # Configuración Moodle
  1419. echo -en "Configurando Moodle..." | tee -a $logFile
  1420. # {
  1421. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1422. sleep 2
  1423. progreso=$((progreso + 1))
  1424. # } > >(whiptail --gauge "Configurando Moodle..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1425. echo -en " OK.\n" | tee -a $logFile
  1426. fi
  1427. # Configurar Virtual Hosts
  1428. # Instalar info.php
  1429. if [ $infoPHPOn = true ];then
  1430. echo -en "Configurando 'info.php'..." | tee -a $logFile
  1431. instalarPHPInfo
  1432. if [ $? -eq 0 ];then
  1433. echo -en " OK.\n" | tee -a $logFile
  1434. else
  1435. echo -en " Ya se encuentra configurado.\n" | tee -a $logFile
  1436. fi
  1437. fi
  1438. # Añadir reglas del cortafuegos
  1439. echo -en "Configurando Cortafuegos..." | tee -a $logFile
  1440. # {
  1441. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1442. configurarCortafuegos
  1443. progreso=$((progreso + 1))
  1444. # } > >(whiptail --gauge "Configurando Cortafuegos..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1445. echo -en " OK.\n" | tee -a $logFile
  1446. # Configurar actualizaciones
  1447. if [ $actualizacionesOn = true ]; then
  1448. echo -en "Configurando Actualizaciones Automáticas..." | tee -a $logFile
  1449. # {
  1450. # echo -en "%s\n" $((100 * progreso / progresoTotal))
  1451. sleep 2
  1452. progreso=$((progreso + 1))
  1453. # } > >(whiptail --gauge "Configurando actualizaciones automáticas..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
  1454. echo -en " OK.\n" | tee -a $logFile
  1455. fi