Project

General

Profile

Download (3.33 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 delpoyed 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 delpoyed 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
# pack and deploy the cdm_dataportal module
48
#
49

    
50
mkdir -p target
51

    
52
echo "creating the module-cdm_dataportal archive: cdm_dataportal-$VERSION.tar.gz"
53
tar -C $WORKSPACE -czf target/cdm_dataportal-$VERSION.tar.gz modules/cdm_dataportal
54

    
55
if $DO_CREATE_DRUPAL_INSTALLER ; then  
56

    
57
  echo "creating the drupal${DRUPAL_VERSION}-cdm_dataportal archive ..."
58
  
59
  # TODO better use drush for the assembly
60

    
61
  # downlod latest and unpack
62
  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"`)
63

    
64
  if [ -z "$ARCHIVE_URL" ]; then
65
    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"
66
    exit -1;
67
  fi
68

    
69
  curl --output drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz $ARCHIVE_URL
70
  tar xzf drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz
71

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

    
75
  # update the module and themes
76
  cd drupal${DRUPAL_VERSION}-cdm_dataportal/sites/all
77
  ./update-to.sh $VERSION
78

    
79
  # copy the profiles
80
  cd ../../
81
  rsync -r --exclude=.svn sites/all/modules/cdm_dataportal/profile/ profiles/
82

    
83
  # make tar
84
  cd ../
85
  tar czf drupal${DRUPAL_VERSION}-cdm_dataportal-$VERSION.tar.gz drupal${DRUPAL_VERSION}-cdm_dataportal
86
  rm -rf drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz
87
fi
88

    
89
# create the new folder on the server and upload everything
90
ssh ${SSH_HOST} "rm -rf /var/www/download/dataportal/$VERSION"
91
ssh ${SSH_HOST} "mkdir /var/www/download/dataportal/$VERSION"
92
ssh ${SSH_HOST} "rm -r /var/www/download/dataportal/stable"
93
ssh ${SSH_HOST} "ln -s /var/www/download/dataportal/$VERSION /var/www/download/dataportal/stable"
94
scp target/cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
95
if $DO_CREATE_DRUPAL_INSTALLER ; then
96
  scp target/drupal${DRUPAL_VERSION}-cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
97
fi
98
  
99
# DONE
100
echo "cdm_dataportal deployment done!"
101

    
102

    
103

    
104

    
105

    
106

    
107

    
108

    
109

    
110

    
(1-1/4)