| @@ -1,80 +1,100 @@ | |||||
| #!/bin/bash | #!/bin/bash | ||||
| export PATH=/opt/plesk/php/8.2/bin:$PATH; | |||||
| cd /var/www/matsen-git-repository/matsen-tool-be/ | |||||
| sudo git pull | |||||
| echo "$(tput setab 2)matsen api has been PULLED$(tput sgr 0)" | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/composer.lock | |||||
| #cp -rf /var/www/matsen-git-repository/matsen-tool-be/httpdocs/composer.lock /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/composer.json | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/composer.json /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config/packages | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/config/packages /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config/routes | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/config/routes /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config/bundles.php | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/config/bundles.php /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config/preload.php | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/config/preload.php /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config/routes.yaml | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/config/routes.yaml /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config/services.yaml | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/config/services.yaml /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/config | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/bin | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/bin /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/migrations | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/migrations /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/src | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/src /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs | |||||
| rm -rf /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/public/index.php | |||||
| cp -rf /var/www/matsen-git-repository/matsen-tool-be/public/index.php /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/public | |||||
| echo "$(tput setab 2)Files have been copied$(tput sgr 0)" | |||||
| cd /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs | |||||
| composer update --no-scripts | |||||
| echo "$(tput setab 2)COMPOSER UPDATED updated$(tput sgr 0)" | |||||
| php /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/bin/console doctrine:migrations:migrate | |||||
| echo "$(tput setab 2)DATABASE SCHEMA updated$(tput sgr 0)" | |||||
| cd /var/www/vhosts/spawntree.de/ | |||||
| sudo chmod 777 matsen-api.spawntree.de | |||||
| cd /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/ | |||||
| sudo chmod 777 -R * | |||||
| cd /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/var/cache/ | |||||
| rm -R * | |||||
| php /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/bin/console cache:clear | |||||
| php /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/bin/console cache:warmup | |||||
| echo "$(tput setab 2)CACHE HAS BEEN CLEARED$(tput sgr 0)" | |||||
| cd /var/www/vhosts/spawntree.de/matsen-api.spawntree.de/httpdocs/var/ | |||||
| sudo chmod 777 -R * | |||||
| sudo chmod 777 cache/ * | |||||
| sudo chmod 777 cache/ | |||||
| #service apache2 restart | |||||
| #echo "$(tput setab 2)CACHE cleared$(tput sgr 0)" | |||||
| echo "$(tput setab 7)$(tput setaf 1)THINK ABOUT POSSIBLE PATCHES!" | |||||
| echo "You have updated matsen api!$(tput sgr 0)" | |||||
| # Die zwei Hauptpfade als Variablen | |||||
| TARGET_PATH="/var/www/crm-api/httpdocs" | |||||
| GIT_PATH="/var/www/matsen-git-repository/matsen-tool-be" | |||||
| # Funktion für das Kopieren der Dateien | |||||
| copy_files() { | |||||
| # Git Pull durchführen | |||||
| cd ${GIT_PATH} | |||||
| sudo git pull | |||||
| echo "$(tput setab 2)matsen api has been PULLED$(tput sgr 0)" | |||||
| # Arrays für Dateien und Verzeichnisse, die kopiert werden sollen | |||||
| CONFIG_FILES=( | |||||
| "bundles.php" | |||||
| "preload.php" | |||||
| "routes.yaml" | |||||
| "services.yaml" | |||||
| ) | |||||
| CONFIG_DIRS=( | |||||
| "packages" | |||||
| "routes" | |||||
| ) | |||||
| ROOT_DIRS=( | |||||
| "bin" | |||||
| "migrations" | |||||
| "src" | |||||
| ) | |||||
| # Composer-Dateien kopieren | |||||
| rm -rf ${TARGET_PATH}/composer.lock | |||||
| rm -rf ${TARGET_PATH}/composer.json | |||||
| cp -rf ${GIT_PATH}/composer.json ${TARGET_PATH} | |||||
| # Config-Dateien kopieren | |||||
| for file in "${CONFIG_FILES[@]}"; do | |||||
| rm -rf ${TARGET_PATH}/config/${file} | |||||
| cp -rf ${GIT_PATH}/config/${file} ${TARGET_PATH}/config/ | |||||
| done | |||||
| # Config-Verzeichnisse kopieren | |||||
| for dir in "${CONFIG_DIRS[@]}"; do | |||||
| rm -rf ${TARGET_PATH}/config/${dir} | |||||
| cp -rf ${GIT_PATH}/config/${dir} ${TARGET_PATH}/config/ | |||||
| done | |||||
| # Root-Verzeichnisse kopieren | |||||
| for dir in "${ROOT_DIRS[@]}"; do | |||||
| rm -rf ${TARGET_PATH}/${dir} | |||||
| cp -rf ${GIT_PATH}/${dir} ${TARGET_PATH}/ | |||||
| done | |||||
| # Index.php kopieren | |||||
| rm -rf ${TARGET_PATH}/public/index.php | |||||
| cp -rf ${GIT_PATH}/public/index.php ${TARGET_PATH}/public | |||||
| echo "$(tput setab 2)Files have been copied$(tput sgr 0)" | |||||
| } | |||||
| # Prüfen des Parameters | |||||
| if [ "$1" = "init" ]; then | |||||
| # Nur Dateien kopieren | |||||
| copy_files | |||||
| echo "$(tput setab 2)Init completed - files copied$(tput sgr 0)" | |||||
| else | |||||
| # Vollständiges Update durchführen | |||||
| copy_files | |||||
| # Composer Update und Datenbank-Migration | |||||
| cd ${TARGET_PATH} | |||||
| composer update --no-scripts | |||||
| echo "$(tput setab 2)COMPOSER UPDATED updated$(tput sgr 0)" | |||||
| php ${TARGET_PATH}/bin/console doctrine:migrations:migrate | |||||
| echo "$(tput setab 2)DATABASE SCHEMA updated$(tput sgr 0)" | |||||
| # Cache leeren und neu aufbauen | |||||
| cd ${TARGET_PATH}/var/cache/ | |||||
| rm -R * | |||||
| php ${TARGET_PATH}/bin/console cache:clear | |||||
| php ${TARGET_PATH}/bin/console cache:warmup | |||||
| echo "$(tput setab 2)CACHE HAS BEEN CLEARED$(tput sgr 0)" | |||||
| cd ${TARGET_PATH}/var/ | |||||
| sudo chmod 777 -R * | |||||
| sudo chmod 777 cache/ * | |||||
| sudo chmod 777 cache/ | |||||
| echo "$(tput setab 7)$(tput setaf 1)THINK ABOUT POSSIBLE PATCHES!" | |||||
| echo "You have updated matsen api!$(tput sgr 0)" | |||||
| fi | |||||