Do not fail if the target directory is not present.

This commit is contained in:
Andrea Dell'Amico 2023-03-20 14:02:54 +01:00
parent 7ed4e181c2
commit b2ce248d1b
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
1 changed files with 12 additions and 10 deletions

View File

@ -1,14 +1,16 @@
#!/bin/bash
# shellcheck shell=bash
## Set our dynamic variables in Renviron.site to be reflected by RStudio Server or Shiny Server
exclude_vars="HOME PASSWORD RSTUDIO_VERSION BATCH_USER_CREATION"
for file in /var/run/s6/container_environment/*
do
sed -i "/^${file##*/}=/d" ${R_HOME}/etc/Renviron.site
regex="(^| )${file##*/}($| )"
[[ ! $exclude_vars =~ $regex ]] && echo "${file##*/}=$(cat $file)" >> ${R_HOME}/etc/Renviron.site || echo "skipping $file"
done
if [ -d "/var/run/s6/container_environment" ] ; then
## Set our dynamic variables in Renviron.site to be reflected by RStudio Server or Shiny Server
exclude_vars="HOME PASSWORD RSTUDIO_VERSION BATCH_USER_CREATION"
for file in /var/run/s6/container_environment/*
do
sed -i "/^${file##*/}=/d" ${R_HOME}/etc/Renviron.site
regex="(^| )${file##*/}($| )"
[[ ! $exclude_vars =~ $regex ]] && echo "${file##*/}=$(cat $file)" >> ${R_HOME}/etc/Renviron.site || echo "skipping $file"
done
## only file-owner (root) should read container_environment files:
chmod 600 /var/run/s6/container_environment/*
## only file-owner (root) should read container_environment files:
chmod 600 /var/run/s6/container_environment/*
fi