From c43b1299cb73548f163a60b9fdb1022292c1ad3b Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Tue, 17 Oct 2023 13:34:20 -0400 Subject: [PATCH] use /var/run/noteable instead of /etc/noteable for connection file path (#58) --- deno/run.sh | 18 +++++++++++++++++- python/base-gpu/run.sh | 15 ++++++++++++++- python/run.sh | 15 ++++++++++++++- r/run.sh | 15 ++++++++++++++- rust/run.sh | 18 +++++++++++++++++- 5 files changed, 76 insertions(+), 5 deletions(-) diff --git a/deno/run.sh b/deno/run.sh index 26d9ae59..7e06a11e 100755 --- a/deno/run.sh +++ b/deno/run.sh @@ -7,6 +7,22 @@ set -x echo "Local time: $(date)" +connection_file=/tmp/connection_file.json +VAR_RUN_FILE="/var/run/noteable/connections/connection_file.json" +ETC_FILE="/etc/noteable/connections/connection_file.json" + +# This is a temporary change while we migrate from /etc/noteable to /var/run/noteable. +# Check if the /var/run file exists, and if it does, copy it to the destination +if [[ -f ${VAR_RUN_FILE} ]]; then + cp ${VAR_RUN_FILE} ${connection_file} +# If the /var/run file doesn't exist, check for the /etc file and copy it if it exists +elif [[ -f ${ETC_FILE} ]]; then + cp ${ETC_FILE} ${connection_file} +else + echo "Error: Neither ${VAR_RUN_FILE} nor ${ETC_FILE} exists." + exit 1 +fi + set +x echo "Injecting Secrets into environment, echoing is turned off" # shellcheck disable=SC1091 @@ -17,5 +33,5 @@ set -x echo "Starting Deno kernel" exec deno --unstable \ jupyter \ - --conn /etc/noteable/connections/connection_file.json \ + --conn ${connection_file} \ --kernel diff --git a/python/base-gpu/run.sh b/python/base-gpu/run.sh index 819455c0..427cb004 100755 --- a/python/base-gpu/run.sh +++ b/python/base-gpu/run.sh @@ -8,7 +8,20 @@ echo "Local time: $(date)" set -x connection_file=/tmp/connection_file.json -cp /etc/noteable/connections/connection_file.json ${connection_file} +VAR_RUN_FILE="/var/run/noteable/connections/connection_file.json" +ETC_FILE="/etc/noteable/connections/connection_file.json" + +# This is a temporary change while we migrate from /etc/noteable to /var/run/noteable. +# Check if the /var/run file exists, and if it does, copy it to the destination +if [[ -f ${VAR_RUN_FILE} ]]; then + cp ${VAR_RUN_FILE} ${connection_file} +# If the /var/run file doesn't exist, check for the /etc file and copy it if it exists +elif [[ -f ${ETC_FILE} ]]; then + cp ${ETC_FILE} ${connection_file} +else + echo "Error: Neither ${VAR_RUN_FILE} nor ${ETC_FILE} exists." + exit 1 +fi # Inject Secrets into environment (see script docstring for more info) # set +x to avoid echoing the Secrets in plaintext to logs diff --git a/python/run.sh b/python/run.sh index d93d0a9d..67d5197a 100755 --- a/python/run.sh +++ b/python/run.sh @@ -8,7 +8,20 @@ echo "Local time: $(date)" set -x connection_file=/tmp/connection_file.json -cp /etc/noteable/connections/connection_file.json ${connection_file} +VAR_RUN_FILE="/var/run/noteable/connections/connection_file.json" +ETC_FILE="/etc/noteable/connections/connection_file.json" + +# This is a temporary change while we migrate from /etc/noteable to /var/run/noteable. +# Check if the /var/run file exists, and if it does, copy it to the destination +if [[ -f ${VAR_RUN_FILE} ]]; then + cp ${VAR_RUN_FILE} ${connection_file} +# If the /var/run file doesn't exist, check for the /etc file and copy it if it exists +elif [[ -f ${ETC_FILE} ]]; then + cp ${ETC_FILE} ${connection_file} +else + echo "Error: Neither ${VAR_RUN_FILE} nor ${ETC_FILE} exists." + exit 1 +fi # Inject Secrets into environment (see script docstring for more info) # set +x to avoid echoing the Secrets in plaintext to logs diff --git a/r/run.sh b/r/run.sh index 0bc216d4..4a94d640 100755 --- a/r/run.sh +++ b/r/run.sh @@ -7,7 +7,20 @@ set -x echo "Local time: $(date)" connection_file=/tmp/connection_file.json -cp /etc/noteable/connections/connection_file.json ${connection_file} +VAR_RUN_FILE="/var/run/noteable/connections/connection_file.json" +ETC_FILE="/etc/noteable/connections/connection_file.json" + +# This is a temporary change while we migrate from /etc/noteable to /var/run/noteable. +# Check if the /var/run file exists, and if it does, copy it to the destination +if [[ -f ${VAR_RUN_FILE} ]]; then + cp ${VAR_RUN_FILE} ${connection_file} +# If the /var/run file doesn't exist, check for the /etc file and copy it if it exists +elif [[ -f ${ETC_FILE} ]]; then + cp ${ETC_FILE} ${connection_file} +else + echo "Error: Neither ${VAR_RUN_FILE} nor ${ETC_FILE} exists." + exit 1 +fi # Inject Secrets into environment (see script docstring for more info) # set +x to avoid echoing the Secrets in plaintext to logs diff --git a/rust/run.sh b/rust/run.sh index c7eb9fa2..677bad1c 100755 --- a/rust/run.sh +++ b/rust/run.sh @@ -7,6 +7,22 @@ set -x echo "Local time: $(date)" +connection_file=/tmp/connection_file.json +VAR_RUN_FILE="/var/run/noteable/connections/connection_file.json" +ETC_FILE="/etc/noteable/connections/connection_file.json" + +# This is a temporary change while we migrate from /etc/noteable to /var/run/noteable. +# Check if the /var/run file exists, and if it does, copy it to the destination +if [[ -f ${VAR_RUN_FILE} ]]; then + cp ${VAR_RUN_FILE} ${connection_file} +# If the /var/run file doesn't exist, check for the /etc file and copy it if it exists +elif [[ -f ${ETC_FILE} ]]; then + cp ${ETC_FILE} ${connection_file} +else + echo "Error: Neither ${VAR_RUN_FILE} nor ${ETC_FILE} exists." + exit 1 +fi + set +x echo "Injecting Secrets into environment, echoing is turned off" # shellcheck disable=SC1091 @@ -17,4 +33,4 @@ set -x echo "Starting Rust kernel" -exec evcxr_jupyter --control_file /etc/noteable/connections/connection_file.json +exec evcxr_jupyter --control_file ${connection_file}