From 8a01153d69b9ce64a64e41b5785539a9f7cf457f Mon Sep 17 00:00:00 2001 From: Bryan Paget <8212170+bryanpaget@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:34:36 -0400 Subject: [PATCH] Add safe version of rm to prevent deletion of filers. (#648) * add safe version of rm * move rm wrapper to github gist * move rm wrapper to github gist * add safe version of rm via github gist * fix typo * fix typo * fix typo * change location of script: github -> gitlab --------- Co-authored-by: Bryan Paget --- "docker-bits/\342\210\236_CMD.Dockerfile" | 2 +- output/docker-stacks-datascience-notebook/Dockerfile | 2 +- output/docker-stacks-datascience-notebook/start-custom.sh | 8 ++++++++ output/jupyterlab-cpu/Dockerfile | 2 +- output/jupyterlab-cpu/start-custom.sh | 8 ++++++++ output/jupyterlab-pytorch/Dockerfile | 2 +- output/jupyterlab-pytorch/start-custom.sh | 8 ++++++++ output/jupyterlab-tensorflow/Dockerfile | 2 +- output/jupyterlab-tensorflow/start-custom.sh | 8 ++++++++ output/remote-desktop/start-custom.sh | 8 ++++++++ output/rstudio/Dockerfile | 2 +- output/rstudio/start-custom.sh | 8 ++++++++ output/sas/Dockerfile | 2 +- output/sas/start-custom.sh | 8 ++++++++ resources/common/start-custom.sh | 8 ++++++++ 15 files changed, 71 insertions(+), 7 deletions(-) diff --git "a/docker-bits/\342\210\236_CMD.Dockerfile" "b/docker-bits/\342\210\236_CMD.Dockerfile" index b525a5397..b883ce343 100644 --- "a/docker-bits/\342\210\236_CMD.Dockerfile" +++ "b/docker-bits/\342\210\236_CMD.Dockerfile" @@ -25,7 +25,7 @@ ADD connect-to-filer.md /home/$NB_USER/connect-to-filer.md # Point conda to Artifactory repository RUN conda config --remove channels conda-forge --system - + USER $NB_USER ENTRYPOINT ["tini", "--"] CMD ["start-custom.sh"] diff --git a/output/docker-stacks-datascience-notebook/Dockerfile b/output/docker-stacks-datascience-notebook/Dockerfile index 7dede0d8d..544d3451f 100644 --- a/output/docker-stacks-datascience-notebook/Dockerfile +++ b/output/docker-stacks-datascience-notebook/Dockerfile @@ -31,7 +31,7 @@ ADD connect-to-filer.md /home/$NB_USER/connect-to-filer.md # Point conda to Artifactory repository RUN conda config --remove channels conda-forge --system - + USER $NB_USER ENTRYPOINT ["tini", "--"] CMD ["start-custom.sh"] diff --git a/output/docker-stacks-datascience-notebook/start-custom.sh b/output/docker-stacks-datascience-notebook/start-custom.sh index ef668524b..6ee03d930 100755 --- a/output/docker-stacks-datascience-notebook/start-custom.sh +++ b/output/docker-stacks-datascience-notebook/start-custom.sh @@ -44,6 +44,14 @@ if [ ! -f /home/$NB_USER/.zsh-installed ]; then touch /home/$NB_USER/.hushlogin fi +# add rm wrapper: +# https://jirab.statcan.ca/browse/ZPS-40 +mkdir -p /home/$NB_USER/.local/bin/ +git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git +mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm +rm -rf /home/$NB_USER/.local/bin/rm-git +chmod +x /home/$NB_USER/.local/bin/rm + export VISUAL="/usr/bin/nano" export EDITOR="$VISUAL" diff --git a/output/jupyterlab-cpu/Dockerfile b/output/jupyterlab-cpu/Dockerfile index e5c8f5ed2..f755ce1be 100644 --- a/output/jupyterlab-cpu/Dockerfile +++ b/output/jupyterlab-cpu/Dockerfile @@ -467,7 +467,7 @@ ADD connect-to-filer.md /home/$NB_USER/connect-to-filer.md # Point conda to Artifactory repository RUN conda config --remove channels conda-forge --system - + USER $NB_USER ENTRYPOINT ["tini", "--"] CMD ["start-custom.sh"] diff --git a/output/jupyterlab-cpu/start-custom.sh b/output/jupyterlab-cpu/start-custom.sh index ef668524b..6ee03d930 100755 --- a/output/jupyterlab-cpu/start-custom.sh +++ b/output/jupyterlab-cpu/start-custom.sh @@ -44,6 +44,14 @@ if [ ! -f /home/$NB_USER/.zsh-installed ]; then touch /home/$NB_USER/.hushlogin fi +# add rm wrapper: +# https://jirab.statcan.ca/browse/ZPS-40 +mkdir -p /home/$NB_USER/.local/bin/ +git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git +mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm +rm -rf /home/$NB_USER/.local/bin/rm-git +chmod +x /home/$NB_USER/.local/bin/rm + export VISUAL="/usr/bin/nano" export EDITOR="$VISUAL" diff --git a/output/jupyterlab-pytorch/Dockerfile b/output/jupyterlab-pytorch/Dockerfile index 94dd42c77..a1cef89c0 100644 --- a/output/jupyterlab-pytorch/Dockerfile +++ b/output/jupyterlab-pytorch/Dockerfile @@ -489,7 +489,7 @@ ADD connect-to-filer.md /home/$NB_USER/connect-to-filer.md # Point conda to Artifactory repository RUN conda config --remove channels conda-forge --system - + USER $NB_USER ENTRYPOINT ["tini", "--"] CMD ["start-custom.sh"] diff --git a/output/jupyterlab-pytorch/start-custom.sh b/output/jupyterlab-pytorch/start-custom.sh index ef668524b..6ee03d930 100755 --- a/output/jupyterlab-pytorch/start-custom.sh +++ b/output/jupyterlab-pytorch/start-custom.sh @@ -44,6 +44,14 @@ if [ ! -f /home/$NB_USER/.zsh-installed ]; then touch /home/$NB_USER/.hushlogin fi +# add rm wrapper: +# https://jirab.statcan.ca/browse/ZPS-40 +mkdir -p /home/$NB_USER/.local/bin/ +git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git +mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm +rm -rf /home/$NB_USER/.local/bin/rm-git +chmod +x /home/$NB_USER/.local/bin/rm + export VISUAL="/usr/bin/nano" export EDITOR="$VISUAL" diff --git a/output/jupyterlab-tensorflow/Dockerfile b/output/jupyterlab-tensorflow/Dockerfile index 84153af5e..ed2ace0c8 100644 --- a/output/jupyterlab-tensorflow/Dockerfile +++ b/output/jupyterlab-tensorflow/Dockerfile @@ -596,7 +596,7 @@ ADD connect-to-filer.md /home/$NB_USER/connect-to-filer.md # Point conda to Artifactory repository RUN conda config --remove channels conda-forge --system - + USER $NB_USER ENTRYPOINT ["tini", "--"] CMD ["start-custom.sh"] diff --git a/output/jupyterlab-tensorflow/start-custom.sh b/output/jupyterlab-tensorflow/start-custom.sh index ef668524b..6ee03d930 100755 --- a/output/jupyterlab-tensorflow/start-custom.sh +++ b/output/jupyterlab-tensorflow/start-custom.sh @@ -44,6 +44,14 @@ if [ ! -f /home/$NB_USER/.zsh-installed ]; then touch /home/$NB_USER/.hushlogin fi +# add rm wrapper: +# https://jirab.statcan.ca/browse/ZPS-40 +mkdir -p /home/$NB_USER/.local/bin/ +git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git +mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm +rm -rf /home/$NB_USER/.local/bin/rm-git +chmod +x /home/$NB_USER/.local/bin/rm + export VISUAL="/usr/bin/nano" export EDITOR="$VISUAL" diff --git a/output/remote-desktop/start-custom.sh b/output/remote-desktop/start-custom.sh index ef668524b..6ee03d930 100755 --- a/output/remote-desktop/start-custom.sh +++ b/output/remote-desktop/start-custom.sh @@ -44,6 +44,14 @@ if [ ! -f /home/$NB_USER/.zsh-installed ]; then touch /home/$NB_USER/.hushlogin fi +# add rm wrapper: +# https://jirab.statcan.ca/browse/ZPS-40 +mkdir -p /home/$NB_USER/.local/bin/ +git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git +mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm +rm -rf /home/$NB_USER/.local/bin/rm-git +chmod +x /home/$NB_USER/.local/bin/rm + export VISUAL="/usr/bin/nano" export EDITOR="$VISUAL" diff --git a/output/rstudio/Dockerfile b/output/rstudio/Dockerfile index 104a74a79..6c16304b9 100644 --- a/output/rstudio/Dockerfile +++ b/output/rstudio/Dockerfile @@ -281,7 +281,7 @@ ADD connect-to-filer.md /home/$NB_USER/connect-to-filer.md # Point conda to Artifactory repository RUN conda config --remove channels conda-forge --system - + USER $NB_USER ENTRYPOINT ["tini", "--"] CMD ["start-custom.sh"] diff --git a/output/rstudio/start-custom.sh b/output/rstudio/start-custom.sh index ef668524b..6ee03d930 100755 --- a/output/rstudio/start-custom.sh +++ b/output/rstudio/start-custom.sh @@ -44,6 +44,14 @@ if [ ! -f /home/$NB_USER/.zsh-installed ]; then touch /home/$NB_USER/.hushlogin fi +# add rm wrapper: +# https://jirab.statcan.ca/browse/ZPS-40 +mkdir -p /home/$NB_USER/.local/bin/ +git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git +mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm +rm -rf /home/$NB_USER/.local/bin/rm-git +chmod +x /home/$NB_USER/.local/bin/rm + export VISUAL="/usr/bin/nano" export EDITOR="$VISUAL" diff --git a/output/sas/Dockerfile b/output/sas/Dockerfile index fd6af7a9d..d06500195 100644 --- a/output/sas/Dockerfile +++ b/output/sas/Dockerfile @@ -519,7 +519,7 @@ ADD connect-to-filer.md /home/$NB_USER/connect-to-filer.md # Point conda to Artifactory repository RUN conda config --remove channels conda-forge --system - + USER $NB_USER ENTRYPOINT ["tini", "--"] CMD ["start-custom.sh"] diff --git a/output/sas/start-custom.sh b/output/sas/start-custom.sh index ef668524b..6ee03d930 100755 --- a/output/sas/start-custom.sh +++ b/output/sas/start-custom.sh @@ -44,6 +44,14 @@ if [ ! -f /home/$NB_USER/.zsh-installed ]; then touch /home/$NB_USER/.hushlogin fi +# add rm wrapper: +# https://jirab.statcan.ca/browse/ZPS-40 +mkdir -p /home/$NB_USER/.local/bin/ +git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git +mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm +rm -rf /home/$NB_USER/.local/bin/rm-git +chmod +x /home/$NB_USER/.local/bin/rm + export VISUAL="/usr/bin/nano" export EDITOR="$VISUAL" diff --git a/resources/common/start-custom.sh b/resources/common/start-custom.sh index ef668524b..6ee03d930 100755 --- a/resources/common/start-custom.sh +++ b/resources/common/start-custom.sh @@ -44,6 +44,14 @@ if [ ! -f /home/$NB_USER/.zsh-installed ]; then touch /home/$NB_USER/.hushlogin fi +# add rm wrapper: +# https://jirab.statcan.ca/browse/ZPS-40 +mkdir -p /home/$NB_USER/.local/bin/ +git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git +mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm +rm -rf /home/$NB_USER/.local/bin/rm-git +chmod +x /home/$NB_USER/.local/bin/rm + export VISUAL="/usr/bin/nano" export EDITOR="$VISUAL"