Skip to content

Commit 2fd4841

Browse files
Redirect errors to stderr
Ignore check prereqs with $COMP_LINE for autcomplete support.
1 parent 1c182b1 commit 2fd4841

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

launcher

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ compare_version() {
6868
}
6969

7070
check_prereqs() {
71+
# If this command is run because of tab completion, ignore it
72+
[ -n "$COMP_LINE" ] && return
7173
docker_path=`which docker.io 2> /dev/null || which docker`
7274
git_path=`which git`
7375
docker_min_version='20.10.0'
@@ -77,8 +79,8 @@ check_prereqs() {
7779
kernel_min_version='4.4.0'
7880

7981
if [ -z $docker_path ]; then
80-
echo "Docker is not installed, you will need to install Docker in order to run Launcher"
81-
echo "See https://docs.docker.com/installation/"
82+
echo "Docker is not installed, you will need to install Docker in order to run Launcher" >&2
83+
echo "See https://docs.docker.com/installation/" >&2
8284
exit 1
8385
fi
8486

@@ -87,19 +89,19 @@ check_prereqs() {
8789
# it usually complains about swap which does not matter
8890
test=`$docker_path info 2> /dev/null`
8991
if [[ $? -ne 0 ]] ; then
90-
echo "Cannot connect to the docker daemon - verify it is running and you have access"
92+
echo "Cannot connect to the docker daemon - verify it is running and you have access" >&2
9193
exit 1
9294
fi
9395

9496
# 2. running an approved storage driver?
9597
if ! $docker_path info 2> /dev/null | grep -E -q 'Storage Driver: (btrfs|aufs|zfs|overlay2|overlayfs)$'; then
96-
echo "Your Docker installation is not using a supported storage driver. If we were to proceed you may have a broken install."
97-
echo "overlay2 is the recommended storage driver, although zfs and aufs may work as well."
98-
echo "Other storage drivers are known to be problematic."
99-
echo "You can tell what filesystem you are using by running \"docker info\" and looking at the 'Storage Driver' line."
100-
echo
101-
echo "If you wish to continue anyway using your existing unsupported storage driver,"
102-
echo "read the source code of launcher and figure out how to bypass this check."
98+
echo "Your Docker installation is not using a supported storage driver. If we were to proceed you may have a broken install." >&2
99+
echo "overlay2 is the recommended storage driver, although zfs and aufs may work as well." >&2
100+
echo "Other storage drivers are known to be problematic." >&2
101+
echo "You can tell what filesystem you are using by running \"docker info\" and looking at the 'Storage Driver' line." >&2
102+
echo >&2
103+
echo "If you wish to continue anyway using your existing unsupported storage driver," >&2
104+
echo "read the source code of launcher and figure out how to bypass this check." >&2
103105
exit 1
104106
fi
105107

@@ -109,13 +111,13 @@ check_prereqs() {
109111

110112
# At least minimum docker version
111113
if compare_version "${docker_min_version}" "${test}"; then
112-
echo "ERROR: Docker version ${test} not supported, please upgrade to at least ${docker_min_version}, or recommended ${docker_rec_version}"
114+
echo "ERROR: Docker version ${test} not supported, please upgrade to at least ${docker_min_version}, or recommended ${docker_rec_version}" >&2
113115
exit 1
114116
fi
115117

116118
# Recommend newer docker version
117119
if compare_version "${docker_rec_version}" "${test}"; then
118-
echo "WARNING: Docker version ${test} deprecated, recommend upgrade to ${docker_rec_version} or newer."
120+
echo "WARNING: Docker version ${test} deprecated, recommend upgrade to ${docker_rec_version} or newer." >&2
119121
fi
120122

121123
# 4. discourse docker image is downloaded
@@ -127,48 +129,48 @@ check_prereqs() {
127129

128130
# At least minimum version
129131
if compare_version "${git_min_version}" "${test}"; then
130-
echo "ERROR: Git version ${test} not supported, please upgrade to at least ${git_min_version}, or recommended ${git_rec_version}"
132+
echo "ERROR: Git version ${test} not supported, please upgrade to at least ${git_min_version}, or recommended ${git_rec_version}" >&2
131133
exit 1
132134
fi
133135

134136
# Recommend best version
135137
if compare_version "${git_rec_version}" "${test}"; then
136-
echo "WARNING: Git version ${test} deprecated, recommend upgrade to ${git_rec_version} or newer."
138+
echo "WARNING: Git version ${test} deprecated, recommend upgrade to ${git_rec_version} or newer." >&2
137139
fi
138140

139141
# Check minimum kernel version due to https://bugs.ruby-lang.org/issues/13885
140142
test=($(uname -r))
141143

142144
# At least minimum version
143145
if compare_version "${kernel_min_version}" "${test}"; then
144-
echo "ERROR: Kernel version ${test} not supported, please upgrade to at least ${kernel_min_version}"
146+
echo "ERROR: Kernel version ${test} not supported, please upgrade to at least ${kernel_min_version}" >&2
145147
exit 1
146148
fi
147149

148150
# 6. able to attach stderr / out / tty
149151
test=`$docker_path run -i --rm -a stdout -a stderr hello-world`
150152
if [[ "$test" =~ "Hello from Docker" ]] ; then : ; else
151-
echo "Your Docker installation is not working correctly"
152-
echo
153-
echo "See: https://meta.discourse.org/t/docker-error-on-bootstrap/13657/18?u=sam"
153+
echo "Your Docker installation is not working correctly" >&2
154+
echo >&2
155+
echo "See: https://meta.discourse.org/t/docker-error-on-bootstrap/13657/18?u=sam" >&2
154156
exit 1
155157
fi
156158

157159
# 7. enough space for the bootstrap on docker folder
158160
folder=`$docker_path info --format '{{.DockerRootDir}}'`
159161
safe_folder=${folder:-/var/lib/docker}
160162
if [[ -d $safe_folder && $(stat -f --format="%a*%S" $safe_folder)/1024**3 -lt 5 ]] ; then
161-
echo "You have less than 5GB of free space on the disk where $safe_folder is located. You will need more space to continue"
163+
echo "You have less than 5GB of free space on the disk where $safe_folder is located. You will need more space to continue" >&2
162164
df -h $safe_folder
163-
echo
165+
echo >&2
164166
if tty >/dev/null; then
165-
read -p "Would you like to attempt to recover space by cleaning docker images and containers in the system? (y/N)" -n 1 -r
166-
echo
167+
read -p "Would you like to attempt to recover space by cleaning docker images and containers in the system? (y/N)" -n 1 -r >&2
168+
echo >&2
167169
if [[ $REPLY =~ ^[Yy]$ ]]
168170
then
169171
$docker_path container prune --force --filter until=24h >/dev/null
170172
$docker_path image prune --all --force --filter until=24h >/dev/null
171-
echo "If the cleanup was successful, you may try again now"
173+
echo "If the cleanup was successful, you may try again now" >&2
172174
fi
173175
fi
174176
exit 1
@@ -188,6 +190,7 @@ case "$1" in
188190
;;
189191
*)
190192
test -f "${BINDIR}/launcher" || update
193+
echo "run ./launcher update to update launcher" >&2
191194
check_prereqs
192195
exec "${BINDIR}/launcher" "$@"
193196
esac

0 commit comments

Comments
 (0)