This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
autodeploy-drupal-make.sh
executable file
·90 lines (69 loc) · 2.21 KB
/
autodeploy-drupal-make.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
#set -x
E_BADARGS=65
EXPECTED_ARGS=4
if [ $# -ne $EXPECTED_ARGS ]
then
echo " This script expect $EXPECTED_ARGS arguments instead of $#"
exit $E_BADARGS
fi
MV=$(which mv)
RM=$(which rm)
DATE=$(which date)
SED=$(which sed)
CAT=$(which cat)
DRUSH=$(which drush)
### CONFIG
DEP_NAME=$1
DEP_BRANCH=$2
DEP_USER=$3
MAKEFILE_NAME=$4
. $($(which dirname) $($(which readlink) -f "$0"))/autodeploy-common.sh
# Clonar RAMA REPO con submoduless en dir tmp
# clone-with-subs.sh $REPO $BRANCH $TARGET
. $LIB/clone-with-subs.sh $REPO_BARE $DEP_BRANCH $TMP_DIR $TAG
# Build 1
BUILD_DIR="$TMP_DIR/tmp"
COLUMNS=72 $DRUSH make $TMP_DIR/$MAKEFILE_NAME $BUILD_DIR
#BUILD_SITES_DIR="$TMP_DIR/tmp2"
#COLUMNS=72 $DRUSH make --contrib-destination --working-copy --no-core $TMP_DIR/drupal-org.make $BUILD_SITES_DIR
#$MV -a $BUILD_SITES_DIR/* $BUILD_DIR/sites/all/
# Copiar files y settings
# copy-files-settings.sh $SOURCE $TARGET
. $LIB/drupal-copy-files-settings.sh $DST_DIR $BUILD_DIR
# Arreglar permisos
# fix-drupal-perms.sh $TARGET
if [ "${FIX_PERMS}" = 'true' ]; then
. $LIB/drupal-fix-perms.sh $BUILD_DIR
fi
# Firmar Robots
REPO_HASH=$($CAT $TMP_DIR/.git_hash)
REPO_DATE=$($CAT $TMP_DIR/.git_date)
SIGN="# Environment generated by $DEP_USER from $DEP_BRANCH (hash: $REPO_HASH, date: $REPO_DATE, make-file: $MAKEFILE_NAME) for site $SITE_NAME on $($DATE '+%Y-%m-%d %H:%M %Z')"
$SED -i '1{s|^|'"${SIGN}\n"'|}' $BUILD_DIR/robots.txt
# Eliminar archivos no para produccion
$RM $BUILD_DIR/.git*
# Loggear despliegue
LOG_DIR=$($(which dirname) "${LOG_FILE}")
if [ ! -d $LOG_DIR ]; then
mkdir -p $LOG_DIR
fi
echo -e "$($DATE '+%Y-%m-%d %H:%M %Z')\t$DEP_BRANCH\t$REPO_DATE\t$REPO_HASH\t$DEP_USER" >> $LOG_FILE
$RM -r $DST_DIR
$MV $BUILD_DIR $DST_DIR
$RM -r $TMP_DIR
# Reload apache
restartServerIfNecesary
# Update y revert de features
COLUMNS=72 $DRUSH -r $DST_DIR -l $SITE_NAME cc all
COLUMNS=72 $DRUSH -r $DST_DIR -l $SITE_NAME updatedb -y
#COLUMNS=72 $DRUSH -r $DST_DIR -l $SITE_NAME fra -y
COLUMNS=72 $DRUSH cache-clear drush
COLUMNS=72 $DRUSH -r $DST_DIR -l $SITE_NAME features-revert-all -y
# Borrar caches
if [ "$CC" != 'false' ]; then
COLUMNS=72 $DRUSH -r $DST_DIR -l $SITE_NAME cc all
fi
# Clean Varnish
cleanVarnishIfNecesary
exit 0