From d2d5e14aa309d4167aba14504e01ec8d3157c0a8 Mon Sep 17 00:00:00 2001 From: bjoern Date: Wed, 17 Feb 2016 17:29:42 +0100 Subject: check if the entrypint script is run in a docker --- docker-ep.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/docker-ep.sh b/docker-ep.sh index aa8e8a2..3e2b630 100755 --- a/docker-ep.sh +++ b/docker-ep.sh @@ -2,16 +2,23 @@ ## ## entrypoint for the docker images -groupmod -g $gid voc -usermod -u $uid -g $gid voc +if [ ! -f /.dockerenv ] && [ ! -f /.dockerinit ]; then + echo "WARNING: this scrip should be only runed inside docker!!" + exit 1 +fi + +if [ ! -z $gid ] && [ ! -z $uid ]; then + groupmod -g $gid voc + usermod -u $uid -g $gid voc -# check if homedir is mounted -if grep -q '/home/voc' /proc/mounts; then - # homedir is mounted into the docker so don't touch the ownership of the files - true -else - # fixup for changed uid and gid - chown -R voc:voc /home/voc + # check if homedir is mounted + if grep -q '/home/voc' /proc/mounts; then + # homedir is mounted into the docker so don't touch the ownership of the files + true + else + # fixup for changed uid and gid + chown -R voc:voc /home/voc + fi fi function startCore() { @@ -62,6 +69,11 @@ function usage() { echo "scriptname.py - starts the example script named 'scriptname.py' " } +if [ -z $1 ]; then + usage + exit +fi + case $1 in help ) usage @@ -82,4 +94,4 @@ case $1 in * ) runExample $1 ;; -esac \ No newline at end of file +esac -- cgit v1.2.3