No Description
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.

Ajout_Agora_Infinity.sh 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #!/bin/bash
  2. #
  3. # v0.7
  4. #
  5. echo "//////////////////////////////////////////////////"
  6. echo ""
  7. echo "Début du script de déploiement d'Agora Infinity"
  8. echo ""
  9. #Récupération des variables
  10. echo -n "Enter DB username: " ; read db_user
  11. echo -n "Enter Database name: " ; read db_name
  12. echo -n "Enter $db_user password: " ; stty -echo ; read db_passwd ; stty echo ; echo ""
  13. echo ""
  14. echo "Test de la connexion à la base de donnée"
  15. while ! mysql -u $db_user -p$db_passwd $db_name -e ";" ; do
  16. read -s -p "Connexion à la base de donnée impossible, merci de ré enter le bon mot de passe: " db_passwd
  17. done
  18. echo "Test conexion BD = OK"
  19. echo ""
  20. echo -n "Enter domaine (ex: clientagora.tree-learning.fr || pas de www.) : " ; read sitedomaine
  21. siteVar="$sitedomaine"
  22. sitedomaine="/var/www/""$sitedomaine""/web"
  23. #test
  24. #sitedomaine="/tmp/""$sitedomaine"
  25. read -e -p "Web user ( ex = webX) : " WebUser
  26. read -e -p "Web group ( ex = clientX) : " WebGroup
  27. UpdateRight="chown -R ""$WebUser"":""$WebGroup"" ""$sitedomaine"
  28. read -e -p "APP_ENV ( default = prod) : " -i "prod" APP_ENV
  29. read -e -p "APP_DEBUG ( default = 0) : " -i "0" APP_DEBUG
  30. read -e -p "APP_SECRET ( default = logipro) : " -i "logipro" APP_SECRET
  31. read -e -p "APP_URL_PREFIX ( default = empty) : " -i "" APP_URL_PREFIX
  32. #read -e -p "APP_SECRET ( default = logipro) : " -i "logipro" APP_SECRET
  33. dbURL='DATABASE_URL="mysql://'$db_user':'$db_passwd'@localhost/'$db_name'"'
  34. #read -e -p "MAILER_HOST= " -i "isp15.logipro.com" MAILER_HOST
  35. #read -e -p "MAILER_USERNAME= " -i "srv-mail@logipro.com" MAILER_USERNAME
  36. #read -e -p "Entrez le mot de passe pour MAILER_PASSWORD= " MAILER_PASSWORD
  37. # On fixe les variables de config smtp
  38. MAILER_HOST="isp15.logipro.com"
  39. MAILER_USERNAME="srv-mail@logipro.com"
  40. MAILER_PASSWORD="BA2kGNEQhSS2695LZA5p"
  41. ####
  42. PHOENIX='"'$sitedomaine'/Phoenix"'
  43. PhoenixPath="$sitedomaine""/Phoenix"
  44. #pour test
  45. sitepath="$sitedomaine""/Phoenix"
  46. #test mkdir -p "$sitepath"
  47. PHPpath="/usr/bin/php"
  48. COMPOSERpath="/usr/bin/composer"
  49. COMPOSERCachepath="$PhoenixPath""/var"
  50. COMPOSER_CACHE_DIR_Var="COMPOSER_CACHE_DIR=""$COMPOSERCachepath"
  51. Php_Memory_Limit_Cmd="php -d memory_limit=5000M"
  52. #Unoconv URL
  53. DOCX_TO_PDF_CONVERTER_URL="https://unoconv.logipro.com/unoconv/pdf"
  54. echo "///////////////////////////////////////"
  55. echo "Résumé des variables :"
  56. echo "Domaine"$sitedomaine
  57. echo "User et group"""$WebUser":"$WebGroup""
  58. echo "Param .env"
  59. echo ""
  60. echo "APP_ENV=$APP_ENV"
  61. echo "APP_DEBUG=$APP_DEBUG"
  62. echo 'APP_SECRET="'$APP_SECRET'"'
  63. echo 'APP_URL_PREFIX="'$APP_URL_PREFIX'"'
  64. echo 'APP_HOST="'$sitedomaine'"'
  65. echo -e "\n"
  66. echo $dbURL
  67. echo -e "\n"
  68. echo 'MAILER_HOST="'$MAILER_HOST'"'
  69. echo 'MAILER_USERNAME="'$MAILER_USERNAME'"'
  70. echo 'MAILER_PASSWORD="'$MAILER_PASSWORD'"'
  71. echo -e "\n"
  72. echo 'DOCX_TO_PDF_CONVERTER_URL'="'$DOCX_TO_PDF_CONVERTER_UR'"'
  73. echo "Prêt pour l'installation ( ctrl+c pour stopper le script | Enter pour continuer )"
  74. read
  75. ################################################### Initialisation de l'instalation
  76. echo "/////////////////"
  77. echo "Installation"
  78. cd $sitedomaine
  79. gitInstall="sudo -u ""$WebUser"" git clone -b master https://git.logipro.com/raphael/Phoenix.git"
  80. $gitInstall
  81. $UpdateRight
  82. cd $PhoenixPath
  83. composerInstall="$COMPOSERpath"" install --no-dev --optimize-autoloader"
  84. sudo -u "$WebUser" $COMPOSER_CACHE_DIR_Var $Php_Memory_Limit_Cmd $composerInstall
  85. ################################################### Création du .env
  86. echo "/////////////////"
  87. echo "Création du .env"
  88. envFilePath="$sitepath""/.env"
  89. cat <<END >$envFilePath
  90. APP_ENV=$APP_ENV
  91. APP_DEBUG=$APP_DEBUG
  92. APP_SECRET="$APP_SECRET"
  93. APP_HOST="$siteVar"
  94. APP_URL_PREFIX="$APP_URL_PREFIX"
  95. $dbURL
  96. MAILER_HOST="$MAILER_HOST"
  97. MAILER_USERNAME="$MAILER_USERNAME"
  98. MAILER_PASSWORD="$MAILER_PASSWORD"
  99. DOCX_TO_PDF_CONVERTER_URL="https://unoconv.logipro.com/unoconv/pdf"
  100. END
  101. $UpdateRight
  102. ###################################################
  103. # récupérer
  104. cd $PhoenixPath
  105. git fetch --all
  106. # Update depuis GIT
  107. git reset --hard origin/master
  108. $UpdateRight
  109. #sudo -u "$WebUser" $PHPpath ./bin/console cache:clear
  110. sudo -u "$WebUser" $PHPpath ./bin/console doctrine:schema:update --force
  111. sudo -u "$WebUser" $PHPpath ./bin/console phoenix:setup
  112. sudo -u "$WebUser" $PHPpath ./bin/console phoenix:thematic:init
  113. $UpdateRight
  114. ################################################### Création du .htaccess
  115. echo "/////////////////"
  116. echo "Création du .htaccess"
  117. htaccessPath=$PhoenixPath"/public/.htaccess"
  118. cat <<END >$htaccessPath
  119. #Voir configuration du vhost Apache sous ISPconfig
  120. END
  121. $UpdateRight
  122. ################################################### creation du script d'update
  123. echo "/////////////////"
  124. echo "Création du script d'update"
  125. updatescriptPath=$PhoenixPath"/bin/update.sh"
  126. #
  127. cat <<END >$updatescriptPath
  128. #!/bin/bash
  129. #===============================================================================
  130. # On se place a la racine
  131. cd $PhoenixPath
  132. # récupérer
  133. git fetch --all
  134. # Update depuis GIT
  135. git reset --hard origin/master
  136. chown -R $WebUser:$WebGroup $PhoenixPath
  137. # Update les dependances
  138. sudo -u $WebUser $COMPOSER_CACHE_DIR_Var $Php_Memory_Limit_Cmd $COMPOSERpath update --no-dev --optimize-autoloader
  139. # Vide le cache
  140. sudo -u $WebUser $PHPpath ./bin/console cache:clear
  141. # patchs avant la base de données
  142. sudo -u $WebUser $PHPpath ./bin/console phoenix:patch:before
  143. # Update le MCD
  144. sudo -u $WebUser $PHPpath ./bin/console doctrine:schema:update --force
  145. # Setup Phoenix
  146. sudo -u $WebUser $PHPpath ./bin/console phoenix:setup
  147. # migration des données vers la dernière version
  148. sudo -u $WebUser $PHPpath ./bin/console doctrine:migrations:migrate -n
  149. echo "Update terminée"
  150. END
  151. chmod +x $updatescriptPath
  152. $UpdateRight
  153. ################################################### création fichier des cron
  154. echo "/////////////////"
  155. echo "Création du fichier de cron"
  156. cronpath=$PhoenixPath"/bin/cron.sh"
  157. cat <<END >$cronpath
  158. #/bin/bash
  159. sudo -u $WebUser /usr/bin/php $PhoenixPath/bin/console phoenix:cron:minute
  160. END
  161. chmod +x $cronpath
  162. ################################################### Correction des droits
  163. $UpdateRight
  164. ################################################### Ajout dans crontab
  165. echo "/////////////////"
  166. echo "Ajout de la tache cron dans /etc/crontab"
  167. echo "### ""$PhoenixPath" >> /etc/crontab
  168. echo "* * * * * root /bin/bash ""$PhoenixPath""/bin/cron.sh >/dev/null 2>&1" >> /etc/crontab
  169. ###
  170. echo "Installation terminée"