diff options
Diffstat (limited to 'unifi/unifi-setup.sh')
-rwxr-xr-x | unifi/unifi-setup.sh | 69 |
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 | |||
3 | set -e | ||
4 | |||
5 | USERNAME="unifi" | ||
6 | BASEDIR="/usr/lib/unifi" | ||
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_GID" = 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 | ||
23 | if ! getent group ${USERNAME} > /dev/null 2>&1; then | ||
24 | addgroup -g ${UNIFI_GID} -S ${USERNAME} | ||
25 | fi | ||
26 | if ! getent passwd ${USERNAME} > /dev/null 2>&1; then | ||
27 | adduser -u ${UNIFI_UID} -S -h /var/lib/${USERNAME} -H -D -G ${USERNAME} ${USERNAME} | ||
28 | fi | ||
29 | |||
30 | # Update permissions on the root directories | ||
31 | chown -R ${USERNAME}:${USERNAME} \ | ||
32 | /var/lib/unifi \ | ||
33 | /var/log/unifi \ | ||
34 | /var/run/unifi \ | ||
35 | /usr/lib/unifi/dl | ||
36 | |||
37 | ln -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 | |||
43 | if [ -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 | ||
50 | fi | ||
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. | ||
57 | if [ -z "$START_DEFAULT" ]; then | ||
58 | echo "is_default=false" >> /var/lib/unifi/system.properties | ||
59 | fi | ||
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 | ||