From c0ae562059fef7eea156850b5633c44ef3e1d2d8 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Fri, 21 May 2021 15:49:49 +0300 Subject: [PATCH] Fix all shellcheck warnings --- base-notebook/start-notebook.sh | 2 ++ base-notebook/start-singleuser.sh | 4 +++- base-notebook/start.sh | 11 ++++++----- examples/docker-compose/bin/letsencrypt.sh | 4 ++-- examples/docker-compose/bin/vbox.sh | 4 ++-- examples/docker-compose/notebook/build.sh | 1 + examples/docker-compose/notebook/down.sh | 1 + examples/docker-compose/notebook/env.sh | 2 +- examples/docker-compose/notebook/up.sh | 1 + 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/base-notebook/start-notebook.sh b/base-notebook/start-notebook.sh index ac26a4a8..60c23092 100755 --- a/base-notebook/start-notebook.sh +++ b/base-notebook/start-notebook.sh @@ -13,8 +13,10 @@ if [[ -n "${JUPYTERHUB_API_TOKEN}" ]]; then # launched by JupyterHub, use single-user entrypoint exec /usr/local/bin/start-singleuser.sh "$@" elif [[ -n "${JUPYTER_ENABLE_LAB}" ]]; then + # shellcheck disable=SC1091 . /usr/local/bin/start.sh $wrapper jupyter lab "$@" else echo "WARN: Jupyter Notebook deprecation notice https://github.com/jupyter/docker-stacks#jupyter-notebook-deprecation-notice." + # shellcheck disable=SC1091 . /usr/local/bin/start.sh $wrapper jupyter notebook "$@" fi diff --git a/base-notebook/start-singleuser.sh b/base-notebook/start-singleuser.sh index d184272f..c94dfe11 100755 --- a/base-notebook/start-singleuser.sh +++ b/base-notebook/start-singleuser.sh @@ -5,7 +5,7 @@ set -e # set default ip to 0.0.0.0 -if [[ "$NOTEBOOK_ARGS $@" != *"--ip="* ]]; then +if [[ "$NOTEBOOK_ARGS $*" != *"--ip="* ]]; then NOTEBOOK_ARGS="--ip=0.0.0.0 $NOTEBOOK_ARGS" fi @@ -14,6 +14,7 @@ fi # These won't be passed from DockerSpawner 0.9, # so avoid specifying --arg=empty-string if [ -n "$NOTEBOOK_DIR" ]; then + # shellcheck disable=SC2089 NOTEBOOK_ARGS="--notebook-dir='$NOTEBOOK_DIR' $NOTEBOOK_ARGS" fi if [ -n "$JPY_PORT" ]; then @@ -36,4 +37,5 @@ if [ -n "$JPY_HUB_API_URL" ]; then fi NOTEBOOK_BIN="jupyterhub-singleuser" +# shellcheck disable=SC1091,SC2086,SC2090 . /usr/local/bin/start.sh "$NOTEBOOK_BIN" $NOTEBOOK_ARGS "$@" diff --git a/base-notebook/start.sh b/base-notebook/start.sh index 81ba3e6f..229fd779 100755 --- a/base-notebook/start.sh +++ b/base-notebook/start.sh @@ -21,6 +21,7 @@ run-hooks () { case "$f" in *.sh) echo "$0: running $f" + # shellcheck disable=SC1090 source "$f" ;; *) @@ -98,7 +99,7 @@ if [ "$(id -u)" == 0 ] ; then # Exec the command as NB_USER with the PATH and the rest of # the environment preserved run-hooks /usr/local/bin/before-notebook.d - echo "Executing the command: ${cmd[@]}" + echo "Executing the command: " "${cmd[@]}" exec sudo -E -H -u "$NB_USER" PATH="$PATH" XDG_CACHE_HOME="/home/$NB_USER/.cache" PYTHONPATH="${PYTHONPATH:-}" "${cmd[@]}" else if [[ "$NB_UID" == "$(id -u jovyan 2>/dev/null)" && "$NB_GID" == "$(id -g jovyan 2>/dev/null)" ]]; then @@ -110,7 +111,7 @@ else if [[ "$STATUS" != "0" ]]; then if [[ -w /etc/passwd ]]; then echo "Adding passwd file entry for $(id -u)" - cat /etc/passwd | sed -e "s/^jovyan:/nayvoj:/" > /tmp/passwd + sed -e "s/^jovyan:/nayvoj:/" /etc/passwd > /tmp/passwd echo "jovyan:x:$(id -u):$(id -g):,,,:/home/jovyan:/bin/bash" >> /tmp/passwd cat /tmp/passwd > /etc/passwd rm /tmp/passwd @@ -127,10 +128,10 @@ else # Warn if looks like user want to override uid/gid but hasn't # run the container as root. if [[ -n "$NB_UID" && "$NB_UID" != "$(id -u)" ]]; then - echo 'Container must be run as root to set $NB_UID' + echo "Container must be run as root to set NB_UID to $NB_UID" fi if [[ -n "$NB_GID" && "$NB_GID" != "$(id -g)" ]]; then - echo 'Container must be run as root to set $NB_GID' + echo "Container must be run as root to set NB_GID to $NB_GID" fi fi @@ -142,6 +143,6 @@ else # Execute the command run-hooks /usr/local/bin/before-notebook.d - echo "Executing the command: ${cmd[@]}" + echo "Executing the command: " "${cmd[@]}" exec "${cmd[@]}" fi diff --git a/examples/docker-compose/bin/letsencrypt.sh b/examples/docker-compose/bin/letsencrypt.sh index fed48344..f7991f25 100755 --- a/examples/docker-compose/bin/letsencrypt.sh +++ b/examples/docker-compose/bin/letsencrypt.sh @@ -18,10 +18,10 @@ set -e # letsencrypt certificate server type (default is production). # Set `CERT_SERVER=--staging` for staging. -: ${CERT_SERVER=''} +: "${CERT_SERVER=''}" # Create Docker volume to contain the cert -: ${SECRETS_VOLUME:=my-notebook-secrets} +: "${SECRETS_VOLUME:=my-notebook-secrets}" docker volume create --name $SECRETS_VOLUME 1>/dev/null # Generate the cert and save it to the Docker volume docker run --rm -it \ diff --git a/examples/docker-compose/bin/vbox.sh b/examples/docker-compose/bin/vbox.sh index 8dfdc721..38597193 100755 --- a/examples/docker-compose/bin/vbox.sh +++ b/examples/docker-compose/bin/vbox.sh @@ -3,9 +3,9 @@ # Distributed under the terms of the Modified BSD License. # Set reasonable default VM settings -: ${VIRTUALBOX_CPUS:=4} +: "${VIRTUALBOX_CPUS:=4}" export VIRTUALBOX_CPUS -: ${VIRTUALBOX_MEMORY_SIZE:=4096} +: "${VIRTUALBOX_MEMORY_SIZE:=4096}" export VIRTUALBOX_MEMORY_SIZE docker-machine create --driver virtualbox "$@" diff --git a/examples/docker-compose/notebook/build.sh b/examples/docker-compose/notebook/build.sh index 6a9dc502..6b030731 100755 --- a/examples/docker-compose/notebook/build.sh +++ b/examples/docker-compose/notebook/build.sh @@ -5,6 +5,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Setup environment +# shellcheck disable=SC1091 source "$DIR/env.sh" # Build the notebook image diff --git a/examples/docker-compose/notebook/down.sh b/examples/docker-compose/notebook/down.sh index fd472fc5..dd43c3f5 100755 --- a/examples/docker-compose/notebook/down.sh +++ b/examples/docker-compose/notebook/down.sh @@ -5,6 +5,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Setup environment +# shellcheck disable=SC1091 source "$DIR/env.sh" # Bring down the notebook container, using container name as project name diff --git a/examples/docker-compose/notebook/env.sh b/examples/docker-compose/notebook/env.sh index 551d2666..7648c0d8 100755 --- a/examples/docker-compose/notebook/env.sh +++ b/examples/docker-compose/notebook/env.sh @@ -10,7 +10,7 @@ export NAME # Exposed container port -: ${PORT:=80} +: "${PORT:=80}" export PORT # Container work volume name diff --git a/examples/docker-compose/notebook/up.sh b/examples/docker-compose/notebook/up.sh index 1c7cc197..f5d9aa77 100755 --- a/examples/docker-compose/notebook/up.sh +++ b/examples/docker-compose/notebook/up.sh @@ -58,6 +58,7 @@ else fi # Setup environment +# shellcheck disable=SC1091 source "$DIR/env.sh" # Create a Docker volume to store notebooks