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-yii.sh
executable file
·79 lines (59 loc) · 1.84 KB
/
autodeploy-yii.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
#!/bin/bash
# Type of script: unattended
# To be runned on: -
# To be runned by: root
# Arguments: $SITE $BRANCH $DEP_USER
# Local dependencies: To be runned from an updated repository, git-archive-all.sh
# Remote dependencies: - none -
# Short description: A script to deploy a working copy of $BRANCH from $REPO of $SITE logging $GL_USER
# ${SCRIPT_DIR}/sudo/autodeploy-drupal.sh ${DEPLOY_NAME} ${BRANCH_NAME} ${GL_USER}
E_BADARGS=65
EXPECTED_ARGS=3
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
. $($(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
# Copiar files y settings
# copy-files-settings.sh $SOURCE $TARGET
. $LIB/yii-copy-files-settings.sh $DST_DIR $TMP_DIR
# Arreglar permisos
# fix-drupal-perms.sh $TARGET
if [ "${FIX_PERMS}" = 'true' ]; then
. $LIB/yii-fix-perms.sh $TMP_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) for site $SITE_NAME on $($DATE '+%Y-%m-%d %H:%M %Z')"
$SED -i '1{s|^|'"${SIGN}\n"'|}' $TMP_DIR/htdocs/robots.txt
# Eliminar archivos no para produccion
$RM $TMP_DIR/.git*
# Loggear despliegue
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 $TMP_DIR $DST_DIR
# Reload apache
restartServerIfNecesary
# Borrar caches
# Pending
#pushd $(pwd)
#cd $DST_DIR
#popd
# Clean Varnish
cleanVarnishIfNecesary
exit 0