-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrun.sh
executable file
·76 lines (63 loc) · 2.05 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#Developer's startup script
#Created by chaplocal on Wed Oct 7 02:09:09 UTC 2015
IMAGE="garywiz/docker-grav"
INTERACTIVE_SHELL="/bin/bash"
# You can specify the external host and ports for your webserver here. These variables
# are also passed into the container so that any application code which does redirects
# can use these if need be.
EXT_HOSTNAME=docker1.local
EXT_HTTP_PORT=8080
EXT_HTTPS_PORT=8443
# Uncomment to enable SSL and specify the certificate hostname
#EXT_SSL_HOSTNAME=secure.example.com
PORTOPT="-p $EXT_HTTP_PORT:8080 -e CONFIG_EXT_HTTP_PORT=$EXT_HTTP_PORT \
-p $EXT_HTTPS_PORT:8443 -e CONFIG_EXT_HTTPS_PORT=$EXT_HTTPS_PORT"
usage() {
echo "Usage: run.sh [-d] [-p port#] [-h] [extra-chaperone-options]"
echo " Run $IMAGE as a daemon or interactively (the default)."
echo " First available port will be remapped to $EXT_HOSTNAME if possible."
exit
}
if [ "$CHAP_SERVICE_NAME" != "" ]; then
echo run.sh should be executed on your docker host, not inside a container.
exit
fi
cd ${0%/*} # go to directory of this file
APPS=$PWD
cd ..
options="-t -i -e TERM=$TERM --rm=true"
shellopt="/bin/bash --rcfile $APPS/bash.bashrc"
while getopts ":-dp:n:" o; do
case "$o" in
d)
options="-d"
shellopt=""
;;
n)
options="$options --name $OPTARG"
;;
p)
PORTOPT="-p $OPTARG"
;;
-) # first long option terminates
break
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
# Run the image with this directory as our local apps dir.
# Create a user with a uid/gid based upon the file permissions of the chaperone.d
# directory.
MOUNT=${PWD#/}; MOUNT=/${MOUNT%%/*} # extract user mountpoint
SELINUX_FLAG=$(sestatus 2>/dev/null | fgrep -q enabled && echo :z)
docker run $options -v $MOUNT:$MOUNT$SELINUX_FLAG $PORTOPT \
-e CONFIG_EXT_HOSTNAME="$EXT_HOSTNAME" \
-e CONFIG_EXT_SSL_HOSTNAME="$EXT_SSL_HOSTNAME" \
-e CONFIG_LOGGING=file \
-e EMACS=$EMACS \
$IMAGE \
--create $USER:$APPS/chaperone.d --config $APPS/chaperone.d $* $shellopt