Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

100 строки
2.6 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=(
  13. "bundles.php"
  14. "preload.php"
  15. "routes.yaml"
  16. "services.yaml"
  17. )
  18. CONFIG_DIRS=(
  19. "packages"
  20. "routes"
  21. )
  22. ROOT_DIRS=(
  23. "bin"
  24. "migrations"
  25. "src"
  26. )
  27. # Composer-Dateien kopieren
  28. rm -rf ${TARGET_PATH}/composer.lock
  29. rm -rf ${TARGET_PATH}/composer.json
  30. cp -rf ${GIT_PATH}/composer.json ${TARGET_PATH}
  31. # Config-Dateien kopieren
  32. for file in "${CONFIG_FILES[@]}"; do
  33. rm -rf ${TARGET_PATH}/config/${file}
  34. cp -rf ${GIT_PATH}/config/${file} ${TARGET_PATH}/config/
  35. done
  36. # Config-Verzeichnisse kopieren
  37. for dir in "${CONFIG_DIRS[@]}"; do
  38. rm -rf ${TARGET_PATH}/config/${dir}
  39. cp -rf ${GIT_PATH}/config/${dir} ${TARGET_PATH}/config/
  40. done
  41. # Root-Verzeichnisse kopieren
  42. for dir in "${ROOT_DIRS[@]}"; do
  43. rm -rf ${TARGET_PATH}/${dir}
  44. cp -rf ${GIT_PATH}/${dir} ${TARGET_PATH}/
  45. done
  46. # Index.php kopieren
  47. rm -rf ${TARGET_PATH}/public/index.php
  48. cp -rf ${GIT_PATH}/public/index.php ${TARGET_PATH}/public
  49. echo "$(tput setab 2)Files have been copied$(tput sgr 0)"
  50. }
  51. # Prüfen des Parameters
  52. if [ "$1" = "init" ]; then
  53. # Nur Dateien kopieren
  54. copy_files
  55. echo "$(tput setab 2)Init completed - files copied$(tput sgr 0)"
  56. else
  57. # Vollständiges Update durchführen
  58. copy_files
  59. # Composer Update und Datenbank-Migration
  60. cd ${TARGET_PATH}
  61. composer update --no-scripts
  62. echo "$(tput setab 2)COMPOSER UPDATED updated$(tput sgr 0)"
  63. php ${TARGET_PATH}/bin/console doctrine:migrations:migrate
  64. echo "$(tput setab 2)DATABASE SCHEMA updated$(tput sgr 0)"
  65. # Cache leeren und neu aufbauen
  66. cd ${TARGET_PATH}/var/cache/
  67. rm -R *
  68. php ${TARGET_PATH}/bin/console cache:clear
  69. php ${TARGET_PATH}/bin/console cache:warmup
  70. echo "$(tput setab 2)CACHE HAS BEEN CLEARED$(tput sgr 0)"
  71. cd ${TARGET_PATH}/var/
  72. sudo chmod 777 -R *
  73. sudo chmod 777 cache/ *
  74. sudo chmod 777 cache/
  75. echo "$(tput setab 7)$(tput setaf 1)THINK ABOUT POSSIBLE PATCHES!"
  76. echo "You have updated matsen api!$(tput sgr 0)"
  77. fi