install 48 KB

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