-
Notifications
You must be signed in to change notification settings - Fork 12
/
get_service_host_ip.sh
executable file
·42 lines (41 loc) · 1.23 KB
/
get_service_host_ip.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
#!/bin/bash
# revised 2021-09-27
# maintainer: herman.tolentino@gmail.com
# --------------------------------------
# purpose: obtain JupyterHub Service Host
# IP Address and update the
# JUPYTERHUB_SERVICE_HOST_IP
# value in the .env file
# --------------------------------------
FILE='/tmp/jupyterhub_host_ip'
if [ -f $FILE ]; then
rm $FILE
else
touch $FILE
fi
unset JUPYTERHUB_SERVICE_HOST_IP
echo "JUPYTERHUB_SSL = $JUPYTERHUB_SSL"
case $JUPYTERHUB_SSL in
no_ssl)
echo "Starting up JupyterHub..."
docker-compose up -d
;;
use_ssl_ss)
echo "Starting up JupyterHub..."
docker-compose up -d
;;
use_ssl_le)
echo "Starting up JupyterHub-LetsEncrypt..."
docker-compose -f docker-compose-letsencrypt.yml up -d
;;
esac
docker inspect --format "{{ .NetworkSettings.Networks.jupyterhubnet.IPAddress }}" jupyterhub >> /tmp/jupyterhub_host_ip
bash ./stophub.sh
echo 'Set Jupyterhub Host IP:'
REPLACE_LINE="JUPYTERHUB_SERVICE_HOST_IP=`cat /tmp/jupyterhub_host_ip`"
echo "$REPLACE_LINE"
sed "s#.*JUPYTERHUB_SERVICE_HOST_IP.*#$REPLACE_LINE#g" .env > /tmp/envfile
cat /tmp/envfile > .env
rm /tmp/envfile
echo "Starting up JupyterHub"
bash ./starthub.sh