using rsync instead of mv to prevent accidental file deletion when bind mount a volume

This commit is contained in:
rigzba21
2021-08-05 22:40:17 -04:00
parent 02f1fb149f
commit 2ef77522e6
2 changed files with 2 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ RUN apt-get update --yes && \
wget \ wget \
ca-certificates \ ca-certificates \
sudo \ sudo \
rsync \
locales \ locales \
fonts-liberation \ fonts-liberation \
run-one && \ run-one && \

View File

@@ -54,7 +54,7 @@ if [ "$(id -u)" == 0 ] ; then
# (it could be mounted, and we shouldn't create it if it already exists) # (it could be mounted, and we shouldn't create it if it already exists)
if [[ ! -e "/home/${NB_USER}" ]]; then if [[ ! -e "/home/${NB_USER}" ]]; then
echo "Relocating home dir to /home/${NB_USER}" echo "Relocating home dir to /home/${NB_USER}"
mv /home/jovyan "/home/${NB_USER}" || ln -s /home/jovyan "/home/${NB_USER}" mkdir "/home/${NB_USER}" && rsync -avx /home/jovyan "/home/${NB_USER}" || ln -s /home/jovyan "/home/${NB_USER}"
fi fi
# if workdir is in /home/jovyan, cd to /home/${NB_USER} # if workdir is in /home/jovyan, cd to /home/${NB_USER}
if [[ "${PWD}/" == "/home/jovyan/"* ]]; then if [[ "${PWD}/" == "/home/jovyan/"* ]]; then