aboutsummaryrefslogtreecommitdiffstats
path: root/non-free/unifi/APKBUILD
blob: 28a0dedc9f242885709c325c6e0f6587eb41bbfb (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Maintainer: TBK <alpine@jjtc.eu>
# Contributer: TBK <alpine@jjtc.eu>
pkgname=unifi
_pkgname=UniFi
pkgver=5.7.23
_pkgver=7957bc47e8
pkgrel=0
pkgdesc="The Ubiquiti UniFi network controller"
url="http://wiki.ubnt.com/UniFi_FAQ"
arch="noarch"
license="UniFi-EULA"
depends="openjdk8-jre-base java-snappy mongodb"
install="$pkgname.pre-install"
pkgusers="$pkgname"
pkggroups="$pkgname"
options="!check" # No test suite
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.zip::https://dl.ubnt.com/unifi/$pkgver-$_pkgver/$_pkgname.unix.zip
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotated
	"
builddir="$srcdir/$_pkgname"

prepare() {
	default_prepare
	# removing libubnt_webrtc_jni.so which disables rtc support
	# which disabled cloud features (afaik)
	rm -rf "$builddir"/lib/native
}

package() {
	cd "$builddir"
	# unifi wants everything in a base directory but we dont
	local basedir="$pkgdir/usr/lib/$pkgname"
	local datadir="$pkgdir/var/lib/$pkgname"
	local webapps="$pkgdir/usr/share/webapps"
	
	mkdir -p $basedir/bin $datadir $webapps

	install -Dm644 "$srcdir"/$pkgname.logrotated \
		"$pkgdir"/etc/logrotate.d/$pkgname
	install -Dm755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 readme.txt \
		"$pkgdir"/usr/share/doc/$pkgname/readme.txt

	cp -r webapps $webapps/$pkgname

	local dir; for dir in dl lib conf; do
		cp -r $dir "$basedir"/
	done
	
	local dir; for dir in work data; do
		install -dm 755 -o $pkgname -g $pkgname "$datadir/$dir"
	done

	# link things back to basedir
	ln -sf /usr/bin/mongod $basedir/bin/mongod
	ln -sf /var/log/$pkgname $basedir/logs
	ln -sf /run/$pkgname $basedir/run
	ln -sf /usr/share/webapps/$pkgname $basedir/webapps
	ln -sf /var/lib/$pkgname/data $basedir/data
	ln -sf /var/lib/$pkgname/work $basedir/work
	
	# overwrite with local snappy but
	# first we got to figure out the version
	local file=$(ls lib/ | grep snappy-java)
	local name=${file%.*}
	local version=${name##*-}
	# the java-snappy pkg has a symlink so we use that
	ln -sf /usr/share/java/snappy-java.jar \
		"$basedir"/lib/snappy-java-$version.jar
	
	# make sure datadir is writable by our user
	chown -R $pkgname:$pkgname $datadir

	# tell search engines to do not index
	echo -e "User-Agent:*\nDisallow:/" > "$webapps"/$pkgname/ROOT/robots.txt
}

sha512sums="63150282d9b7c907e0851bfcfa6779c8a5568b6aa5a8c7333dd5d1403ea8561f8175e9682f79c508da98812efc619257971943a1c3803dd1e72295b9de3340af  unifi-5.7.23.zip
b19a7d684ef2ec7c4159417c21185ccd8ce498da25405b69014fdb32e346a0077f7edc5dfc994481d12936aa8dbf22e6baf29571fd0003aaad19609d24c549f4  unifi.initd
d339555a91de7488badbedf8a4c85cff878e7d0720a8cf6a8340f51f3666dcf4878b47a1fff4c9c2846d7af140d11e48e898f8c4dba1f81c1004b76a81f0821e  unifi.confd
9e54d9e1c720b8e50c9af9363105f6ea9ff2cffff7dc67477a7701aacf21ba977424fe9fbaba6a00d5f64310a2e2517e9328a7acb91a4bc06ed237139a8e0d9b  unifi.logrotated"