Project

General

Profile

Download (3.46 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/bash
2

    
3
DRUPAL_VERSION="7"
4

    
5
GIT_REPO_URL="edit-git:/var/git/cdm-dataportal.git"
6

    
7
DO_CREATE_DRUPAL_INSTALLER=false
8

    
9

    
10
##############################################################
11
# NOTE: the ssh host should be configured in the ~/.ssh/config:
12
#     Host edit-deploy
13
#     HostName <ip ot host name>
14
#     User <deployment-user>
15
# 
16
# At the server to be deployed to you need to setup and configure the
17

    
18
# 1. create the <deployment-user> 
19
#
20
# 2. assuming you are logged in as the <deployment-user>:
21
#
22
#  echo "umask 0126" >> ~/.bashrc : 
23
#   
24
# 3. user 'www-data' must be member of the group of the <deployment-user>
25
#
26
# 4. The permissions of the folders to deployed to must be set to 775 ownership must be adjusted:
27
#   chmod -R 775 <the folders>
28
#   chown -R www-data:deploy <the folders> 
29
# 
30
#  
31
SSH_HOST='edit-deploy'
32
##############################################################
33

    
34
if [ -z "$1" ]; then
35
	echo "version parameter missing\nUsage: deploy.sh <version-number>"
36
  exit -1
37
fi
38
VERSION=$1
39

    
40
# $WORKSPACE is an environment variable set by jenkins
41
if [ -z "$WORKSPACE" ]; then
42
  echo "ERROR: environment variable WORKSPACE should be set by jenkins but is missing."
43
  exit -1
44
fi
45

    
46
#
47
# set version for release
48
#
49

    
50
sed -i -e 's/^version.*$/version = 7.x-'$VERSION'/g' $WORKSPACE/modules/cdm_dataportal/cdm_dataportal.info
51

    
52

    
53
#
54
# pack and deploy the cdm_dataportal module
55
#
56

    
57
mkdir -p target
58

    
59
echo "creating the module-cdm_dataportal archive: cdm_dataportal-$VERSION.tar.gz"
60
tar czf target/cdm_dataportal-$VERSION.tar.gz $WORKSPACE/modules/cdm_dataportal
61

    
62
if $DO_CREATE_DRUPAL_INSTALLER ; then  
63

    
64
  echo "creating the drupal${DRUPAL_VERSION}-cdm_dataportal archive ..."
65
  
66
  # TODO better use drush for the assembly
67

    
68
  # downlod latest and unpack
69
  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"`)
70

    
71
  if [ -z "$ARCHIVE_URL" ]; then
72
    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"
73
    exit -1;
74
  fi
75

    
76
  curl --output drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz $ARCHIVE_URL
77
  tar xzf drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz
78

    
79
  # update the update script update-to.sh
80
  rsync -r --exclude=.svn ../jenkins-ci/dataportal-version-update/ drupal${DRUPAL_VERSION}-cdm_dataportal/sites/all
81

    
82
  # update the module and themes
83
  cd drupal${DRUPAL_VERSION}-cdm_dataportal/sites/all
84
  ./update-to.sh $VERSION
85

    
86
  # copy the profiles
87
  cd ../../
88
  rsync -r --exclude=.svn sites/all/modules/cdm_dataportal/profile/ profiles/
89

    
90
  # make tar
91
  cd ../
92
  tar czf drupal${DRUPAL_VERSION}-cdm_dataportal-$VERSION.tar.gz drupal${DRUPAL_VERSION}-cdm_dataportal
93
  rm -rf drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz
94
fi
95

    
96
# create the new folder on the server and upload everything
97
ssh ${SSH_HOST} "rm -rf /var/www/download/dataportal/$VERSION"
98
ssh ${SSH_HOST} "mkdir /var/www/download/dataportal/$VERSION"
99
ssh ${SSH_HOST} "rm -r /var/www/download/dataportal/stable"
100
ssh ${SSH_HOST} "ln -s /var/www/download/dataportal/$VERSION /var/www/download/dataportal/stable"
101
scp target/cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
102
if $DO_CREATE_DRUPAL_INSTALLER ; then
103
  scp target/drupal${DRUPAL_VERSION}-cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
104
fi
105
  
106
# DONE
107
echo "cdm_dataportal deployment done!"
108

    
109

    
110

    
111

    
112

    
113

    
114

    
115

    
116

    
117

    
(1-1/4)