Skip to content

Commit

Permalink
[nix] Run set-up-authoritative-keyserver.sh on nix startup
Browse files Browse the repository at this point in the history
Summary:
issue: [[https://linear.app/comm/issue/ENG-6845/multi-keyserver-testing-pt-2 | ENG-6845]]
We want to run set-up-authoritative-keyserver.sh when nix is run.

Test Plan: Ran `nix develop` and checked that the script is executed

Reviewers: michal, tomek, O1 Nix

Reviewed By: michal

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D11310
  • Loading branch information
InkaAlicja committed Mar 13, 2024
1 parent 8d0b522 commit da499cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions nix/dev-shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ mkShell {
# Provide decent bash prompt
source "${better-prompt}/bin/better-prompt"
$PRJ_ROOT/scripts/set-up-authoritative-keyserver.sh
echo "Welcome to Comm dev environment! :)"
'';
}
6 changes: 5 additions & 1 deletion scripts/set-up-authoritative-keyserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PRJ_ROOT="$(git rev-parse --show-toplevel)"
user_credentials_file="$PRJ_ROOT/keyserver/secrets/user_credentials.json"

set_up_or_abort() {
read -r -p "Do you want to set up a new authoritative keyserver? (y/N) " user_input
read -t 60 -r -p "Do you want to set up a new authoritative keyserver? (y/N) " user_input

if [[ $user_input != "Y" && $user_input != "y" ]]; then
exit 1
Expand Down Expand Up @@ -35,6 +35,10 @@ set_up_or_abort() {
node "$PRJ_ROOT"/scripts/set-user-credentials.js "$PRJ_ROOT"
}

if [[ -n "$BUILDKITE" || -n "$GITHUB_ACTIONS" ]]; then
exit
fi

if grep -q '"usingIdentityCredentials":.*true' "$user_credentials_file"; then
if ! (mysql -u "$USER" -Bse "USE comm; SELECT * FROM metadata" 2>/dev/null | grep "db_version">/dev/null); then
echo -e "'usingIdentityCredentials' is set to true, but the database is not set up.\n" \
Expand Down

0 comments on commit da499cc

Please sign in to comment.