Spaces:
Runtime error
Runtime error
| set -eo pipefail | |
| set -x | |
| # Generate htdigest password file for webdav access if it doesn't exist. | |
| JUPYTER_ENABLE_WEBDAV=${JUPYTER_ENABLE_WEBDAV:-false} | |
| export HUB_HOME=/tmp | |
| export JUPYTER_ENABLE_WEBDAV | |
| if [ -f /var/run/secrets/kubernetes.io/serviceaccount/namespace ]; then | |
| DEPLOYMENT=`echo $HOSTNAME | sed -e 's/^\(.*\)-[^-]*-[^-]*$/\1/'` | |
| NAMESPACE=`cat /var/run/secrets/kubernetes.io/serviceaccount/namespace` | |
| WEBDAV_REALM=$NAMESPACE/$DEPLOYMENT | |
| else | |
| WEBDAV_REALM=jupyter-on-openshift/jupyter-notebooks | |
| fi | |
| WEBDAV_USERFILE=/opt/app-root/etc/webdav.htdigest | |
| export WEBDAV_REALM | |
| export WEBDAV_USERFILE | |
| if [ ! -f $WEBDAV_USERFILE ]; then | |
| touch $WEBDAV_USERFILE | |
| if [[ ! -z "${JUPYTER_NOTEBOOK_PASSWORD}" ]]; then | |
| DIGEST="$( printf "%s:%s:%s" "jupyter" "$WEBDAV_REALM" "$JUPYTER_NOTEBOOK_PASSWORD" | md5sum | awk '{print $1}' )" | |
| printf "%s:%s:%s\n" "jupyter" "$WEBDAV_REALM" "$DIGEST" >> $WEBDAV_USERFILE | |
| fi | |
| fi | |
| # Pre-clone repositories defined in JUPYTER_PRELOAD_REPOS | |
| if [ -n "${JUPYTER_PRELOAD_REPOS}" ]; then | |
| for repo in `echo ${JUPYTER_PRELOAD_REPOS} | tr ',' ' '`; do | |
| # Check for the presence of "@branch" in the repo string | |
| REPO_BRANCH=$(echo ${repo} | cut -s -d'@' -f2) | |
| if [[ -n ${REPO_BRANCH} ]]; then | |
| # Remove the branch from the repo string and convert REPO_BRANCH to git clone arg | |
| repo=$(echo ${repo} | cut -d'@' -f1) | |
| REPO_BRANCH="-b ${REPO_BRANCH}" | |
| fi | |
| echo "Checking if repository $repo exists locally" | |
| REPO_DIR=$(basename ${repo}) | |
| if ! [ -d "${REPO_DIR}" ]; then | |
| GIT_SSL_NO_VERIFY=true git clone ${repo} ${REPO_DIR} ${REPO_BRANCH} | |
| fi | |
| done | |
| fi | |
| # Copy notebooks onto the user volume if they don't exist | |
| if [ -d /opt/app-root/notebooks ] && ! [ -d /opt/app-root/src/openvino_notebooks ]; then | |
| cp -r /opt/app-root/notebooks /opt/app-root/src/openvino_notebooks | |
| fi | |
| # Start the Jupyter notebook instance. Run using supervisord if enabled, | |
| # or it is required by webdav access. | |
| if [ x"$JUPYTER_ENABLE_WEBDAV" == x"true" ]; then | |
| JUPYTER_ENABLE_SUPERVISORD=true | |
| fi | |
| if [[ ! -z "${JUPYTER_ENABLE_SUPERVISORD}" ]]; then | |
| # Startup supervisord against the configuration and keep it in the | |
| # foreground so becomes process ID 1 for the container. | |
| exec /opt/app-root/bin/supervisord --nodaemon \ | |
| --configuration /opt/app-root/etc/supervisord.conf | |
| else | |
| . /opt/app-root/bin/start-notebook.sh "$@" | |
| fi | |