Commit 55505809 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Script shell pour lancer l'import et la synchro (utile pour la config CRON)

parent 97f73c6b
Loading
Loading
Loading
Loading
+28 −11
Original line number Diff line number Diff line
#!/bin/bash
#!/usr/bin/env bash

#############################################################################################
#        Script de lancement de l'import et de la synchro pour un établissement.
#############################################################################################
#
# Usage :
#   $ run-import.sh "UCN"
# Variables d'env requises :
#   ETAB : code de l'établissement à traiter, ex: "UCN".
#
# Variables d'env possibles :
#   SERVICE : code du service à traiter, ex: "variable".
#
#############################################################################################

usage() {
  cat << EOF
Script de lancement de l'import et de la synchro pour un établissement.
Usage: $0 <ETAB>
Usage: ETAB=<etab> [SERVICE=<service>] $0
EOF
  exit 0;
}

[[ -z "$1" ]] && usage
echo "Etablissement : $ETAB"
echo "Service : $SERVICE"

[[ -z "$ETAB" ]] && usage

CURR_DIR=$(cd `dirname $0` && pwd)
APP_DIR=$(cd ${CURR_DIR}/.. && pwd)

ROOT_DIR=$(cd `dirname $0` && pwd)/..
ETAB="$1"
echo "Répertoire courant : $CURR_DIR"
echo "Répertoire de l'appli : $APP_DIR"

php "$ROOT_DIR"/public/index.php import-all --etablissement="$ETAB" --synchronize=0 --breakOnServiceNotFound=0 && \
php "$ROOT_DIR"/public/index.php run synchro --all
# >> "/tmp/cron_sygal_import_$1.log" 2>&1 && \
# Import (appel web service) puis Synchro
if [ -z "$SERVICE" ]; then
  # tous les services
  set -x
  /usr/bin/php ${APP_DIR}/public/index.php import-all --etablissement=${ETAB} --synchronize=0 --breakOnServiceNotFound=0 && \
  /usr/bin/php ${APP_DIR}/public/index.php run synchro --all
else
  # seul service spécifié
  set -x
  /usr/bin/php ${APP_DIR}/public/index.php import --etablissement=${ETAB} --service=${SERVICE} --synchronize=0 && \
  /usr/bin/php ${APP_DIR}/public/index.php run synchro --name=${SERVICE}
fi
 No newline at end of file