Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
wilson-apps/docker/1.5.4/entrypoint.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (34 sloc)
1.15 KB
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
#!/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 |