1
|
#!/bin/bash
|
2
|
|
3
|
#
|
4
|
#
|
5
|
#
|
6
|
#
|
7
|
DRUPAL_VERSION="7"
|
8
|
SVN_USER="edit-jenkins"
|
9
|
|
10
|
|
11
|
##############################################################
|
12
|
# NOTE: the ssh host should be configured in the ~/.ssh/config:
|
13
|
# Host edit-deploy
|
14
|
# HostName <ip ot host name>
|
15
|
# User <deployment-user>
|
16
|
#
|
17
|
# At the server to be delpoyed to you need to setup and configure the
|
18
|
|
19
|
# 1. crate the <deployment-user>
|
20
|
#
|
21
|
# 2. assuming you are logged in as the <deployment-user>:
|
22
|
#
|
23
|
# echo "umask 0126" >> ~/.bashrc :
|
24
|
#
|
25
|
# 3. user 'www-data' must be member of the group of the <deployment-user>
|
26
|
#
|
27
|
# 4. The permissions of the folders to delpoyed to must be set to 775 ownership must be adjusted:
|
28
|
# chmod -R 775 <the folders>
|
29
|
# chown -R www-data:deploy <the folders>
|
30
|
#
|
31
|
#
|
32
|
SSH_HOST='edit-deploy'
|
33
|
##############################################################
|
34
|
|
35
|
if [ -z "$1" ]; then
|
36
|
echo "version parameter missing\nUsage: deploy.sh <version-number>"
|
37
|
exit -1
|
38
|
fi
|
39
|
VERSION=$1
|
40
|
|
41
|
# $WORKSPACE is an environment variable set by jenkins
|
42
|
if [ -z "$WORKSPACE" ]; then
|
43
|
echo "ERROR: environment variable WORKSPACE should be set by jenkins but is missing."
|
44
|
exit -1
|
45
|
fi
|
46
|
|
47
|
# check if tag exists
|
48
|
set +e # turn of "exit script on failure", since we expect that svn tags may not always exist
|
49
|
TAG_EXISTS=(`svn info http://dev.e-taxonomy.eu/svn/tags/drupal/module-cdm_dataportal/$VERSION 2> /dev/null | grep URL`)
|
50
|
set -e # turn on again "exit script on failure"
|
51
|
|
52
|
|
53
|
|
54
|
if [ -z "$TAG_EXISTS" ]; then
|
55
|
# it is a new version number ...
|
56
|
|
57
|
#
|
58
|
# compile the sass files to css in the zen_dataportal theme
|
59
|
# this will create the versions needed for production
|
60
|
#
|
61
|
if [ -x "$COMPASS" ]; then
|
62
|
$COMPASS clean $WORKSPACE/themes/zen_dataportal/
|
63
|
$COMPASS compile $WORKSPACE/themes/zen_dataportal/
|
64
|
svn --username=$SVN_USER ci -m "sass compiled for production purposes prior release"
|
65
|
else
|
66
|
echo "ERROR on sass compilation since the evnvironment variable COMPASS is either missing or not the file "$COMPASS" is not executable"
|
67
|
exit 1
|
68
|
fi
|
69
|
|
70
|
# create release tag and branch for the module
|
71
|
svn --username=$SVN_USER copy -m "release tag for cdm_dataportal $VERSION" http://dev.e-taxonomy.eu/svn/trunk/drupal/${DRUPAL_VERSION}.x/modules/cdm_dataportal http://dev.e-taxonomy.eu/svn/tags/drupal/module-cdm_dataportal/$VERSION
|
72
|
svn --username=$SVN_USER copy -m "branch for cdm_dataportal $VERSION" http://dev.e-taxonomy.eu/svn/tags/drupal/module-cdm_dataportal/$VERSION http://dev.e-taxonomy.eu/svn/branches/drupal/module-cdm_dataportal-RELEASE-$VERSION
|
73
|
|
74
|
#create release tag and branch for the themes
|
75
|
svn --username=$SVN_USER copy -m "release tag for drupal themes $VERSION" http://dev.e-taxonomy.eu/svn/trunk/drupal/${DRUPAL_VERSION}.x/themes http://dev.e-taxonomy.eu/svn/tags/drupal/themes/$VERSION
|
76
|
svn --username=$SVN_USER copy -m "branch for drupal themes $VERSION" http://dev.e-taxonomy.eu/svn/tags/drupal/themes/$VERSION http://dev.e-taxonomy.eu/svn/branches/drupal/themes-RELEASE-$VERSION
|
77
|
fi
|
78
|
|
79
|
|
80
|
#
|
81
|
# pack and deploy the cdm_dataportal module
|
82
|
#
|
83
|
cd $WORKSPACE/cdm_dataportal
|
84
|
#create the target folder
|
85
|
if [ ! -d target ]; then
|
86
|
mkdir target
|
87
|
fi
|
88
|
cd target
|
89
|
rm -rf *
|
90
|
|
91
|
# create the module-cdm_dataportal archive
|
92
|
svn --username=$SVN_USER export http://dev.e-taxonomy.eu/svn/tags/drupal/module-cdm_dataportal/$VERSION ./cdm_dataportal
|
93
|
tar czf cdm_dataportal-$VERSION.tar.gz ./cdm_dataportal
|
94
|
|
95
|
# create the drupal${DRUPAL_VERSION}-cdm_dataportal archive ...
|
96
|
|
97
|
# downlod latest and unpack
|
98
|
ARCHIVE_URL=(`lynx -dump http://wp5.e-taxonomy.eu/download/dataportal/stable/ | grep "download/dataportal/stable/drupal${DRUPAL_VERSION}-cdm_dataportal" | head -n 1 | sed -e "s/.*\(http.*\)/\1/g"`)
|
99
|
|
100
|
if [ -z "$ARCHIVE_URL" ]; then
|
101
|
echo "http://wp5.e-taxonomy.eu/download/dataportal/stable/ does not contain drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz file, please check this symling on the server"
|
102
|
exit -1;
|
103
|
fi
|
104
|
|
105
|
curl --output drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz $ARCHIVE_URL
|
106
|
tar xzf drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz
|
107
|
|
108
|
# update the update script update-to.sh
|
109
|
rsync -r --exclude=.svn ../jenkins-ci/dataportal-version-update/ drupal${DRUPAL_VERSION}-cdm_dataportal/sites/all
|
110
|
|
111
|
# update the module and themes
|
112
|
cd drupal${DRUPAL_VERSION}-cdm_dataportal/sites/all
|
113
|
./update-to.sh $VERSION
|
114
|
|
115
|
# copy the profiles
|
116
|
cd ../../
|
117
|
rsync -r --exclude=.svn sites/all/modules/cdm_dataportal/profile/ profiles/
|
118
|
|
119
|
# make tar
|
120
|
cd ../
|
121
|
tar czf drupal${DRUPAL_VERSION}-cdm_dataportal-$VERSION.tar.gz drupal${DRUPAL_VERSION}-cdm_dataportal
|
122
|
rm -rf drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz
|
123
|
|
124
|
# create the new folder on the server and upload everything
|
125
|
ssh ${SSH_HOST} "rm -rf /var/www/download/dataportal/$VERSION"
|
126
|
ssh ${SSH_HOST} "mkdir /var/www/download/dataportal/$VERSION"
|
127
|
ssh ${SSH_HOST} "rm -r /var/www/download/dataportal/stable"
|
128
|
ssh ${SSH_HOST} "ln -s /var/www/download/dataportal/$VERSION /var/www/download/dataportal/stable"
|
129
|
scp cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
|
130
|
scp drupal${DRUPAL_VERSION}-cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
|
131
|
|
132
|
# DONE
|
133
|
echo "cdm_dataportal deployment done!"
|
134
|
|
135
|
|
136
|
|
137
|
|
138
|
|
139
|
|
140
|
|
141
|
|
142
|
|
143
|
|