-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.sh
224 lines (177 loc) · 6.26 KB
/
env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
if ! ( [ -e env.sh ] && [ -e VERSION ] ); then
echo "Doesn't look like you are in the root directory. Source this from the config directory."
CONFIG_FAILED=yes
else
function source-env () {
if ! [ -d $1 ]; then
echo "$1 doesn't exist"
return 1
fi
if [ -e $1/env.sh ]; then
#[ "$BE_QUIET." = "." ] && echo "sourcing $1/env.sh"
pushd $1 > /dev/null
. ./env.sh
popd > /dev/null
fi
return 0
}
function up-to-date() {
if [ "$1." = "." ]; then
D=$PWD
else
D=$1
fi
RED="\e[101m"
NC="\e[0m"
pushd $D > /dev/null
if ! git diff --exit-code --stat 2>&1 >/dev/null ; then echo -e "${RED}You have uncommitted changes in $D $NC"; return 1;fi
git remote update > /dev/null
if ! git status -uno| grep -q 'Your branch is up.to.date with'; then echo -e "${RED}$D is not up-to-date with upstream $NC";return 1; fi
popd
}
export CSE142L_ROOT=$PWD
export COURSE_NAME=CSE142L
export COURSE_INSTANCE=wi24
export GITHUB_CLASSROOM_ORG=CSE142
export NB_RELEASE_INCLUDES=$CSE142L_ROOT/labs/CSE141pp-Lab-Common
export HTTP_ROOT_REPO=https://github.com/NVSL/CSE141pp-Root.git
export ROOT_REPO_BRANCH=main
export HTTP_ARCHLAB_REPO=https://github.com/NVSL/cse141pp-archlab.git
export ARCHLAB_REPO_BRANCH=master
export CLOUD_NAMESPACE=default
export DOCKER_ORG=stevenjswanson
export DJR_SERVER=https://cse142l-dev.wl.r.appspot.com
export JUPYTER_CONFIG_DIR=$CSE142L_ROOT/jupyter_config
VERSION=$(cat $CSE142L_ROOT/VERSION)
[ ".$REAL_USER" = "." ] && REAL_USER=$USER
export DOCKER_IMAGE_VERSION=v$VERSION
if [ ".$DEPLOYMENT" = ".yes" ]; then
export DOCKER_IMAGE_INFIX=
else
DOCKER_IMAGE_INFIX=${DOCKER_IMAGE_INFIX:--$REAL_USER}
export DOCKER_IMAGE_INFIX
fi
#export DOCKER_IMAGE_VERSION=s21-dev
export DOCKER_CORE_IMAGE=$DOCKER_ORG/cse142l$DOCKER_IMAGE_INFIX-core:$DOCKER_IMAGE_VERSION
export DOCKER_DEVEL_IMAGE=$DOCKER_ORG/cse142l$DOCKER_IMAGE_INFIX-dev:$DOCKER_IMAGE_VERSION
export DOCKER_DEVEL_IMAGE_LATEST=$DOCKER_ORG/cse142l$DOCKER_IMAGE_INFIX-dev:latest
export DOCKER_RUNNER_IMAGE=$DOCKER_ORG/cse142l$DOCKER_IMAGE_INFIX-runner:$DOCKER_IMAGE_VERSION
export DOCKER_BASE_IMAGE=$DOCKER_ORG/cse142l$DOCKER_IMAGE_INFIX-base:$DOCKER_IMAGE_VERSION
export DOCKER_SERVICE_IMAGE=$DOCKER_ORG/cse142l$DOCKER_IMAGE_INFIX-service:$DOCKER_IMAGE_VERSION
export DOCKER_DSMLP_IMAGE=$DOCKER_ORG/cse142l$DOCKER_IMAGE_INFIX-service-dsmlp:$DOCKER_IMAGE_VERSION
#DOCKER_USER_IMAGE=$DOCKER_ORG/cse142l-user:$DOCKER_IMAGE_VERSION
export DJR_JOB_TYPE=CSE142L.CSE142LJob.CSE142LJob
export CSE142L_RUNNER_DOCKER_IMAGE=stevenjswanson/cse142l-runner:latest
export DJR_CLUSTER=djr-default-cluster
export EMULATION_DIR=/tmp/emulation
export CLOUD_MODE=CLOUD
export DJR_DOCKER_SCRATCH=/tmp/djr_scratch
export GOOGLE_CLOUD_PROJECT=cse142l-dev
export LABS="intro-bench compiler-bench caches-bench caches2-bench parallel-bench"
export SECRETS_DIRECTORY=$CSE142L_ROOT/CSE141pp-Config/secrets
export PACKET_PROJECT_ID=1a5e2c60-b31f-49f9-85a1-84b4c5d8033f
export DOCKER_USERNAME=stevenjswanson
if [ -d $SECRETS_DIRECTORY ]; then
export DOCKER_ACCESS_TOKEN=$(cat $SECRETS_DIRECTORY/docker_hub_token)
fi
export GOOGLE_CREDENTIALS_FILE=cse142l-dev-c775b40fa9bf.json
export GOOGLE_APPLICATION_CREDENTIALS=$SECRETS_DIRECTORY/$GOOGLE_CREDENTIALS_FILE
if [ -d $SECRETS_DIRECTORY ]; then
export GITHUB_OAUTH_TOKEN=$(cat $SECRETS_DIRECTORY/git_oauth_token)
export CSE142L_KEY=$(cat $SECRETS_DIRECTORY/lab_encryption_key)
fi
export ALLOWED_GOOGLE_DOMAINS="ucsd.edu,eng.ucsd.edu"
export MONETA_ROOT=$CSE142L_ROOT/CSE141pp-Tool-Moneta
export CANELA_ROOT=$CSE142L_ROOT/CSE141pp-SimpleCNN
export PIN_ROOT=$CSE142L_ROOT/CSE141pp-Tool-Moneta-Pin/
export PATH=$CSE142L_ROOT/bin:/opt/conda/bin/:/usr/local/bin:$PATH
#CLOUD_MODE
#DJR_SERVER
#DJR_CLUSTER=djr-default-cluster
export SUBDIRS="cse141pp-archlab CSE141pp-LabPython CSE141pp-DJR CSE141pp-Tool-Moneta CSE141pp-SimpleCNN CSE141pp-Tool-Moneta-Pin cfiddle"
for d in $SUBDIRS; do
source-env $d
done
source-env shim
# this checks if we are in an interactive shell.
# no idea how it works.
function bump-version() {
pushd $CSE142L_ROOT > /dev/null
branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch." != "main." ]; then
echo "Only bump main branch"
return 1
fi
t=$(cat VERSION)
echo $[t + 1] > VERSION
git add VERSION
git commit -m "new-version"
git push
echo "New version is $(cat VERSION)"
reconfig
popd > /dev/null
}
function reconfig () {
__HERE=$PWD
cd $CSE142L_ROOT
. env.sh
cd $__HERE
}
function deployed() {
export DEPLOYMENT=yes
reconfig
}
if [[ $- == *i* ]]; then
function notdeployed() {
undef DEPLOYED
reconfig
}
function ssh-login () {
if ! [ -e $HOME/.ssh/ ]; then
echo "$HOME/.ssh doesn't exist, so I'm not setting up an ssh-agent for you. You'll need to type your password to clone each repo."
return 1
fi
if [ "$SSH_AUTH_SOCK." == "." ] || [ "$1." == "-f." ]; then
eval `ssh-agent`
else
echo Agent is already running socket = $SSH_AUTH_SOCK. Not starting.
fi
if [ $(ssh-add -l | grep -v "The agent has no identities" | wc -l) = 0 ]; then
ssh-add
else
echo It already has an identity loaded. Not adding.
fi
}
function whereami () {
for i in DJR_CLUSTER THIS_DOCKER_IMAGE THIS_DOCKER_CONTAINER THIS_DOCKER_IMAGE_UUID WORK_OUTSIDE_OF_DOCKER REAL_IP_ADDR; do
echo $i=$(eval "echo \$$i")
done
}
function prompter() {
if git rev-parse --abbrev-ref HEAD 2> /dev/null > /dev/null; then
GIT=[$(git rev-parse --abbrev-ref HEAD)]
else
GIT=
fi
if [ ".$REAL_HOSTNAME" != "." ]; then
R_HOST="($REAL_HOSTNAME)"
else
R_HOST=
fi
PS1="\h$R_HOST:\w $DEPLOYED_TEXT$MISMATCH$GIT\$ "
}
PROMPT_COMMAND=prompter
# if [ ".$THUNK_TO_HOME" = ".yes" ]; then # this is for students using the
# # runner image. We source the
# # this file and then take them
# # home.
# echo Changing to $HOME
# cd $HOME
# unset THUNK_TO_HOME
# else
# echo Not thunking
# fi
whereami
ssh-login
fi
fi