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.

66 lines
1.9 KiB

  1. #!/bin/bash
  2. TARGET_PATH="/var/www/crm-api/httpdocs"
  3. GIT_PATH="/var/www/matsen-git-repository/matsen-tool-be"
  4. create_directories() {
  5. # Erstelle notwendige Verzeichnisse falls sie nicht existieren
  6. mkdir -p ${TARGET_PATH}/config
  7. mkdir -p ${TARGET_PATH}/public
  8. mkdir -p ${TARGET_PATH}/var/cache
  9. }
  10. copy_files() {
  11. cd ${GIT_PATH}
  12. sudo GIT_SSH_COMMAND="ssh -i /home/service-spawntree/.ssh/id_rsa -p 1122" git pull
  13. echo "$(tput setab 2)matsen api has been PULLED$(tput sgr 0)"
  14. ROOT_DIRS="bin config migrations src"
  15. # Erstelle zuerst alle notwendigen Verzeichnisse
  16. create_directories
  17. rm -rf ${TARGET_PATH}/composer.lock
  18. rm -rf ${TARGET_PATH}/composer.json
  19. cp -rf ${GIT_PATH}/composer.json ${TARGET_PATH}
  20. for dir in $ROOT_DIRS; do
  21. rm -rf ${TARGET_PATH}/$dir
  22. cp -rf ${GIT_PATH}/$dir ${TARGET_PATH}/
  23. done
  24. # Stelle sicher, dass der public Ordner existiert
  25. mkdir -p ${TARGET_PATH}/public
  26. rm -rf ${TARGET_PATH}/public/index.php
  27. cp -rf ${GIT_PATH}/public/index.php ${TARGET_PATH}/public/
  28. echo "$(tput setab 2)Files have been copied$(tput sgr 0)"
  29. }
  30. if [ "$1" = "init" ]; then
  31. copy_files
  32. echo "$(tput setab 2)Init completed - files copied$(tput sgr 0)"
  33. else
  34. copy_files
  35. cd ${TARGET_PATH}
  36. composer update --no-scripts
  37. echo "$(tput setab 2)COMPOSER UPDATED updated$(tput sgr 0)"
  38. php ${TARGET_PATH}/bin/console doctrine:migrations:migrate
  39. echo "$(tput setab 2)DATABASE SCHEMA updated$(tput sgr 0)"
  40. cd ${TARGET_PATH}/var/cache/
  41. rm -R *
  42. php ${TARGET_PATH}/bin/console cache:clear
  43. php ${TARGET_PATH}/bin/console cache:warmup
  44. echo "$(tput setab 2)CACHE HAS BEEN CLEARED$(tput sgr 0)"
  45. cd ${TARGET_PATH}/var/
  46. sudo chmod 777 -R *
  47. sudo chmod 777 cache/ *
  48. sudo chmod 777 cache/
  49. echo "$(tput setab 7)$(tput setaf 1)THINK ABOUT POSSIBLE PATCHES!"
  50. echo "You have updated matsen api!$(tput sgr 0)"
  51. fi