diff options
Diffstat (limited to 'unifi-video/entrypoint.sh')
-rwxr-xr-x | unifi-video/entrypoint.sh | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/unifi-video/entrypoint.sh b/unifi-video/entrypoint.sh deleted file mode 100755 index 7b1e7b1..0000000 --- a/unifi-video/entrypoint.sh +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | set -e | ||
4 | |||
5 | USERNAME="unifi-video" | ||
6 | BASEDIR="/usr/lib/unifi-video" | ||
7 | DATA_DIR="${BASEDIR}/data" | ||
8 | |||
9 | # Default UID/GID to owner of the data directory | ||
10 | UNIFI_UID=${UNIFI_UID:-$(stat -L -c "%u" $DATA_DIR)} | ||
11 | UNIFI_GID=${UNIFI_GID:-$(stat -L -c "%u" $DATA_DIR)} | ||
12 | |||
13 | if [ "$UNIFI_UID" = 0 -o "$UNIFI_GID" = 0 ]; then | ||
14 | echo "Set UNIFI_UID and UNIFI_GID in environment" | ||
15 | exit 1 | ||
16 | else | ||
17 | echo "Unifi UID/GID: $UNIFI_UID $UNIFI_GID" | ||
18 | fi | ||
19 | |||
20 | cd ${BASEDIR} | ||
21 | |||
22 | # Create the user and group if they don't exist | ||
23 | if ! grep "^${USERNAME}:" /etc/group &>/dev/null; then | ||
24 | addgroup -g ${UNIFI_GID} -S ${USERNAME} | ||
25 | fi | ||
26 | if ! grep "^${USERNAME}:" /etc/passwd &>/dev/null; then | ||
27 | adduser -u ${UNIFI_UID} -S -h /var/lib/${USERNAME} -H -D -G ${USERNAME} ${USERNAME} | ||
28 | fi | ||
29 | |||
30 | mkdir -p /var/log/mongodb/logs | ||
31 | |||
32 | # Update permissions on the root directories | ||
33 | chown -R ${USERNAME}:${USERNAME} \ | ||
34 | /var/run/unifi-video \ | ||
35 | /var/log/unifi-video \ | ||
36 | /var/lib/unifi-video \ | ||
37 | /var/log/mongodb/logs | ||
38 | |||
39 | chown -R ${USERNAME}:${USERNAME} \ | ||
40 | /usr/lib/unifi-video/conf/evostream \ | ||
41 | /usr/lib/unifi-video/webapps \ | ||
42 | /usr/lib/unifi-video/conf/Catalina \ | ||
43 | /usr/lib/unifi-video/work | ||
44 | |||
45 | # But do not let the unifi user write the ROOT WAR | ||
46 | chown root:root /usr/lib/unifi-video/webapps/ROOT.war | ||
47 | |||
48 | # Setup tmpfs if the user mounted it | ||
49 | TMPFS_ARG= | ||
50 | TMPFS_DIR="/var/cache/unifi-video" | ||
51 | if [ -d $TMPFS_DIR ]; then | ||
52 | TMPFS_ARG="-Dav.tempdir=${TMPFS_DIR}" | ||
53 | chown ${USERNAME} ${TMPFS_DIR} | ||
54 | chmod -R 0700 ${TMPFS_DIR} | ||
55 | fi | ||
56 | |||
57 | # Do the base setup and migrate files | ||
58 | if [ ! -f "${DATA_DIR}/system.properties" ]; then | ||
59 | cp -f "${BASEDIR}/etc/system.properties" "${DATA_DIR}/system.properties" | ||
60 | fi | ||
61 | |||
62 | if [ -f "${DATA_DIR}/truststore" ]; then | ||
63 | rm -f "${DATA_DIR}/truststore" | ||
64 | fi | ||
65 | |||
66 | if [ ! -f "${DATA_DIR}/ufv-truststore" ]; then | ||
67 | cp -f "${BASEDIR}/etc/ufv-truststore" "${DATA_DIR}/ufv-truststore" | ||
68 | fi | ||
69 | |||
70 | chown -h ${USERNAME}:${USERNAME} \ | ||
71 | "${DATA_DIR}" \ | ||
72 | "${DATA_DIR}/system.properties" \ | ||
73 | "${DATA_DIR}/ufv-truststore" | ||
74 | |||
75 | # Cleanup mongodb lock file if it exists otherwise the controller will freeze | ||
76 | # forever trying to start Mongo | ||
77 | [ -f data/db/mongod.lock ] && rm data/db/mongod.lock | ||
78 | |||
79 | # Allow running a shell in the container | ||
80 | if [ ! -z "$@" ]; then | ||
81 | /sbin/su-exec ${USERNAME} "$@" | ||
82 | else | ||
83 | # Replace the current process with a scoped-down controller. The java app | ||
84 | # is designed to do its own job control but it has to run with an init | ||
85 | # system or it doesn't get the signals from docker. | ||
86 | exec /usr/bin/dumb-init -c /sbin/su-exec ${USERNAME} /usr/lib/jvm/default-jvm/jre/bin/java \ | ||
87 | -cp ${BASEDIR}/lib/airvision.jar \ | ||
88 | -Dlog4j.configurationFile=${BASEDIR}/log4j2.json \ | ||
89 | ${TMPFS_ARG} \ | ||
90 | -Djava.library.path=${BASEDIR}/lib \ | ||
91 | -Djavax.net.ssl.trustStore=${DATA_DIR}/ufv-truststore \ | ||
92 | -Djava.security.egd=file:/dev/urandom \ | ||
93 | -Xmx$(free -m | awk 'NR==2{printf "%dM\n", $2*0.26 }') \ | ||
94 | -Djava.awt.headless=true \ | ||
95 | -Dfile.encoding=UTF-8 \ | ||
96 | com.ubnt.airvision.Main start | ||
97 | fi | ||