aboutsummaryrefslogtreecommitdiffstats
path: root/non-free/unifi/APKBUILD
blob: 12483ade7458afce40219f302ec55cf31b14e929 (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
88
89
90
91
92
93
94
95
# Maintainer: TBK <alpine@jjtc.eu>
# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Contributor: AdamRushad <2429990+adamrushad@users.noreply.github.com>
pkgname=unifi
_pkgname=UniFi
pkgver=5.9.29
pkgrel=0
pkgdesc="The Ubiquiti UniFi SDN 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/$_pkgname.unix.zip
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotated
	mongo_prune.js
	unifi_db_prune.cron
	"
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

	# install purging DB job (disabled by default)
	install -Dm644 "$srcdir"/mongo_prune.js "$pkgdir"/etc/unifi/mongo_prune.js
	install -Dm755 "$srcdir"/unifi_db_prune.cron "$pkgdir"/etc/periodic/weekly/unifi_db_prune
}

sha512sums="f00ba9470d78fa5922e81a5ff2e53927d2a2ec7d08ab543abf4b236ff9fb8761b060083025fc410f72c0ff48c75c915dd3561a3869dc4a2de0f8900e19af0976  unifi-5.9.29.zip
b19a7d684ef2ec7c4159417c21185ccd8ce498da25405b69014fdb32e346a0077f7edc5dfc994481d12936aa8dbf22e6baf29571fd0003aaad19609d24c549f4  unifi.initd
d339555a91de7488badbedf8a4c85cff878e7d0720a8cf6a8340f51f3666dcf4878b47a1fff4c9c2846d7af140d11e48e898f8c4dba1f81c1004b76a81f0821e  unifi.confd
9e54d9e1c720b8e50c9af9363105f6ea9ff2cffff7dc67477a7701aacf21ba977424fe9fbaba6a00d5f64310a2e2517e9328a7acb91a4bc06ed237139a8e0d9b  unifi.logrotated
3eec528077af9b32aa065610b4ffc50537a1c851c84624eaa63287787d853c0f8c953a97bd58bc6c2cab7f9f26eaff8c8b2815a84454169f7e0d96b94dfc91ee  mongo_prune.js
25d66b144403676bcb6142f4942b62c6f969a6b359ccb4dd4fcb826b1e57f902179d01182369704970b2d6094b8b3789fd375c17cec908cac53f7abf01fb2e1b  unifi_db_prune.cron"