File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -237,7 +237,16 @@ gitlab_uninstall_unused_database_client() {
237
237
REGEX_DB_CLIENT_VERSIONS_IN_USE=" -common${DB_CLIENT_VERSIONS_IN_USE} "
238
238
239
239
# remove unused client using regex above
240
- UNUSED_DB_CLIENTS=$( apt-cache pkgnames postgresql-client | grep -v -e " ${REGEX_DB_CLIENT_VERSIONS_IN_USE} " | tr ' \n' ' ' )
240
+ # grep may return non-zero code on mo match, so fake the exit code with the `|| true` to swallow that
241
+ UNUSED_DB_CLIENTS=$( apt-cache pkgnames postgresql-client | grep -v -e " ${REGEX_DB_CLIENT_VERSIONS_IN_USE} " || true)
242
+ if [[ " ${UNUSED_DB_CLIENTS} " == " " ]]; then
243
+ echo " - All installed version of clients are in use. Did not uninstalled any client..."
244
+ return
245
+ fi
246
+
247
+ # just to get clean log, convert newline (package name delimiter) to single whitespace
248
+ UNUSED_DB_CLIENTS=$( echo ${UNUSED_DB_CLIENTS} | tr ' \n' ' ' )
249
+
241
250
echo " - Uninstalling unused client(s): ${UNUSED_DB_CLIENTS} "
242
251
DEBIAN_FRONTEND=noninteractive apt-get -qq -y purge -- ${UNUSED_DB_CLIENTS} > /dev/null
243
252
fi
You can’t perform that action at this time.
0 commit comments