Skip to content

Commit 4c94bb6

Browse files
Luke OsborneLuke Osborne
authored andcommitted
quickstart: Add check that psql exists for demo branch
The demo branch uses psql to interactively guide the user through the quickstart. The error message if psql is not on the path will eventually be somewhate clear 'psql: command not found', but it's better to catch this at the beginning and provide a more descriptive message. Change-Id: Ida5cdb78825c4cb3f238268928c4fb016c3615aa Reviewed-on: https://gerrit.readyset.name/c/readyset/+/6682 Reviewed-by: Marcelo Altmann <[email protected]> Tested-by: Buildkite CI
1 parent 6da6db3 commit 4c94bb6

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

quickstart/readyset_demo.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,23 +391,31 @@ print_exit_message() {
391391
fi
392392
}
393393

394+
check_psql_exists() {
395+
if ! command -v psql &>/dev/null; then
396+
echo -e "${RED}psql (PostgreSQL client) is not installed. Please install psql to continue.${NOCOLOR}"
397+
exit 1
398+
fi
399+
}
400+
401+
check_mysql_exists() {
402+
if ! command -v mysql &>/dev/null; then
403+
echo -e "${RED}mysql (MySQL client) is not installed. Please install mysql to continue.${NOCOLOR}"
404+
exit 1
405+
fi
406+
}
407+
394408
switch_on_mode() {
395409
echo -e "${BLUE}Would you like to run the demo or connect to your own db?${NOCOLOR}"
396410
read -rp "demo(d)/postgres(p)/mysql(m): " mode
397411
if [[ $mode == "p" ]]; then
398-
if ! command -v psql &>/dev/null; then
399-
echo -e "${RED}psql (PostgreSQL client) is not installed. Please install psql to continue.${NOCOLOR}"
400-
exit 1
401-
fi
402-
412+
check_psql_exists
403413
run_byo_postgres
404414
elif [[ $mode == "m" ]]; then
405-
if ! command -v mysql &>/dev/null; then
406-
echo -e "${RED}mysql (MySQL client) is not installed. Please install mysql to continue.${NOCOLOR}"
407-
exit 1
408-
fi
415+
check_mysql_exists
409416
run_byo_mysql
410417
elif [[ $mode == "d" ]]; then
418+
check_psql_exists
411419
run_demo
412420
else
413421
echo -e "${RED}Invalid option. Please try again.${NOCOLOR}"

0 commit comments

Comments
 (0)