Daniel 1 yıl önce
ebeveyn
işleme
fb579e0c91
1 değiştirilmiş dosya ile 12 ekleme ve 33 silme
  1. +12
    -33
      1deployMatsenApi.sh

+ 12
- 33
1deployMatsenApi.sh Dosyayı Görüntüle

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

# 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_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)"

# 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.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/
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/
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}/
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/
@@ -83,6 +63,5 @@ else
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

Yükleniyor…
İptal
Kaydet