summaryrefslogtreecommitdiff
blob: a86ef7450ebd2d3ab16a49bb72e3b2598e289491 (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
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit systemd

MY_PV="${PV/_beta/-beta.}"
DESCRIPTION="UniFi Video Server"
HOMEPAGE="https://www.ubnt.com/download/unifi-video/"
SRC_URI="https://dl.ubnt.com/firmwares/ufv/v${MY_PV}/unifi-video.Ubuntu18.04_amd64.v${MY_PV}.deb"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""
RESTRICT="mirror"

DEPEND="acct-group/unifi-video
	acct-user/unifi-video"
RDEPEND="${DEPEND}
	dev-db/mongodb
	dev-java/commons-daemon
	sys-apps/lsb-release
	sys-apps/util-linux
	sys-libs/libcap
	virtual/jre:1.8"

S=${WORKDIR}
QA_PREBUILT="usr/lib*/${PN}/lib/*.so usr/lib*/${PN}/bin/*"

src_unpack() {
	default
	unpack "${WORKDIR}"/data.tar.gz
}

src_prepare() {
	eapply "${FILESDIR}"/commons-daemon-move.patch
	sed -i usr/sbin/${PN} \
		-e '/require_root$/d' \
		-e '/update_limits$/d' \
		-e '/ulimit/d' \
		-e '/coredump_filter/d' || die
	default
}

src_install() {
	export CODEPATH=/usr/lib/${PN}
	export DATAPATH=/var/lib/${PN}
	LOGPATH=${DATAPATH}/logs
	VARLOGPATH=/var/log/${PN}

	insinto /usr/lib
	doins -r .${CODEPATH}
	into /usr
	dosbin usr/sbin/unifi-video

	dodir ${LOGPATH}
	fowners -R ${PN}:${PN} ${DATAPATH}
	dosym ${LOGPATH} ${VARLOGPATH}
	dosym ${LOGPATH} ${CODEPATH}/logs

	dosym ${DATAPATH} ${CODEPATH}/data

	fperms 500 ${CODEPATH}/bin/ubnt.avtool
	fperms 500 ${CODEPATH}/bin/evostreamms
	fperms 500 /usr/sbin/${PN}
	fowners -R ${PN}:${PN} ${CODEPATH}
	fperms -R 0400 ${CODEPATH}/lib/
	fperms 500 ${CODEPATH}/lib/

	echo "CONFIG_PROTECT=\"${DATAPATH}/system.properties\"" > "${T}"/99${PN}
	doenvd "${T}"/99${PN}

	dosym ../../../bin/mongod ${CODEPATH}/bin/mongod

	newinitd "${FILESDIR}"/${PN}.initd ${PN}
	systemd_dounit "${FILESDIR}"/${PN}.service
}

pkg_postinst() {
	if [[ ! -f ${DATAPATH}/system.properties ]]; then
		cp ${CODEPATH}/etc/system.properties ${DATAPATH}/system.properties
		echo uuid=$(uuidgen) >> ${DATAPATH}/system.properties
	fi
}