Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

88 рядки
2.5 KiB

  1. #!/bin/bash
  2. # Die zwei Hauptpfade als Variablen
  3. TARGET_PATH="/var/www/crm-api/httpdocs"
  4. GIT_PATH="/var/www/matsen-git-repository/matsen-tool-be"
  5. # Funktion für das Kopieren der Dateien
  6. copy_files() {
  7. # Git Pull durchführen
  8. cd ${GIT_PATH}
  9. sudo GIT_SSH_COMMAND="ssh -i /home/service-spawntree/.ssh/id_rsa -p 1122" git pull
  10. echo "$(tput setab 2)matsen api has been PULLED$(tput sgr 0)"
  11. # Arrays für Dateien und Verzeichnisse, die kopiert werden sollen
  12. CONFIG_FILES=("bundles.php" "preload.php" "routes.yaml" "services.yaml")
  13. CONFIG_DIRS=("packages" "routes")
  14. ROOT_DIRS=("bin" "migrations" "src")
  15. # Composer-Dateien kopieren
  16. rm -rf ${TARGET_PATH}/composer.lock
  17. rm -rf ${TARGET_PATH}/composer.json
  18. cp -rf ${GIT_PATH}/composer.json ${TARGET_PATH}
  19. # Config-Dateien kopieren
  20. for file in "${CONFIG_FILES[@]}"; do
  21. rm -rf ${TARGET_PATH}/config/${file}
  22. cp -rf ${GIT_PATH}/config/${file} ${TARGET_PATH}/config/
  23. done
  24. # Config-Verzeichnisse kopieren
  25. for dir in "${CONFIG_DIRS[@]}"; do
  26. rm -rf ${TARGET_PATH}/config/${dir}
  27. cp -rf ${GIT_PATH}/config/${dir} ${TARGET_PATH}/config/
  28. done
  29. # Root-Verzeichnisse kopieren
  30. for dir in "${ROOT_DIRS[@]}"; do
  31. rm -rf ${TARGET_PATH}/${dir}
  32. cp -rf ${GIT_PATH}/${dir} ${TARGET_PATH}/
  33. done
  34. # Index.php kopieren
  35. rm -rf ${TARGET_PATH}/public/index.php
  36. cp -rf ${GIT_PATH}/public/index.php ${TARGET_PATH}/public
  37. echo "$(tput setab 2)Files have been copied$(tput sgr 0)"
  38. }
  39. # Prüfen des Parameters
  40. if [ "$1" = "init" ]; then
  41. # Nur Dateien kopieren
  42. copy_files
  43. echo "$(tput setab 2)Init completed - files copied$(tput sgr 0)"
  44. else
  45. # Vollständiges Update durchführen
  46. copy_files
  47. # Composer Update und Datenbank-Migration
  48. cd ${TARGET_PATH}
  49. composer update --no-scripts
  50. echo "$(tput setab 2)COMPOSER UPDATED updated$(tput sgr 0)"
  51. php ${TARGET_PATH}/bin/console doctrine:migrations:migrate
  52. echo "$(tput setab 2)DATABASE SCHEMA updated$(tput sgr 0)"
  53. # Cache leeren und neu aufbauen
  54. cd ${TARGET_PATH}/var/cache/
  55. rm -R *
  56. php ${TARGET_PATH}/bin/console cache:clear
  57. php ${TARGET_PATH}/bin/console cache:warmup
  58. echo "$(tput setab 2)CACHE HAS BEEN CLEARED$(tput sgr 0)"
  59. cd ${TARGET_PATH}/var/
  60. sudo chmod 777 -R *
  61. sudo chmod 777 cache/ *
  62. sudo chmod 777 cache/
  63. echo "$(tput setab 7)$(tput setaf 1)THINK ABOUT POSSIBLE PATCHES!"
  64. echo "You have updated matsen api!$(tput sgr 0)"
  65. fi