Project

General

Profile

Download (3.33 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 c371caa4 Andreas Kohlbecker
# At the server to be delpoyed 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 c371caa4 Andreas Kohlbecker
# 4. The permissions of the folders to delpoyed 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 90fcfc17 Andreas Kohlbecker
#
47
# pack and deploy the cdm_dataportal module
48
#
49 6657531f Andreas Kohlbecker
50 03e53b89 Andreas Kohlbecker
mkdir -p target
51 6657531f Andreas Kohlbecker
52 03e53b89 Andreas Kohlbecker
echo "creating the module-cdm_dataportal archive: cdm_dataportal-$VERSION.tar.gz"
53 6f300451 Andreas Kohlbecker
tar -C $WORKSPACE -czf target/cdm_dataportal-$VERSION.tar.gz modules/cdm_dataportal
54 6657531f Andreas Kohlbecker
55 03e53b89 Andreas Kohlbecker
if $DO_CREATE_DRUPAL_INSTALLER ; then  
56 6657531f Andreas Kohlbecker
57 03e53b89 Andreas Kohlbecker
  echo "creating the drupal${DRUPAL_VERSION}-cdm_dataportal archive ..."
58
  
59
  # TODO better use drush for the assembly
60 6657531f Andreas Kohlbecker
61 03e53b89 Andreas Kohlbecker
  # 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 6657531f Andreas Kohlbecker
69 03e53b89 Andreas Kohlbecker
  curl --output drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz $ARCHIVE_URL
70
  tar xzf drupal${DRUPAL_VERSION}-cdm_dataportal.tar.gz
71 6657531f Andreas Kohlbecker
72 03e53b89 Andreas Kohlbecker
  # 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 6657531f Andreas Kohlbecker
75 03e53b89 Andreas Kohlbecker
  # update the module and themes
76
  cd drupal${DRUPAL_VERSION}-cdm_dataportal/sites/all
77
  ./update-to.sh $VERSION
78 6657531f Andreas Kohlbecker
79 03e53b89 Andreas Kohlbecker
  # 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 6657531f Andreas Kohlbecker
89
# create the new folder on the server and upload everything
90 996c0a9d Andreas Kohlbecker
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 627b371b Andreas Kohlbecker
scp target/cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
95 03e53b89 Andreas Kohlbecker
if $DO_CREATE_DRUPAL_INSTALLER ; then
96 627b371b Andreas Kohlbecker
  scp target/drupal${DRUPAL_VERSION}-cdm_dataportal-${VERSION}.tar.gz ${SSH_HOST}:/var/www/download/dataportal/${VERSION}/
97 03e53b89 Andreas Kohlbecker
fi
98
  
99 6657531f Andreas Kohlbecker
# DONE
100
echo "cdm_dataportal deployment done!"
101
102
103
104
105
106
107
108
109