From de2ebeb8e5de7bfec9d468cf0978ea9c178c480f Mon Sep 17 00:00:00 2001 From: Carsten Kuenne Date: Tue, 26 Jun 2018 15:45:38 +0200 Subject: [PATCH] Create entrypoint.sh --- docker/1.5.3/entrypoint.sh | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 docker/1.5.3/entrypoint.sh diff --git a/docker/1.5.3/entrypoint.sh b/docker/1.5.3/entrypoint.sh new file mode 100644 index 0000000..5a9bf30 --- /dev/null +++ b/docker/1.5.3/entrypoint.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +#this script is run when the container is started +#optionally adds $CONTAINERKEY to shiny server url by modifying shiny-server.conf +# +#example: +#http://: +#-> +#http://:/ +# +#to use this add the "-e" parameter when starting a container: +#docker run ... -e CONTAINERKEY=${container_key} ... +#example: +#docker run --name='sav1' -d -p 50000:3838 -v '/mnt/agnerds/docker/projects/sav1':'/srv/shiny-server/external_data' -e CONTAINERKEY=sav1 loosolab/wilson:1.2" +#-> http://:50000/sav1 + +conf="/etc/shiny-server/shiny-server.conf" + +#create backup of original shiny-server.conf +if [[ ! -f "${conf}.old" ]]; then + cp ${conf} ${conf}.old +else + cp ${conf}.old ${conf} +fi + +#add parameter(s) at top of .conf +param="preserve_logs true;" +sed -i "1i $param" ${conf} + +param="sanitize_errors off;" +sed -i "1i $param" ${conf} + +#if environment variable given -> add key to url +if [[ ! -z "$CONTAINERKEY" ]]; then + CONTAINERKEY=$(echo -e $CONTAINERKEY | sed 's/\//\\\//g') #to escape "/" + cat ${conf} | sed "s/location \//location \/$CONTAINERKEY/g" >${conf}.1 + mv ${conf}.1 ${conf} +fi + +#start shiny server +exec shiny-server 2>&1 >>/var/log/shiny-server.log