-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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://<IP>:<PORT> | ||
#-> | ||
#http://<IP>:<PORT>/<CONTAINERKEY> | ||
# | ||
#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/data' -e CONTAINERKEY=sav1 loosolab/wilson:1.2" | ||
#-> http://<IP>: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 |