6
6
# Coder enterprise features).
7
7
8
8
SCRIPT_DIR=$( dirname " ${BASH_SOURCE[0]} " )
9
- # shellcheck disable=SC1091,SC1090
9
+ # shellcheck source=scripts/lib.sh
10
10
source " ${SCRIPT_DIR} /lib.sh"
11
11
12
12
# Allow toggling verbose output
@@ -62,18 +62,24 @@ CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
62
62
" ${CODER_DEV_SHIM} " server --address 0.0.0.0:3000 || kill -INT -$$ &
63
63
64
64
echo ' == Waiting for Coder to become ready'
65
- timeout 60s bash -c ' until curl -s --fail http://localhost:3000 > /dev/null 2>&1; do sleep 0.5; done'
65
+ timeout 60s bash -c ' until curl -s --fail http://localhost:3000/healthz > /dev/null 2>&1; do sleep 0.5; done'
66
+
67
+ # Check if credentials are already set up to avoid setting up again.
68
+ " ${CODER_DEV_SHIM} " list > /dev/null 2>&1 && touch " ${PROJECT_ROOT} /.coderv2/developsh-did-first-setup"
66
69
67
70
if [ ! -f " ${PROJECT_ROOT} /.coderv2/developsh-did-first-setup" ]; then
68
71
# Try to create the initial admin user.
69
- " ${CODER_DEV_SHIM} " login http://127.0.0.1:3000 --first-user-username=admin --first-user-email=admin@coder.com --first-user-password=" ${password} " ||
72
+ if " ${CODER_DEV_SHIM} " login http://127.0.0.1:3000 --first-user-username=admin --first-user-email=admin@coder.com --first-user-password=" ${password} " ; then
73
+ # Only create this file if an admin user was successfully
74
+ # created, otherwise we won't retry on a later attempt.
75
+ touch " ${PROJECT_ROOT} /.coderv2/developsh-did-first-setup"
76
+ else
70
77
echo ' Failed to create admin user. To troubleshoot, try running this command manually.'
78
+ fi
71
79
72
80
# Try to create a regular user.
73
81
" ${CODER_DEV_SHIM} " users create --email=member@coder.com --username=member --password=" ${password} " ||
74
82
echo ' Failed to create regular user. To troubleshoot, try running this command manually.'
75
-
76
- touch " ${PROJECT_ROOT} /.coderv2/developsh-did-first-setup"
77
83
fi
78
84
79
85
# If we have docker available and the "docker" template doesn't already
@@ -97,14 +103,31 @@ CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
97
103
fi
98
104
99
105
# Start the frontend once we have a template up and running
100
- CODER_HOST=http://127.0.0.1:3000 yarn --cwd=./site dev || kill -INT -$$ &
106
+ CODER_HOST=http://127.0.0.1:3000 yarn --cwd=./site dev --host | {
107
+ while read -r line; do
108
+ echo " [SITE] $( date -Iseconds) : $line "
109
+ done
110
+ } || kill -INT -$$ &
111
+
112
+ interfaces=(localhost)
113
+ if which ip > /dev/null 2>&1 ; then
114
+ # shellcheck disable=SC2207
115
+ interfaces+=($( ip a | awk ' /inet / {print $2}' | cut -d/ -f1) )
116
+ elif which ifconfig > /dev/null 2>&1 ; then
117
+ # shellcheck disable=SC2207
118
+ interfaces+=($( ifconfig | awk ' /inet / {print $2}' ) )
119
+ fi
101
120
102
121
log
103
122
log " ===================================================================="
104
123
log " == =="
105
124
log " == Coder is now running in development mode. =="
106
- log " == API: http://localhost:3000 =="
107
- log " == Web UI: http://localhost:8080 =="
125
+ for iface in " ${interfaces[@]} " ; do
126
+ log " $( printf " == API: http://%s:3000%$(( 26 - ${# iface} )) s==" " $iface " " " ) "
127
+ done
128
+ for iface in " ${interfaces[@]} " ; do
129
+ log " $( printf " == Web UI: http://%s:8080%$(( 26 - ${# iface} )) s==" " $iface " " " ) "
130
+ done
108
131
log " == =="
109
132
log " == Use ./scripts/coder-dev.sh to talk to this instance! =="
110
133
log " ===================================================================="
0 commit comments