-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstart.sh
executable file
·33 lines (25 loc) · 1003 Bytes
/
start.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
#!/bin/bash
PORT=${PORT:-8081}
LISTEN=${LISTEN:-127.0.0.1}
# determine the docker executable name
if which docker; then DOCKER='docker'
else DOCKER='docker.io' ; fi # debian default
# check that docker is installed
if ! sudo $DOCKER --version ; then
echo 'install docker first...' ; exit 1
fi
# make output verbose
set -o xtrace -o nounset
# set the random_key if not already set
HASH=$(cat /dev/urandom | tr -dc 'a-f0-9' | fold -w 48 | head -n 1)
sed -i "s/{{RANDOM_KEY}}/${HASH}/g" ./roundcube/config.inc.php
# 0. Create roundcube-data container to host only data
sudo $DOCKER ps -a | grep 'roundcube-data'
if [ "$?" -ne 0 ] ; then
echo 'launching instance of roundcude-data'
sudo $DOCKER run -v /rc --name roundcube-data busybox mkdir -p /rc
fi
# 1. Create image with roundcube
sudo $DOCKER build -t thinred/roundcube ./roundcube
# 2. Start it and attach rc-data volumes
sudo $DOCKER run -p ${LISTEN}:${PORT}:80 --volumes-from roundcube-data -d --name roundcube thinred/roundcube