Skip to content
Snippets Groups Projects
Select Git revision
  • c307b5fe0a36f8ffcc21c87410cef25cf2713af7
  • master default protected
  • php84
  • ll-api-test
  • 6.x
  • release_6.2.0
  • modif_maintenance_phtml
  • 6.0.x
  • detached2
  • detached
  • php82
  • feature_SearchAndSelectFilter
  • 5.x
  • 4.x
  • 7.2.1
  • 7.2.0
  • 6.2.0
  • 7.1.0
  • 7.0.0
  • 1.1.1
  • 6.1.7
  • 6.1.6
  • 6.1.5
  • 6.0.16
  • 6.0.15
  • 6.1.4
  • 6.0.14
  • 6.1.3
  • 6.0.13
  • 6.1.2
  • 6.0.12
  • 6.1.1
  • 6.1.0
  • 6.0.11
34 results

deploy.sh

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    deploy.sh 2.85 KiB
    #/bin/bash
    
    ########################################################################
    # Synchronise le répertoire courant avec celui spécifié en argument,
    # à l'aide de l'outil 'rsync'.
    # Une simple simulation peut être faite.
    #
    # NB: Des fichiers peuvent être exclus de la synchro.
    ########################################################################
    
    EXCLUSIONS=""
    EXCLUSIONS="$EXCLUSIONS --exclude auth.json"
    EXCLUSIONS="$EXCLUSIONS --exclude /public/.htaccess"
    EXCLUSIONS="$EXCLUSIONS --exclude /docs/*"
    EXCLUSIONS="$EXCLUSIONS --exclude /logs/*"
    EXCLUSIONS="$EXCLUSIONS --exclude /tests"
    EXCLUSIONS="$EXCLUSIONS --exclude *~"
    EXCLUSIONS="$EXCLUSIONS --exclude .svn/"
    EXCLUSIONS="$EXCLUSIONS --exclude .git/"
    EXCLUSIONS="$EXCLUSIONS --exclude /composer.lock"
    EXCLUSIONS="$EXCLUSIONS --exclude /*.log"
    #EXCLUSIONS="$EXCLUSIONS --exclude /vendor/*"
    EXCLUSIONS="$EXCLUSIONS --exclude /config/*local.php"
    EXCLUSIONS="$EXCLUSIONS --exclude /data/cache/*"
    EXCLUSIONS="$EXCLUSIONS --exclude /config/autoload/*local.php"
    EXCLUSIONS="$EXCLUSIONS --exclude /temp/*"
    
    LOG_FILE='./deploy.log'
    
    # Execute getopt
    ARGS=`getopt -o "t:s:" -l "target:,simulation:" -n "getopt.sh" -- "$@"`
    
    # Bad arguments
    if [ $? -ne 0 ];
    then
      exit 1
    fi
    
    # A little magic
    eval set -- "$ARGS"
    
    # Now go through all the options
    while true;
    do
      case "$1" in
        -t|--target)
        #--------------
          if [ -n "$2" ];
          then
            echo "Target : $2"
            target="$2"
          fi
          shift 2;;
    
        -s|--simulation)
        #---------------
          if [ -n "$2" ];
          then
            echo "Simulation : $2"
            simul=$2
          fi
          shift 2;;
    
        --)
          shift
          break;;
      esac
    done
    
    if [ ! $target ]; then
        echo "Target (ex: gauthierb@dev.unicaen.fr:/var/www/closer) ?"
        read target
    fi
    if [ ! $simul ]; then
        echo "Simulation (y/n) ? "
        read simul
    fi
    
    sourceDir="."
    doit="y"
    
    echo
    echo "------------------------------------------------------------------------------------------------------"
    echo "S Y N C H R O N I S A T I O N"
    echo "------------------------------------------------------------------------------------------------------"
    
    targetDir=$target
    
    echo "Source directory : $sourceDir"
    echo "Target directory : $target"
    
    # simulation
    if [ $simul = "y" ]; then
    	echo
    	echo "SIMULATION :"
    	echo "------------"
    	rsync -avzn --perms --delete $EXCLUSIONS -e ssh $sourceDir $targetDir
            exit
    fi
    
    # logging
    ts=`date +%d/%m/%Y-%H:%M:%S`
    echo "------------------------------------------------------------------------------------------------------" >> $LOG_FILE
    echo "$ts : $0 $*" >> $LOG_FILE
    
    # synchronisation
    if [ $doit = "y" ]; then
    	echo
    	echo "SYNCHRONISATION :"
    	echo "-----------------"
    	rsync -avz --perms --delete $EXCLUSIONS -e ssh --log-file=$LOG_FILE $sourceDir $targetDir
    fi
    
    echo "------------------------------------------------------------------------------------------------------"
    echo