-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.sh
executable file
·44 lines (38 loc) · 1.44 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# deployment script for the change_from_address patch for the ReminderUserAccessDashboardEmail cron job
# Clone the repo that has this file via
#
# git clone [email protected]:ctsit/change_from_address_in_dashboard_reminder.git
#
# Call this script with two parameters:
#
# REDCAP_ROOT - the top level redcap directory. typically this directory contains cron.php
# REDCAP_VERSION - the version of the code being patched/deployed.
#
set -e
export REDCAP_ROOT=$1
export REDCAP_VERSION=$2
# determine the directory where this script resides
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Enumerate available patch files
PATCH_VERSIONS=$(mktemp)
CWD=`pwd`
cd $DIR
$(ls *.patch | grep -v "sql" | sed "s/\.patch//;" > $PATCH_VERSIONS)
cd $CWD
# Get version string of the best patch file
if [[ $(cat $PATCH_VERSIONS | grep "$REDCAP_VERSION") ]]; then
REDCAP_PATCH_VERSION=$REDCAP_VERSION
else
echo "${REDCAP_VERSION}" >> "$PATCH_VERSIONS"
if [[ "$(cat $PATCH_VERSIONS | sort -V | head -n 1)" == "$REDCAP_VERSION" ]]; then
# provided version is earlier than any updated version, use base patch.patch file
REDCAP_PATCH_VERSION="patch"
else
# use closest lower version patch file
REDCAP_PATCH_VERSION=$(cat $PATCH_VERSIONS | sort -V | grep "$REDCAP_VERSION" -B 1 | head -n1)
fi
fi
rm $PATCH_VERSIONS
cd $REDCAP_ROOT/redcap_v$REDCAP_VERSION/Classes/
patch -p1 < $DIR/${REDCAP_PATCH_VERSION}.patch