-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathupgradeTestRail.sh
More file actions
executable file
·100 lines (80 loc) · 3.57 KB
/
Copy pathupgradeTestRail.sh
File metadata and controls
executable file
·100 lines (80 loc) · 3.57 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
timeStamp=$(date "+%Y.%m.%d-%H.%M.%S")
dbFolder=_mysql
optFolder=_opt
confFolder=_config
# value for the variable cassandraDeprecationVersion will need to be updated with actual deprecation version.
cassandraDeprecationVersion="9.5.1"
cassandraIsDeprecated="true"
backupDir=backup
mkdir -p $backupDir
echo
echo "###########################################################################################"
echo " TestRail quick upgrade"
echo " This script will help you to upgrade TestRail."
echo " It currently only works with the 'standard docker-compose.yml' file , which uses Apache."
echo " !! Important: If you're running nginx, you need to do the update manually for now."
echo
echo " Please be aware that you will need 'sudo' installed to run this script."
echo "###################################################################################"
echo
read -p "Press 'Enter' to continue (or Ctrl+C to abort)"
echo
echo "Upgrading TestRail"
echo " -- assuming the DB is in _mysql and the reports/attachments/... files in _opt"
echo
echo "These TestRail versions are available"
wget -q -O - "https://hub.docker.com/v2/repositories/testrail/apache/tags" | grep -o '"name": *"[^"]*' | grep -o '[^"]*$'
echo
read -r -p "Press 'l' to continue with 'latest' or type in the version you want to use: " version
echo
if [ "$version" = 'l' ]; then
sed -i "s/TESTRAIL_VERSION=.*/TESTRAIL_VERSION=latest/g" .env
else
if grep -Fxq "TESTRAIL_VERSION" .env
then
sed -i "s/TESTRAIL_VERSION=.*/TESTRAIL_VERSION=${version}/g" .env
else
echo "TESTRAIL_VERSION=${version}" >> .env
fi
fi
# Normalize versions to 3-part format (e.g., 9 -> 9.0.0, 9.0 -> 9.0.0)
normalize_version() {
echo "$1" | awk -F. '{ printf("%d.%d.%d\n", $1, $2?$2:0, $3?$3:0) }'
}
version=$(normalize_version "$version")
cassandraDeprecationVersion=$(normalize_version "$cassandraDeprecationVersion")
if [ "$(printf '%s\n' "$version" "$cassandraDeprecationVersion" | sort -V | head -n1)" == "$version" ] && [ "$version" != "$cassandraDeprecationVersion" ]; then
cassandraIsDeprecated="false"
else
echo "Cassandra Deprecation Applied for Provided Testrail Version '${version}'"
fi
echo
echo "###########################################################################################"
echo " If you're upgrading from a docker applicance, simply continue. Otherwise, do these steps:"
echo " * Ensure that the 'config.php' file is in the '_config folder'."
echo " * Copy the content of /var/lib/mysql to '_mysql'"
echo " (if you're using a dedicated mysql server for TestRail -- otherwise do a manual upgrade)"
if [ "$cassandraIsDeprecated" == "false" ]; then
echo " * Copy the content of /var/lib/cassandra to '_cassandra'"
fi
echo " (if you're using a dedicated mysql server for TestRail -- otherwise do a manual upgrade)"
echo " * Copy/Move your attachment, reports, logs, and audit folders into '_opt'."
echo
echo " When you're done with these steps, simply continue."
echo "###################################################################################"
echo
read -p "Press 'Enter' to continue (or Ctrl+C to abort)"
echo
echo "Creating backup file"
sudo tar czf "${backupDir}/testrail-backup-${timeStamp}".tar.gz $optFolder $dbFolder $confFolder
echo "Getting new TestRail version and then restarting TestRail"
docker-compose pull
docker-compose down -v --remove-orphans
if [ "$cassandraIsDeprecated" == "true" ]; then
docker-compose -f docker-compose.yml up -d
else
docker-compose -f docker-compose.yml -f docker-compose-override-cassandra.yml up -d
fi
echo
echo "We're done :-)"