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

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