Daniel 1 år sedan
förälder
incheckning
fb579e0c91
1 ändrade filer med 12 tillägg och 33 borttagningar
  1. +12
    -33
      1deployMatsenApi.sh

+ 12
- 33
1deployMatsenApi.sh Visa fil

@@ -1,80 +1,60 @@
#!/bin/bash #!/bin/bash


# Die zwei Hauptpfade als Variablen
TARGET_PATH="/var/www/crm-api/httpdocs" TARGET_PATH="/var/www/crm-api/httpdocs"
GIT_PATH="/var/www/matsen-git-repository/matsen-tool-be" GIT_PATH="/var/www/matsen-git-repository/matsen-tool-be"


# Funktion für das Kopieren der Dateien
copy_files() { copy_files() {
# Git Pull durchführen
cd ${GIT_PATH} cd ${GIT_PATH}
sudo GIT_SSH_COMMAND="ssh -i /home/service-spawntree/.ssh/id_rsa -p 1122" git pull sudo GIT_SSH_COMMAND="ssh -i /home/service-spawntree/.ssh/id_rsa -p 1122" git pull

echo "$(tput setab 2)matsen api has been PULLED$(tput sgr 0)" 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")
CONFIG_FILES="bundles.php preload.php routes.yaml services.yaml"
CONFIG_DIRS="packages routes"
ROOT_DIRS="bin migrations src"


ROOT_DIRS=("bin" "migrations" "src")

# Composer-Dateien kopieren
rm -rf ${TARGET_PATH}/composer.lock rm -rf ${TARGET_PATH}/composer.lock
rm -rf ${TARGET_PATH}/composer.json rm -rf ${TARGET_PATH}/composer.json
cp -rf ${GIT_PATH}/composer.json ${TARGET_PATH} 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/
for file in $CONFIG_FILES; do
rm -rf ${TARGET_PATH}/config/$file
cp -rf ${GIT_PATH}/config/$file ${TARGET_PATH}/config/
done 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/
for dir in $CONFIG_DIRS; do
rm -rf ${TARGET_PATH}/config/$dir
cp -rf ${GIT_PATH}/config/$dir ${TARGET_PATH}/config/
done done


# Root-Verzeichnisse kopieren
for dir in "${ROOT_DIRS[@]}"; do
rm -rf ${TARGET_PATH}/${dir}
cp -rf ${GIT_PATH}/${dir} ${TARGET_PATH}/
for dir in $ROOT_DIRS; do
rm -rf ${TARGET_PATH}/$dir
cp -rf ${GIT_PATH}/$dir ${TARGET_PATH}/
done done


# Index.php kopieren
rm -rf ${TARGET_PATH}/public/index.php rm -rf ${TARGET_PATH}/public/index.php
cp -rf ${GIT_PATH}/public/index.php ${TARGET_PATH}/public cp -rf ${GIT_PATH}/public/index.php ${TARGET_PATH}/public


echo "$(tput setab 2)Files have been copied$(tput sgr 0)" echo "$(tput setab 2)Files have been copied$(tput sgr 0)"
} }


# Prüfen des Parameters
if [ "$1" = "init" ]; then if [ "$1" = "init" ]; then
# Nur Dateien kopieren
copy_files copy_files
echo "$(tput setab 2)Init completed - files copied$(tput sgr 0)" echo "$(tput setab 2)Init completed - files copied$(tput sgr 0)"
else else
# Vollständiges Update durchführen
copy_files copy_files


# Composer Update und Datenbank-Migration
cd ${TARGET_PATH} cd ${TARGET_PATH}
composer update --no-scripts composer update --no-scripts

echo "$(tput setab 2)COMPOSER UPDATED updated$(tput sgr 0)" echo "$(tput setab 2)COMPOSER UPDATED updated$(tput sgr 0)"


php ${TARGET_PATH}/bin/console doctrine:migrations:migrate php ${TARGET_PATH}/bin/console doctrine:migrations:migrate

echo "$(tput setab 2)DATABASE SCHEMA updated$(tput sgr 0)" echo "$(tput setab 2)DATABASE SCHEMA updated$(tput sgr 0)"


# Cache leeren und neu aufbauen
cd ${TARGET_PATH}/var/cache/ cd ${TARGET_PATH}/var/cache/
rm -R * rm -R *


php ${TARGET_PATH}/bin/console cache:clear php ${TARGET_PATH}/bin/console cache:clear
php ${TARGET_PATH}/bin/console cache:warmup php ${TARGET_PATH}/bin/console cache:warmup

echo "$(tput setab 2)CACHE HAS BEEN CLEARED$(tput sgr 0)" echo "$(tput setab 2)CACHE HAS BEEN CLEARED$(tput sgr 0)"


cd ${TARGET_PATH}/var/ cd ${TARGET_PATH}/var/
@@ -83,6 +63,5 @@ else
sudo chmod 777 cache/ sudo chmod 777 cache/


echo "$(tput setab 7)$(tput setaf 1)THINK ABOUT POSSIBLE PATCHES!" echo "$(tput setab 7)$(tput setaf 1)THINK ABOUT POSSIBLE PATCHES!"

echo "You have updated matsen api!$(tput sgr 0)" echo "You have updated matsen api!$(tput sgr 0)"
fi fi

Laddar…
Avbryt
Spara