From d2379ef331c044da9d2037982542f81f96fcb459 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Tue, 25 Jan 2022 04:24:29 +0000 Subject: [PATCH 1/4] refactor: Helper script to add a user --- scripts/create_initial_user.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 scripts/create_initial_user.sh diff --git a/scripts/create_initial_user.sh b/scripts/create_initial_user.sh new file mode 100755 index 0000000000000..b3d80e85e911a --- /dev/null +++ b/scripts/create_initial_user.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -euo pipefail + +EMAIL="${EMAIL:-admin@coder.com}" +USERNAME="${USERNAME:-admin}" +ORGANIZATION="${ORGANIZATION:-default}" +PASSWORD="${PASSWORD:-p@ssword1}" + +curl -X POST \ +-d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \ +-H 'Content-Type:application/json' \ +http://localhost:3000/api/v2/users \ No newline at end of file From df6601ad3b29fd101bcf5751c0f3a0d4ad63da2c Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Tue, 25 Jan 2022 16:42:33 +0000 Subject: [PATCH 2/4] Move user creation to develop script --- develop.sh | 16 ---------------- scripts/create_initial_user.sh | 4 ++-- 2 files changed, 2 insertions(+), 18 deletions(-) delete mode 100755 develop.sh diff --git a/develop.sh b/develop.sh deleted file mode 100755 index ec2a89c5a6dd3..0000000000000 --- a/develop.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -PROJECT_ROOT="$(git rev-parse --show-toplevel)" -cd "${PROJECT_ROOT}" - -# Do initial build - a dev build for coderd. -# It's OK that we don't build the front-end before - because the front-end -# assets are handled by the `yarn dev` devserver. -make bin/coderd - -# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly -# to kill both at the same time. For more details, see: -# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script -(trap 'kill 0' SIGINT; CODERV2_HOST=http://127.0.0.1:3000 yarn dev & ./bin/coderd) \ No newline at end of file diff --git a/scripts/create_initial_user.sh b/scripts/create_initial_user.sh index b3d80e85e911a..c2bd182c287dd 100755 --- a/scripts/create_initial_user.sh +++ b/scripts/create_initial_user.sh @@ -4,8 +4,8 @@ set -euo pipefail EMAIL="${EMAIL:-admin@coder.com}" USERNAME="${USERNAME:-admin}" -ORGANIZATION="${ORGANIZATION:-default}" -PASSWORD="${PASSWORD:-p@ssword1}" +ORGANIZATION="${ORGANIZATION:-ACME-Corp}" +PASSWORD="${PASSWORD:-password}" curl -X POST \ -d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \ From a5427bb93103e934ab174e18a40803f527123a4c Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Tue, 25 Jan 2022 16:47:42 +0000 Subject: [PATCH 3/4] Fix script --- develop.sh | 32 ++++++++++++++++++++++++++++++++ scripts/create_initial_user.sh | 13 ------------- 2 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 develop.sh delete mode 100755 scripts/create_initial_user.sh diff --git a/develop.sh b/develop.sh new file mode 100644 index 0000000000000..689b92ebbcdc4 --- /dev/null +++ b/develop.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -euo pipefail + +EMAIL="${EMAIL:-admin@coder.com}" +USERNAME="${USERNAME:-admin}" +ORGANIZATION="${ORGANIZATION:-ACME-Corp}" +PASSWORD="${PASSWORD:-password}" +PROJECT_ROOT="$(git rev-parse --show-toplevel)" +cd "${PROJECT_ROOT}" + +# Helper to create an initial user +function create_initial_user() { + # TODO: We need to wait for `coderd` to spin up - + # need to replace with a deterministic strategy + sleep 5s + + curl -X POST \ + -d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \ + -H 'Content-Type:application/json' \ + http://localhost:3000/api/v2/users +} + +# Do initial build - a dev build for coderd. +# It's OK that we don't build the front-end before - because the front-end +# assets are handled by the `yarn dev` devserver. +make bin/coderd + +# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly +# to kill both at the same time. For more details, see: +# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script +(trap 'kill 0' SIGINT; create_initial_user & CODERV2_HOST=http://127.0.0.1:3000 yarn dev & ./bin/coderd) \ No newline at end of file diff --git a/scripts/create_initial_user.sh b/scripts/create_initial_user.sh deleted file mode 100755 index c2bd182c287dd..0000000000000 --- a/scripts/create_initial_user.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -EMAIL="${EMAIL:-admin@coder.com}" -USERNAME="${USERNAME:-admin}" -ORGANIZATION="${ORGANIZATION:-ACME-Corp}" -PASSWORD="${PASSWORD:-password}" - -curl -X POST \ --d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \ --H 'Content-Type:application/json' \ -http://localhost:3000/api/v2/users \ No newline at end of file From d62fc8a921983b70727aaa80e136a4b68712980c Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Tue, 25 Jan 2022 16:48:41 +0000 Subject: [PATCH 4/4] Set executable bit --- develop.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 develop.sh diff --git a/develop.sh b/develop.sh old mode 100644 new mode 100755