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.5KB

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