forked from darribas/gds_env
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgettoken.sh
More file actions
30 lines (25 loc) · 827 Bytes
/
gettoken.sh
File metadata and controls
30 lines (25 loc) · 827 Bytes
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
#! /bin/bash -e
printf "Running gettoken file\n"
# Capture existing containers
CID=$(docker ps -aq)
# Check if we have any
if [ -z "$CID" ]
then
# If not, that's fine but we can say so
printf "No running docker containers...\n"
else
# we've found some
printf "Looking for tokens on running containers...\n"
# Parse the container IDs into an array --
# although unlikely, it's possible more than
# one is running.
IFS=$'\n' CIDS=($CID)
for i in "${CIDS[@]}"
do
printf "Container id: $i\n"
echo $(docker exec -i $i jupyter notebook list)
TOKEN=$(echo $(docker exec -i $i sh -c "jupyter notebook list") | sed -nE 's/.*=([0-9A-Fa-f]+).*/\\1/p')
printf "\thas token ${TOKEN}\n"
done
fi
printf "Done.\n"