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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. echo "///////////////////////////////////////"
  53. echo "Résumé des variables :"
  54. echo "Domaine"$sitedomaine
  55. echo "User et group"""$WebUser":"$WebGroup""
  56. echo "Param .env"
  57. echo ""
  58. echo "APP_ENV=$APP_ENV"
  59. echo "APP_DEBUG=$APP_DEBUG"
  60. echo 'APP_SECRET="'$APP_SECRET'"'
  61. echo 'APP_URL_PREFIX="'$APP_URL_PREFIX'"'
  62. echo 'APP_HOST="'$sitedomaine'"'
  63. echo -e "\n"
  64. echo $dbURL
  65. echo -e "\n"
  66. echo 'MAILER_HOST="'$MAILER_HOST'"'
  67. echo 'MAILER_USERNAME="'$MAILER_USERNAME'"'
  68. echo 'MAILER_PASSWORD="'$MAILER_PASSWORD'"'
  69. echo -e "\n"
  70. echo "Prêt pour l'installation ( ctrl+c pour stopper le script | Enter pour continuer )"
  71. read
  72. ################################################### Initialisation de l'instalation
  73. echo "/////////////////"
  74. echo "Installation"
  75. cd $sitedomaine
  76. gitInstall="sudo -u ""$WebUser"" git clone -b master https://git.logipro.com/raphael/Phoenix.git"
  77. $gitInstall
  78. $UpdateRight
  79. cd $PhoenixPath
  80. composerInstall="$COMPOSERpath"" install --no-dev --optimize-autoloader"
  81. sudo -u "$WebUser" $COMPOSER_CACHE_DIR_Var $Php_Memory_Limit_Cmd $composerInstall
  82. ################################################### Création du .env
  83. echo "/////////////////"
  84. echo "Création du .env"
  85. envFilePath="$sitepath""/.env"
  86. cat <<END >$envFilePath
  87. APP_ENV=$APP_ENV
  88. APP_DEBUG=$APP_DEBUG
  89. APP_SECRET="$APP_SECRET"
  90. APP_HOST="$siteVar"
  91. APP_URL_PREFIX="$APP_URL_PREFIX"
  92. $dbURL
  93. MAILER_HOST="$MAILER_HOST"
  94. MAILER_USERNAME="$MAILER_USERNAME"
  95. MAILER_PASSWORD="$MAILER_PASSWORD"
  96. END
  97. $UpdateRight
  98. ###################################################
  99. # récupérer
  100. cd $PhoenixPath
  101. git fetch --all
  102. # Update depuis GIT
  103. git reset --hard origin/master
  104. $UpdateRight
  105. #sudo -u "$WebUser" $PHPpath ./bin/console cache:clear
  106. sudo -u "$WebUser" $PHPpath ./bin/console doctrine:schema:update --force
  107. sudo -u "$WebUser" $PHPpath ./bin/console phoenix:setup
  108. sudo -u "$WebUser" $PHPpath ./bin/console phoenix:thematic:init
  109. $UpdateRight
  110. ################################################### Création du .htaccess
  111. echo "/////////////////"
  112. echo "Création du .htaccess"
  113. htaccessPath=$PhoenixPath"/public/.htaccess"
  114. cat <<END >$htaccessPath
  115. #Voir configuration du vhost Apache sous ISPconfig
  116. END
  117. $UpdateRight
  118. ################################################### creation du script d'update
  119. echo "/////////////////"
  120. echo "Création du script d'update"
  121. updatescriptPath=$PhoenixPath"/bin/update.sh"
  122. #
  123. cat <<END >$updatescriptPath
  124. #!/bin/bash
  125. #===============================================================================
  126. # On se place a la racine
  127. cd $PhoenixPath
  128. # récupérer
  129. git fetch --all
  130. # Update depuis GIT
  131. git reset --hard origin/master
  132. chown -R $WebUser:$WebGroup $PhoenixPath
  133. # Update les dependances
  134. sudo -u $WebUser $COMPOSER_CACHE_DIR_Var $Php_Memory_Limit_Cmd $COMPOSERpath update --no-dev --optimize-autoloader
  135. # Vide le cache
  136. sudo -u $WebUser $PHPpath ./bin/console cache:clear
  137. # patchs avant la base de données
  138. sudo -u $WebUser $PHPpath ./bin/console phoenix:patch:before
  139. # Update le MCD
  140. sudo -u $WebUser $PHPpath ./bin/console doctrine:schema:update --force
  141. # Setup Phoenix
  142. sudo -u $WebUser $PHPpath ./bin/console phoenix:setup
  143. # migration des données vers la dernière version
  144. sudo -u $WebUser $PHPpath ./bin/console doctrine:migrations:migrate -n
  145. echo "Update terminée"
  146. END
  147. chmod +x $updatescriptPath
  148. $UpdateRight
  149. ################################################### création fichier des cron
  150. echo "/////////////////"
  151. echo "Création du fichier de cron"
  152. cronpath=$PhoenixPath"/bin/cron.sh"
  153. cat <<END >$cronpath
  154. #/bin/bash
  155. sudo -u $WebUser /usr/bin/php $PhoenixPath/bin/console phoenix:cron:minute
  156. END
  157. chmod +x $cronpath
  158. ################################################### Correction des droits
  159. $UpdateRight
  160. ################################################### Ajout dans crontab
  161. echo "/////////////////"
  162. echo "Ajout de la tache cron dans /etc/crontab"
  163. echo "### ""$PhoenixPath" >> /etc/crontab
  164. echo "* * * * * root /bin/bash ""$PhoenixPath""/bin/cron.sh >/dev/null 2>&1" >> /etc/crontab
  165. ###
  166. echo "Installation terminée"