-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo_upgrade_app.sh
executable file
·118 lines (82 loc) · 2.03 KB
/
go_upgrade_app.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/bash
set -e
BASE=${HOME}/atlassian-tools
. ${BASE}/conf/config.sh
. ${BASE}/lib/utils.sh
BIN="${BASE}"/bin
FULLPATH=$(/usr/bin/readlink -e "$0")
CFG=${BASE}/conf/config.sh
INSTALLER=''
ACTION=''
ABLEMENT=''
[[ $VERBOSE -eq $YES ]] && set -x
###
# FUNCTIONS
###
assert_app_installed() {
[[ -d "${APP_INSTALL_DIR}"/bin ]] || die "app install dir '$APP_INSTALL_DIR/bin' not found"
}
assert_installer_exists() {
[[ -z "$INSTALLER" ]] && INSTALLER=$( get_installer )
[[ -f "$INSTALLER" ]] || die "Installer file not found; '$INSTALLER' "
}
run_installer() {
/usr/bin/chmod +x "${INSTALLER}"
"${INSTALLER}"
}
print_usage() {
local _prg=$(/usr/bin/basename "${FULLPATH}")
cat <<ENDHERE
${_prg}
Upgrade the Atlassian app specified in config file '$CFG'
SYNOPSYS
${_prg} [OPTIONS] <--start | --finish>
USAGE
--start Start an upgrade (stop services, install upgrade, etc.)
--finish Finish an upgrade (re-enable services, re-enable notifications, etc.)
OPTIONS
-h --help Print this help and exit
ENDHERE
}
###
# MAIN
###
# Getopts
ENDWHILE=0
while [[ $# -gt 0 ]] && [[ $ENDWHILE -eq 0 ]] ; do
case $1 in
(-h|--help) print_usage; exit 0;;
(--start)
ACTION='start'
ABLEMENT='disable'
;;
(--finish)
ACTION='finish'
ABLEMENT='enable'
;;
(--) ENDWHILE=1;;
(-*) die "Invalid option '$1'";;
(*) ENDWHILE=1; break;;
esac
shift
done
if [[ $ACTION == 'start' ]] ; then
INSTALLER=$( get_installer )
assert_app_installed
assert_installer_exists
"${BIN}"/backup_config_files.sh
"${BIN}"/set_services.sh $ABLEMENT
run_installer
"${BIN}"/restore_config_files.sh
"${BIN}"/set_notifications.sh $ABLEMENT
"${BIN}"/fix_java_heap_size.sh
"${BIN}"/fix_app_config.sh
"${BIN}"/set_web_access.sh $ABLEMENT
elif [[ $ACTION == 'finish' ]] ; then
"${BIN}"/set_notifications.sh $ABLEMENT
"${BIN}"/set_services.sh $ABLEMENT
"${BIN}"/set_web_access.sh $ABLEMENT
else
die "Missing one of '--start' | '--finish'"
fi
echo "Elapsed time: '$SECONDS' seconds."