Eolisation de l'applicatif MSE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61-pve 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/bash
  2. function synchroHost()
  3. {
  4. local hst=${1}
  5. local WORKDIR=${2}
  6. local jobs_error_log="/var/www/html/mse/app/logs/jobs-error.log"
  7. local crond_file="/etc/cron.d/pve-jobs-run"
  8. echo "#### Working on ${hst}"
  9. ssh ${hst} "rm -rf /etc/php/5.6/fpm/pool.d/*"
  10. local cmd="cd ${WORKDIR};"
  11. echo "#### Synchro MSE"
  12. rsync -e ssh -av \
  13. --exclude="app/aglae/*" \
  14. --exclude="app/cache" \
  15. --exclude="app/DoctrineMigrations" \
  16. --exclude="app/izly" \
  17. --exclude="app/logs" \
  18. --exclude="app/uploads" \
  19. --exclude="app/webservices" \
  20. --exclude="components" \
  21. --exclude="certs" \
  22. --exclude="dist" \
  23. --exclude="patch" \
  24. --exclude="scripts" \
  25. /var/www/html/mse/ root@${hst}:/var/www/html/mse/
  26. echo "#### Synchro Apache"
  27. rsync -e ssh -av \
  28. --include="mse.conf" \
  29. /etc/apache2/sites-available/ root@${hst}:/etc/apache2/sites-available/
  30. echo "#### Synchro Apache MPM"
  31. rsync -e ssh -av \
  32. --include="mpm_worker.conf" \
  33. /etc/apache2/mods-available/ root@${hst}:/etc/apache2/mods-available/
  34. if [[ -f '/etc/rsyslog.d/eole-traps/mse.conf' ]]
  35. then
  36. echo "#### Synchro rsyslog"
  37. rsync -e ssh -av --include="mse.conf" /etc/rsyslog.d/eole-traps/ root@${hst}:/etc/rsyslog.d/eole-traps/
  38. fi
  39. if [[ -f '/etc/logrotate.d/mse' ]]
  40. then
  41. echo "#### Synchro logrotate"
  42. rsync -e ssh -av --include="mse" /etc/logrotate.d/ root@${hst}:/etc/logrotate.d/
  43. fi
  44. echo "#### Synchro PHP-FPM"
  45. rsync -e ssh -av \
  46. --include="php.ini" \
  47. --include="pool.d" \
  48. --include="pool.d/www.conf" \
  49. /etc/php/5.6/fpm/ root@${hst}:/etc/php/5.6/fpm/
  50. # Nettoyage des confs par défaut
  51. cmd="${cmd} rm -f /etc/php/5.6/fpm/pool.d/*~;"
  52. cmd="${cmd} rm -f /etc/apache2/mods-enabled/*~"
  53. cmd="${cmd} rm -f /etc/apache2/sites-enabled/*~"
  54. cmd="${cmd} rm -f /etc/apache2/sites-enabled/mse.conf"
  55. # Nettoyage du cache
  56. cmd="${cmd} rm -rf ${WORKDIR}/app/cache/*;"
  57. #cmd="${cmd} php -r \"apc_clear_cache(); apc_clear_cache('user'); apc_clear_cache('opcode');\";"
  58. # Warm up du cache
  59. cmd="${cmd} php app/console cache:warmup --env=prod --no-debug;"
  60. # Réinitialisation des droits
  61. cmd="${cmd} mkdir -p app/{aglae,doc,DoctrineMigration,izly,cache,logs,spool,webservices,uploads};"
  62. cmd="${cmd} mkdir -p {components,certs,dist,patch,scripts};"
  63. cmd="${cmd} chown -R :www-data app/{cache,logs,spool,webservices};"
  64. cmd="${cmd} chmod -R 775 app/{cache,logs,spool,webservices};"
  65. # Creation CRON spool mailer
  66. cmd="${cmd} echo \"*/5 * * * * root cd /var/www/html/mse; php app/console swiftmailer:spool:send --message-limit=500 --env=prod > /dev/null 2>>${jobs_error_log}\" > ${crond_file};"
  67. # Activation mods apache
  68. cmd="${cmd} a2dismod mpm_worker;"
  69. cmd="${cmd} a2enmod mpm_event;"
  70. apacheMods="proxy_fcgi rewrite expires remoteip"
  71. for mod in ${apacheMods}
  72. do
  73. cmd="${cmd} a2enmod ${mod};"
  74. done
  75. # Redémarrage service apache
  76. cmd="${cmd} a2ensite mse;"
  77. cmd="${cmd} service php5.6-fpm restart;"
  78. cmd="${cmd} service apache2 stop;"
  79. cmd="${cmd} service apache2 start;"
  80. ssh ${hst} "${cmd}"
  81. echo "### Work on ${HOST} DONE"
  82. }
  83. chmod +x /var/www/html/mse/scripts/scribe-post-install.sh
  84. CreoleRun "/var/www/html/mse/scripts/scribe-post-install.sh"
  85. mkdir /var/www/html/mse/app/cache/prod/besimple
  86. chown -R www-data: /var/www/html/mse/app/cache/prod/besimple
  87. LOGFILE=/var/log/eole/mse-sync.log
  88. if [[ -e ${LOGFILE} ]]
  89. then
  90. [[ -e ${LOGFILE}.bck ]] && rm ${LOGFILE}.bck
  91. mv ${LOGFILE} ${LOGFILE}.bck
  92. fi
  93. WORKDIR="/var/www/html/mse"
  94. childs=""
  95. for worker in $(CreoleGet mseSlaves)
  96. do
  97. synchroHost ${worker} ${WORKDIR} 2>&1 >> /var/log/eole/mse-sync.log &
  98. childs+="${worker}:${!} "
  99. done
  100. for child in ${childs}
  101. do
  102. name=${child%:*}
  103. pid=${child#*:}
  104. while [[ -d /proc/${pid} ]]
  105. do
  106. sleep 1
  107. done
  108. echo Worker ${name} sync done
  109. done