-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathentrypoint
executable file
·68 lines (58 loc) · 1.56 KB
/
entrypoint
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
#!/bin/sh
echo "### ENTRYPOINT BEGIN ###"
echo $*
echo "### ENTRYPOINT END ###"
ctl () {
node --harmony /app/bin/ctl \
--pid-path="$BTSYNC_PID_PATH" \
--config-path="$BTSYNC_CONFIG_PATH" \
--host-data-path="$HOST_DATA_PATH" \
--data-path="$DATA_PATH" \
$@
}
# If we got arguments, I suppose you want to control btsync, as so, lets pass
# them to btsyncctl and exit with its value
if [ "$1" == "ctl" ]; then
exec ctl ${@:2};
exit $?
fi
if [ "$1" == "bash" ]; then
exec /bin/sh -s # ${@:2};
exit $?
fi
if [ "$1" == "bootstrap" ]; then
ctl init;
ctl add --secret="$2" "$3";
fi
# Dump variables to help development process
echo
echo "--"
echo
echo "Environment Variables"
echo
echo "DATA:"
echo "- PATH: ${DATA_PATH}"
echo "BTSYNC:"
echo "- ACTIVE: true"
echo "- CONFIG: INTERVAL@${BTSYNC_CONFIG_INTERVAL_CHECK} PATH@${BTSYNC_CONFIG_PATH}"
echo "- USER: ${BTSYNC_UID} ${BTSYNC_USER} ${BTSYNC_HOME}"
echo "- GROUP: ${BTSYNC_GID} ${BTSYNC_GROUP}"
echo "NFS:"
echo "- ACTIVE: $( [ ! -z "${NFS}" ] && echo "true" || "false" )"
echo "- VERSION: ${NFS_VERSION}"
echo
echo "--"
echo
# Activate nfs service in case we should use it
if [ ! -z "${NFS}" ]; then
rm -f /app/s6/nfs/down
fi
# Configure user
echo "Configuring user: $BTSYNC_USER -> ${BTSYNC_UID}:${BTSYNC_GID}"
addgroup -g "$BTSYNC_GID" "$BTSYNC_GROUP"
adduser -u "$BTSYNC_UID" -G "$BTSYNC_GROUP" -h "$BTSYNC_HOME" -D "$BTSYNC_USER"
mkdir -p "$BTSYNC_HOME"
# Own data folder
chown -R ${BTSYNC_UID}:${BTSYNC_GID} ${DATA_PATH}
# Start supervisor
exec s6-svscan /app/s6