代码拉取完成,页面将自动刷新
#!/bin/bash
# modified 2021-09-27
# author Herman Tolentino
if [[ ! -f .env ]]; then
echo "Copying environment template..."
cp .env-template .env
fi
source .env
# manage PostGreSQL data volume
if [[ $POSTGRES_DELETE_DB == 1 ]]; then
echo "Creating PostgreSQL data volumes..."
docker volume rm $DB_VOLUME_HOST
docker volume create $DB_VOLUME_HOST
fi
# generate PostGreSQL password and proxy token
# update .env with values
if [[ ! -f secrets/pg_pass ]]; then
echo "Generating PostGreSQL password..."
./pg_pass.sh
fi
if [[ ! -f secrets/proxy_token ]]; then
echo "Generating JupyterHub proxy token..."
./proxy_token.sh
fi
if [[ ! -f userlist ]]; then
echo "Copying userlist template..."
cp userlist-template userlist
fi
# download miniconda to copy into Docker.jupyterhub
if [[ ! -f ./miniconda.sh ]]; then
echo "Downloading miniconda..."
MINICONDA_FILE=https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
while true;do
wget -T 15 -c $MINICONDA_FILE -O ./miniconda.sh && break
done
fi
./stophub.sh
if [[ $DOCKER_BUILD_CACHE_OPTION == '--no-cache' ]]; then
if [[ "$(docker images -q jupyterhub:latest)" == "" ]]; then
echo "JupyterHub image does not exist."
else
echo "Deleting JupyterHub Docker image..."
docker rmi $(docker images -a | grep jupyterhub | awk '{print $3}')
fi
fi
# get images for base notebooks for Dockerfile.custom and Dockerfile.stacks
# uncommend other jupyter notebook containers below as needed
if [[ "$(docker images -q jupyter/minimal-notebook)" == "" ]]; then
echo "Pulling jupyter stacks image..."
docker pull jupyter/minimal-notebook:$IMAGE_TAG
fi
if [[ "$(docker images -q jrcs/letsencrypt-nginx-proxy-companion)" == "" ]]; then
echo "Pulling LetsEncrypt image..."
docker pull jrcs/letsencrypt-nginx-proxy-companion
fi
echo "Creating network and data volumes..."
make network
make volumes
docker volume create --name=nginx_vhostd
docker volume create --name=nginx_html
./create-network.sh
echo "JUPYTERHUB_SSL = $JUPYTERHUB_SSL"
case $JUPYTERHUB_SSL in
use_ssl_ss)
echo "Creating SSL certificate..."
./create-certs.sh
;;
use_ssl_le)
# make letsencrypt server apps executable
echo "Making LetsEncrypt apps executable..."
chmod a+x server_apps/letsencrypt/app/cert_status
chmod a+x server_apps/letsencrypt/app/entrypoint.sh
chmod a+x server_apps/letsencrypt/app/force_renew
chmod a+x server_apps/letsencrypt/app/functions.sh
chmod a+x server_apps/letsencrypt/app/letsencrypt_service
chmod a+x server_apps/letsencrypt/app/signal_le_service
chmod a+x server_apps/letsencrypt/app/start.sh
;;
esac
echo "Building Docker images..."
echo "JUPYTERHUB_SSL = $JUPYTERHUB_SSL"
case $JUPYTERHUB_SSL in
no_ssl)
echo "Shutting down JupyterHub..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose -f docker-compose.yml down
;;
use_ssl_ss)
echo "Shutting down JupyterHub..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose -f docker-compose.yml down
;;
use_ssl_le)
echo "Shutting down JupyterHub-LetsEncrypt..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose -f docker-compose-letsencrypt.yml down
;;
esac
# Get jupyterhub host IP address
echo "Obtaining JupyterHub host ip address..."
FILE1='/tmp/jupyterhub_host_ip'
if [ -f $FILE1 ]; then
rm $FILE1
else
touch $FILE1
fi
unset JUPYTERHUB_SERVICE_HOST_IP
echo "JUPYTERHUB_SSL = $JUPYTERHUB_SSL"
case $JUPYTERHUB_SSL in
no_ssl)
echo "Starting up JupyterHub..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose up -d
;;
use_ssl_ss)
echo "Starting up JupyterHub..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose up -d
;;
use_ssl_le)
echo "Starting up JupyterHub-LetsEncrypt..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose -f docker-compose-letsencrypt.yml up -d
sleep 10
;;
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
if [[ ! "$(docker ps -a | grep jupyter-)" ]]; then
echo "Removing running notebook servers..."
docker stop $(docker ps -a | grep jupyter- | awk '{print $1}')
docker rm $(docker ps -a | grep jupyter- | awk '{print $1}')
fi
#docker rmi $(docker images -q jupyterhub:latest)
#docker rmi $(docker images -q postgres-hub:latest)
#docker rmi -f $(docker images -q jupyterhub-user:latest)
if [ ! -f 'singleuser/drive.jupyterlab-settings' ]; then
echo "Copying Google drive JupyterLab settings template..."
cp singleuser/drive.jupyterlab-settings-template singleuser/drive.jupyterlab-settings
fi
echo "Rebuilding JupyterHub and Single-user Docker images..."
echo "JUPYTERHUB_SSL = $JUPYTERHUB_SSL"
case $JUPYTERHUB_SSL in
no_ssl)
echo "Rebuilding JupyterHub..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose -f docker-compose.yml $DOCKER_BUILD_CACHE_OPTION build
;;
use_ssl_ss)
echo "Rebuilding JupyterHub..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose -f docker-compose.yml $DOCKER_BUILD_CACHE_OPTION build
;;
use_ssl_le)
echo "Rebuilding JupyterHub-LetsEncrypt..."
COMPOSE_DOCKER_CLI_BUILD=$COMPOSE_DOCKER_CLI_BUILD docker-compose -f docker-compose-letsencrypt.yml $DOCKER_BUILD_CACHE_OPTION build
;;
esac
echo "Building notebook image..."
make notebook_base
make notebook_body
make notebook_image
#make notebook_packed
rc=$?
if [[ $rc -ne 0 ]]; then
echo "Error was: $rc" >> errorlog.txt
else
if [ -f .env-e ]; then
rm .env-e
fi
echo "Build complete!"
echo "Run starthub.sh from the command line..."
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。