Skip to content
Snippets Groups Projects
Select Git revision
  • 16ab6d3042a20e92c1a1aacd5917cf1e56cd044f
  • 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.38 KiB
    #/bin/bash
    
    ########################################################################
    # Synchronise le répertoire courant avec celui spécifié en argument.
    # Une simple simulation peut etre faite.
    #
    # Les fichiers à exclure sont listés dans un fichier à part.
    ########################################################################
    
    EXCLUSIONS="--exclude /docs/* --exclude /logs/* --exclude /tests --exclude *~ --exclude .svn/ --exclude .git/"
    EXCLUSIONS="$EXCLUSIONS --exclude /config/autoload/*local.php"
    EXCLUSIONS="$EXCLUSIONS --exclude /temp/*"
    
    LOG_FILE='./deploy.log'
    
    echo "Nom du répertoire sur le serveur ? "
    read appName
    
    dev="gauthierb@dev.unicaen.fr:/var/www/$appName/"
    prod="gauthierb@lgest1.unicaen.fr:/var/www/html/$appName/"
    
    sourceDir="."
    simul="o"
    doit="o"
    
    echo
    echo "------------------------------------------------------------------------------------------------------"
    echo "S Y N C H R O N I S A T I O N"
    echo "------------------------------------------------------------------------------------------------------"
    
    echo "Répertoire source : $sourceDir"
    
    if [ $1 -a $1 = "nosim" ]; then
    	simul="n"
    	targetDir=$2
    else
    	if [ $2 -a $2 = "nosim" ]; then
    		simul="n"
    	fi
    	targetDir=$1
    fi
    
    # répertoire cible
    if [ ! $targetDir ]; then
    	echo "La cible (dev ou prod), svp ? "
    	read targetDir
    fi
    
    if [ $targetDir = "dev" ]; then
        targetDir=$dev
    else
        if [ $targetDir = "prod" ]; then
            targetDir=$prod
        else
            echo "Répertoire cible inconnu!"
            echo "------------------------------------------------------------------------------------------------------"
            echo
            exit
        fi
    fi
    
    echo "Répertoire cible  : $targetDir"
    
    # simulation préalable
    if [ $simul = "o" ]; then
    	echo
    	echo "SIMULATION :"
    	echo "------------"
    	rsync -avzn --perms --delete $EXCLUSIONS -e ssh $sourceDir $targetDir
    
    	echo
    	echo -n "Procéder à la synchronisation ? (o/n) "
    	read doit
    fi
    
    # logging
    ts=`date +%d/%m/%Y-%H:%M:%S`
    echo "------------------------------------------------------------------------------------------------------" >> $LOG_FILE
    echo "$ts : $0 $*" >> $LOG_FILE
    
    # synchronisation
    if [ $doit = "o" ]; then
    	echo
    	echo "SYNCHRONISATION :"
    	echo "-----------------"
    	rsync -avz --perms --delete $EXCLUSIONS -e ssh --log-file=$LOG_FILE $sourceDir $targetDir
    fi
    
    echo "------------------------------------------------------------------------------------------------------"
    echo