Project

General

Profile

Download (3.46 KB) Statistics
| Branch: | Tag: | Revision:
1 6657531f Andreas Kohlbecker
#!/bin/bash
2
3 e1a98fc1 Andreas Kohlbecker
DRUPAL_VERSION="7"
4 6657531f Andreas Kohlbecker
5 bcb6df2c Andreas Kohlbecker
GIT_REPO_URL="edit-git:/var/git/cdm-dataportal.git"
6
7 03e53b89 Andreas Kohlbecker
DO_CREATE_DRUPAL_INSTALLER=false
8
9 996c0a9d Andreas Kohlbecker
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 e2e159b4 Andreas Kohlbecker
# At the server to be deployed to you need to setup and configure the
17 996c0a9d Andreas Kohlbecker
18 03e53b89 Andreas Kohlbecker
# 1. create the <deployment-user> 
19 996c0a9d Andreas Kohlbecker
#
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 e2e159b4 Andreas Kohlbecker
# 4. The permissions of the folders to deployed to must be set to 775 ownership must be adjusted:
27 996c0a9d Andreas Kohlbecker
#   chmod -R 775 <the folders>
28
#   chown -R www-data:deploy <the folders> 
29
# 
30
#  
31
SSH_HOST='edit-deploy'
32
##############################################################
33
34 6657531f Andreas Kohlbecker
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 90fcfc17 Andreas Kohlbecker
if [ -z "$WORKSPACE" ]; then
42
  echo "ERROR: environment variable WORKSPACE should be set by jenkins but is missing."
43
  exit -1
44 6657531f Andreas Kohlbecker
fi
45
46 e2e159b4 Andreas Kohlbecker
#
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 90fcfc17 Andreas Kohlbecker
#
54
# pack and deploy the cdm_dataportal module
55
#
56 6657531f Andreas Kohlbecker
57 03e53b89 Andreas Kohlbecker
mkdir -p target
58 6657531f Andreas Kohlbecker
59 03e53b89 Andreas Kohlbecker
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 6657531f Andreas Kohlbecker
62 03e53b89 Andreas Kohlbecker
if $DO_CREATE_DRUPAL_INSTALLER ; then  
63 6657531f Andreas Kohlbecker
64 03e53b89 Andreas Kohlbecker
  echo "creating the drupal${DRUPAL_VERSION}-cdm_dataportal archive ..."
65
  
66
  # TODO better use drush for the assembly
67 6657531f Andreas Kohlbecker
68 03e53b89 Andreas Kohlbecker
  # 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 6657531f Andreas Kohlbecker
76 03e53b89 Andreas Kohlbecker
  curl --output drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz $ARCHIVE_URL
77
  tar xzf drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz
78 6657531f Andreas Kohlbecker
79 03e53b89 Andreas Kohlbecker
  # 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 6657531f Andreas Kohlbecker
82 03e53b89 Andreas Kohlbecker
  # update the module and themes
83
  cd drupal${DRUPAL_VERSION}-cdm_dataportal/sites/all
84
  ./update-to.sh $VERSION
85 6657531f Andreas Kohlbecker
86 03e53b89 Andreas Kohlbecker
  # 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 6657531f Andreas Kohlbecker
96
# create the new folder on the server and upload everything
97 996c0a9d Andreas Kohlbecker
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 627b371b Andreas Kohlbecker
scp target/cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
102 03e53b89 Andreas Kohlbecker
if $DO_CREATE_DRUPAL_INSTALLER ; then
103 627b371b Andreas Kohlbecker
  scp target/drupal${DRUPAL_VERSION}-cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
104 03e53b89 Andreas Kohlbecker
fi
105
  
106 6657531f Andreas Kohlbecker
# DONE
107
echo "cdm_dataportal deployment done!"
108
109
110
111
112
113
114
115
116