-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_rsync.sh
executable file
·54 lines (44 loc) · 1.28 KB
/
build_rsync.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
#!/bin/bash
#
#################################
# do not call this script directly.
# use the Makefile.
#################################
#
# Build the rsync stunnel docker container using the Dockerfile
#
# https://charlesreid1.com/wiki/Docker/Dockerfiles
SED="/bin/sed"
function usage {
echo ""
echo "build_rsync.sh script:"
echo "builds an rsync stunnel docker container."
echo "specify a port number for the stunnel server to use:"
echo ""
echo " ./build_rsync.sh 666"
echo ""
}
if [[ "$#" -ne 1 || $1 =~ "[0-9]\{1,5\}" ]];
then
usage
else
CERT="fullchain.pem"
KEY="privkey.pem"
CONF="stunnel.conf"
THIS_CONF="stunnel.server.rsync.conf"
STARTSCRIPT="start_stunnel.sh"
DOCKERFILE="Dockerfile"
if [ -f $CERT -a -f $KEY -a -f $THIS_CONF ]; then
$SED "s/PORT/${1}/g" ${THIS_CONF} > ${CONF}
$SED -i "s/ssyncd [0-9]\{1,5\}/ssyncd ${1}/g" ${STARTSCRIPT}
$SED -i "s/EXPOSE [0-9]\{1,5\}/EXPOSE ${1}/g" ${DOCKERFILE}
docker build -f ${DOCKERFILE} -t cmr_stunnel_rsync .
else
echo "rsync stunnel docker container build script:"
echo "Missing one of the following:"
echo "${CERT}, ${KEY}, ${THIS_CONF}"
echo ""
echo "Copy an example stunel configuration file, or use your own."
echo "Check /etc/letsencrypt/live/domain.com/ or /etc/ssl/ for certificates."
fi
fi