aboutsummaryrefslogtreecommitdiff
path: root/unifi/unifi-setup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'unifi/unifi-setup.sh')
-rwxr-xr-xunifi/unifi-setup.sh69
1 files changed, 0 insertions, 69 deletions
diff --git a/unifi/unifi-setup.sh b/unifi/unifi-setup.sh
deleted file mode 100755
index 86153b5..0000000
--- a/unifi/unifi-setup.sh
+++ /dev/null
@@ -1,69 +0,0 @@
1#!/bin/sh
2
3set -e
4
5USERNAME="unifi"
6BASEDIR="/usr/lib/unifi"
7DATA_DIR="${BASEDIR}/data"
8
9# Default UID/GID to owner of the data directory
10UNIFI_UID=${UNIFI_UID:-$(stat -L -c "%u" $DATA_DIR)}
11UNIFI_GID=${UNIFI_GID:-$(stat -L -c "%u" $DATA_DIR)}
12
13if [ "$UNIFI_GID" = 0 -o "$UNIFI_GID" = 0 ]; then
14 echo "Set UNIFI_UID and UNIFI_GID in environment"
15 exit 1
16else
17 echo "Unifi UID/GID: $UNIFI_UID $UNIFI_GID"
18fi
19
20cd ${BASEDIR}
21
22# Create the user and group
23if ! getent group ${USERNAME} > /dev/null 2>&1; then
24 addgroup -g ${UNIFI_GID} -S ${USERNAME}
25fi
26if ! getent passwd ${USERNAME} > /dev/null 2>&1; then
27 adduser -u ${UNIFI_UID} -S -h /var/lib/${USERNAME} -H -D -G ${USERNAME} ${USERNAME}
28fi
29
30# Update permissions on the root directories
31chown -R ${USERNAME}:${USERNAME} \
32 /var/lib/unifi \
33 /var/log/unifi \
34 /var/run/unifi \
35 /usr/lib/unifi/dl
36
37ln -s /var/log/unifi /logs
38
39# Cleanup mongodb lock file if it exists otherwise the controller will freeze
40# forever trying to start Mongo
41[ -f data/db/mongod.lock ] && rm data/db/mongod.lock
42
43if [ -n "$MONGO_URL" ]; then
44 echo "Using external mongodb instance"
45 echo "db.mongo.local=false" >> /var/lib/unifi/system.properties
46 echo "db.mongo.uri=${MONGO_URL}" >> /var/lib/unifi/system.properties
47 echo "statdb.mongo.uri=${MONGO_STATS_URL}" >> /var/lib/unifi/system.properties
48 echo "unifi.db.name=${MONGO_DB_NAME:-ace}" >> /var/lib/unifi/system.properties
49 echo "statdb.db.name=${MONGO_STATS_DB_NAME:-ace_stat}" >> /var/lib/unifi/system.properties
50fi
51
52# If this is set that the controller will start with no settings and will run
53# the setup.
54#
55# WARNING! If this is set on a live database then the controller will delete
56# all data and start fresh.
57if [ -z "$START_DEFAULT" ]; then
58 echo "is_default=false" >> /var/lib/unifi/system.properties
59fi
60
61# Replace the current process with a scoped-down controller. The java app
62# is designed to do its own job control but it has to run with an init
63# system or it doesn't get the signals from docker.
64#
65# Use the snappy native library installed with apk because the bundled on
66# is built against libc which is not available in Alpine. Without this
67# inform will fail with a decompression library error.
68
69# NOTE: This has been migrated to simplevisor.json