flagflag  
2: 2021-07-03 (Sat) 18:59:47 iseki source Cur: 2021-07-13 (Tue) 20:06:59 iseki source
Line 3: Line 3:
 # Copyright (c) Jupyter Development Team.  # Copyright (c) Jupyter Development Team.
 # Distributed under the terms of the Modified BSD License.  # Distributed under the terms of the Modified BSD License.
 + 
 set -e  set -e
 + 
 # Exec the specified command or fall back on bash  # Exec the specified command or fall back on bash
 if [ $# -eq 0 ]; then  if [ $# -eq 0 ]; then
Line 12: Line 12:
     cmd=( "$@" )      cmd=( "$@" )
 fi  fi
 + 
 run-hooks () {  run-hooks () {
     # Source scripts or run executable files in a directory      # Source scripts or run executable files in a directory
Line 37: Line 37:
     echo "$0: done running hooks in $1"      echo "$0: done running hooks in $1"
 }  }
 + 
 run-hooks /usr/local/bin/start-notebook.d  run-hooks /usr/local/bin/start-notebook.d
 + 
 # Handle special flags if we're root  # Handle special flags if we're root
 if [ $(id -u) == 0 ] ; then  if [ $(id -u) == 0 ] ; then
 + 
     # Only attempt to change the jovyan username if it exists      # Only attempt to change the jovyan username if it exists
     if id jovyan &> /dev/null ; then      if id jovyan &> /dev/null ; then
Line 48: Line 48:
         usermod -d /home/$NB_USER -l $NB_USER jovyan          usermod -d /home/$NB_USER -l $NB_USER jovyan
     fi      fi
 + 
     # Handle case where provisioned storage does not have the correct permissions by default      # Handle case where provisioned storage does not have the correct permissions by default
     # Ex: default NFS/EFS (no auto-uid/gid)      # Ex: default NFS/EFS (no auto-uid/gid)
Line 61: Line 61:
         done          done
     fi      fi
 + 
     # handle home and working directory if the username changed      # handle home and working directory if the username changed
     if [[ "$NB_USER" != "jovyan" ]]; then      if [[ "$NB_USER" != "jovyan" ]]; then
Line 77: Line 77:
         fi          fi
     fi      fi
 + 
     # Change UID:GID of NB_USER to NB_UID:NB_GID if it does not match      # Change UID:GID of NB_USER to NB_UID:NB_GID if it does not match
     if [ "$NB_UID" != $(id -u $NB_USER) ] || [ "$NB_GID" != $(id -g $NB_USER) ]; then      if [ "$NB_UID" != $(id -u $NB_USER) ] || [ "$NB_GID" != $(id -g $NB_USER) ]; then
Line 87: Line 87:
         useradd --home /home/$NB_USER -u $NB_UID -g $NB_GID -G 100 -l $NB_USER          useradd --home /home/$NB_USER -u $NB_UID -g $NB_GID -G 100 -l $NB_USER
     fi      fi
 + 
     # Enable sudo if requested      # Enable sudo if requested
     if [[ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]]; then      if [[ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]]; then
Line 93: Line 93:
         echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook          echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook
     fi      fi
 + 
     # Add $CONDA_DIR/bin to sudo secure_path      # Add $CONDA_DIR/bin to sudo secure_path
     sed -r "s#Defaults\s+secure_path\s*=\s*\"?([^\"]+)\"?#Defaults secure_path=\"\1:$CONDA_DIR/bin\"#" /etc/sudoers | grep secure_path > /etc/sudoers.d/path      sed -r "s#Defaults\s+secure_path\s*=\s*\"?([^\"]+)\"?#Defaults secure_path=\"\1:$CONDA_DIR/bin\"#" /etc/sudoers | grep secure_path > /etc/sudoers.d/path
 + 
     # Exec the command as NB_USER with the PATH and the rest of      # Exec the command as NB_USER with the PATH and the rest of
     # the environment preserved      # the environment preserved
Line 120: Line 120:
             fi              fi
         fi          fi
 + 
         # Warn if the user isn't going to be able to write files to $HOME.          # Warn if the user isn't going to be able to write files to $HOME.
         if [[ ! -w /home/jovyan ]]; then          if [[ ! -w /home/jovyan ]]; then
Line 135: Line 135:
         fi          fi
     fi      fi
 + 
     # Warn if looks like user want to run in sudo mode but hasn't run      # Warn if looks like user want to run in sudo mode but hasn't run
     # the container as root.      # the container as root.
Line 141: Line 141:
         echo 'Container must be run as root to grant sudo permissions'          echo 'Container must be run as root to grant sudo permissions'
     fi      fi
 + 
     # Execute the command      # Execute the command
     run-hooks /usr/local/bin/before-notebook.d      run-hooks /usr/local/bin/before-notebook.d


Front page   New List of Pages Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom)

Site Search

Login

Username:

Password:


Lost Password?
Register now!!

Sub Menu

mini Calendar

Last MonthJul 2025Next Month
Su Mo Tu We Th Fr Sa
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
Today

Who's Online

62 user(s) are online (12 user(s) are browsing xpwiki)

Members: 0
Guests: 62

more...

Access Counter

Today : 9124912491249124
Yesterday : 1013210132101321013210132
Total : 2753481927534819275348192753481927534819275348192753481927534819
Powered by XOOPS Cube 2.1© 2001-2006 XOOPS Cube Project
Design by XoopsDesign.com