install 47 KB

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