forked from drscream/mi-core-unifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customize
executable file
·38 lines (28 loc) · 1022 Bytes
/
customize
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
#!/usr/bin/bash
#
# Put customizations to your image in this file.
PATH=/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
# UniFi Controller Version
UNIFI_VERSION="5.8.21-2a76eef78d"
UNIFI_HASH="107f7ea67a9fc2acd6e661e6e92027bb"
# Exit if any commands fail
set -o errexit
echo "* Add UniFi user"
useradd -d /opt/local/UniFi -s /usr/bin/false unifi
echo "* Download and install UniFi Controller Software"
wget http://dl.ubnt.com/unifi/${UNIFI_VERSION}/UniFi.unix.zip -O /tmp/UniFi.unix.zip
LOCAL_HASH=($(digest -a md5 /tmp/UniFi.unix.zip))
if [[ "${UNIFI_HASH}" != "${LOCAL_HASH}" ]]; then
echo "ERROR: You maybe downloaded the wrong file for UniFi.unix.zip"
exit 1
fi
echo "* Extract to /opt/local"
unzip /tmp/UniFi.unix.zip -d /opt/local/
echo "* Use local installed mongodb binary"
ln -sf /opt/local/bin/mongod /opt/local/UniFi/bin/mongod
echo "* Chown everything to the unify user"
chown -R unifi:other /opt/local/UniFi
# Clean up
echo "* Cleaning up."
rm -rf /root/*
sm-prepare-image -y