Skip to content

Commit f086157

Browse files
authored
Clean up the refactor (#907)
- Use source appropriately (needed for config to propagate properly) - Standardize group/endgroup line-spacing - Clean up envvar defaults
1 parent 568f905 commit f086157

13 files changed

+28
-39
lines changed

install.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010
log_file="sentry_install_log-`date +'%Y-%m-%d_%H-%M-%S'`.txt"
1111
exec &> >(tee -a "$log_file")
1212

13-
source ./install/_lib.sh
13+
source "$(dirname $0)/install/_lib.sh"
1414

1515
echo "${_group}Defining variables and helpers ..."
1616
MIN_DOCKER_VERSION='19.03.6'
@@ -139,7 +139,7 @@ if [[ "$IS_KVM" -eq 0 ]]; then
139139
fi
140140
echo "${_endgroup}"
141141

142-
./install/create-docker-volumes.sh
142+
source ./install/create-docker-volumes.sh
143143

144144
echo "${_group}Ensuring files from examples ..."
145145
ensure_file_from_example $SENTRY_CONFIG_PY
@@ -265,14 +265,14 @@ for topic in $NEEDED_KAFKA_TOPICS; do
265265
done
266266
echo "${_endgroup}"
267267

268-
./install/upgrade-postgres.sh
269-
./install/set-up-and-migrate-database.sh
270-
./install/migrate-file-storage.sh
271-
./install/relay-credentials.sh
272-
./install/geoip.sh
268+
source ./install/upgrade-postgres.sh
269+
source ./install/set-up-and-migrate-database.sh
270+
source ./install/migrate-file-storage.sh
271+
source ./install/relay-credentials.sh
272+
source ./install/geoip.sh
273273

274274
if [[ "$MINIMIZE_DOWNTIME" ]]; then
275-
./install/restart-carefully.sh
275+
source ./install/restart-carefully.sh
276276
else
277277
echo ""
278278
echo "-----------------------------------------------------------------"

install/_lib.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#!/usr/bin/env bash
21
set -euo pipefail
2+
test "${DEBUG:-}" && set -x
33

44
# Work from the onpremise root, no matter which script is called from where.
55
if [[ "$(basename $0)" = "install.sh" ]]; then
@@ -15,7 +15,7 @@ define_stuff() {
1515
# Read .env for default values with a tip o' the hat to https://stackoverflow.com/a/59831605/90297
1616
t=$(mktemp) && export -p > "$t" && set -a && . $_ENV && set +a && . "$t" && rm "$t" && unset t
1717

18-
if [ "${GITHUB_ACTIONS:-''}" = "true" ]; then
18+
if [ "${GITHUB_ACTIONS:-}" = "true" ]; then
1919
_group="::group::"
2020
_endgroup="::endgroup::"
2121
else

install/_test_setup.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
set -euo pipefail
2-
test ${DEBUG:-''} && set -x
3-
cd "$(dirname $0)/.."
2+
source "$(dirname $0)/_lib.sh"
43

54
rm -rf /tmp/sentry-onpremise-test-sandbox.*
65
_SANDBOX="$(mktemp -d /tmp/sentry-onpremise-test-sandbox.XXX)"
@@ -10,7 +9,7 @@ report_success() {
109
}
1110

1211
teardown() {
13-
test ${DEBUG:-''} || rm -rf "$_SANDBOX"
12+
test "${DEBUG:-}" || rm -rf "$_SANDBOX"
1413
}
1514

1615
setup() {

install/create-docker-volumes-test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ count() {
1111
before=$(count)
1212
test $before -eq 0 || test $before -eq $expected
1313

14-
./install/create-docker-volumes.sh
15-
./install/create-docker-volumes.sh
16-
./install/create-docker-volumes.sh
14+
source ./install/create-docker-volumes.sh
15+
source ./install/create-docker-volumes.sh
16+
source ./install/create-docker-volumes.sh
1717

1818
test $(count) -eq $expected
1919

install/create-docker-volumes.sh

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env bash
2-
source "$(dirname $0)/_lib.sh"
31
echo "${_group}Creating volumes for persistent storage ..."
42

53
echo "Created $(docker volume create --name=sentry-clickhouse)."

install/geoip-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ mmdb="geoip/GeoLite2-City.mmdb"
55

66
# Starts with no mmdb, ends up with empty.
77
test ! -f $mmdb
8-
./install/geoip.sh
8+
source ./install/geoip.sh
99
diff -rub $mmdb $mmdb.empty
1010

1111
# Doesn't clobber existing, though.
1212
echo GARBAGE > $mmdb
13-
./install/geoip.sh
13+
source ./install/geoip.sh
1414
test "$(cat $mmdb)" = "GARBAGE"
1515

1616
report_success

install/geoip.sh

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env bash
2-
source "$(dirname $0)/_lib.sh"
31
echo "${_group}Setting up GeoIP integration ..."
42

53
install_geoip() {

install/migrate-file-storage.sh

100755100644
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#!/usr/bin/env bash
2-
source "$(dirname $0)/_lib.sh"
3-
41
echo "${_group}Migrating file storage ..."
2+
53
SENTRY_DATA_NEEDS_MIGRATION=$(docker run --rm -v sentry-data:/data alpine ash -c "[ ! -d '/data/files' ] && ls -A1x /data | wc -l || true")
64
if [[ -n "$SENTRY_DATA_NEEDS_MIGRATION" ]]; then
75
# Use the web (Sentry) image so the file owners are kept as sentry:sentry
86
# The `\"` escape pattern is to make this compatible w/ Git Bash on Windows. See #329.
97
$dcr --entrypoint \"/bin/bash\" web -c \
108
"mkdir -p /tmp/files; mv /data/* /tmp/files/; mv /tmp/files /data/files; chown -R sentry:sentry /data"
119
fi
10+
1211
echo "${_endgroup}"

install/relay-credentials-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ test ! -f $cfg
99
test ! -f $creds
1010

1111
# Running the install script adds them.
12-
./install/relay-credentials.sh
12+
source ./install/relay-credentials.sh
1313
test -f $cfg
1414
test -f $creds
1515
test "$(jq -r 'keys[2]' $creds)" = "secret_key"
1616

1717
# If the files exist we don't touch it.
1818
echo GARBAGE > $cfg
1919
echo MOAR GARBAGE > $creds
20-
./install/relay-credentials.sh
20+
source ./install/relay-credentials.sh
2121
test "$(cat $cfg)" = "GARBAGE"
2222
test "$(cat $creds)" = "MOAR GARBAGE"
2323

install/relay-credentials.sh

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env bash
2-
source "$(dirname $0)/_lib.sh"
31
echo "${_group}Generating Relay credentials ..."
42

53
RELAY_CONFIG_YML="relay/config.yml"

0 commit comments

Comments
 (0)