summaryrefslogtreecommitdiff
blob: 60556282d490b13c6bf94d098809deb8b5b4219b (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
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="4"

# Require python-2 with sqlite USE flag
PYTHON_DEPEND="2:2.6"
PYTHON_USE_WITH="sqlite"

inherit eutils python user

MY_P="${P/sab/SAB}"

DESCRIPTION="Binary newsgrabber in Python, with web-interface. Successor of old SABnzbd project"
HOMEPAGE="http://www.sabnzbd.org/"
SRC_URI="mirror://sourceforge/sabnzbdplus/${MY_P}-src.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""

RDEPEND="
	app-arch/par2cmdline
	app-arch/unrar
	app-arch/unzip
	dev-python/cheetah
	dev-python/pyopenssl
	dev-python/yenc
"

S="${WORKDIR}/${MY_P}"
DHOMEDIR="/var/lib/${PN}"

pkg_setup() {
	# Control PYTHON_USE_WITH
	python_set_active_version 2
	python_pkg_setup

	# Create sabnzbd group
	enewgroup ${PN}
	# Create sabnzbd user, put in sabnzbd group
	enewuser ${PN} -1 -1 "${DHOMEDIR}" ${PN}
}

src_install() {
	dodoc {ABOUT,CHANGELOG,ISSUES,README}.txt Sample-PostProc.sh

	newconfd "${FILESDIR}/${PN}.conf" ${PN}

	newinitd "${FILESDIR}/${PN}.init" ${PN}

	# Default configuration file
	insinto "${DHOMEDIR}/config"
	doins "${FILESDIR}/${PN}.ini"

	# Assign ownership of SABnzbd default directory
	fowners -R root:${PN} "${DHOMEDIR}"
	fperms -R 770 "${DHOMEDIR}"

	# Rotation of logfile
	insinto /etc/logrotate.d
	newins "${FILESDIR}/${PN}.logrotate" ${PN}

	# Add themes & code into /usr/share
	insinto /usr/share/${PN}
	doins -r cherrypy email gntp interfaces locale po sabnzbd SABnzbd.py tools util

	# Adjust permissions in python source directory for root:sabnzbd
	fowners -R root:${PN} /usr/share/${PN}
	fperms -R 770 /usr/share/${PN}
}

pkg_postinst() {
	python_mod_optimize /usr/share/${PN}

	elog "SABnzbd has been installed with default directories in ${DHOMEDIR}"
	elog
	elog "Please configure /etc/conf.d/${PN} before starting as daemon!"
	elog "If you use SSL connection for SABnzbd WebUi, you have to change SAB_PORT with \"9090\"."
	elog
	elog "Start with ${ROOT}etc/init.d/${PN} start"
	elog "Visit http://<host ip>:8080 to configure SABnzbd"
	elog "Default web username/password : sabnzbd/secret"
	elog
	elog "Add CONFIG_PROTECT=\"${DHOMEDIR}/config\" to your make.conf. Otherwise, we will lose your personal configuration"
}

pkg_postrm() {
	python_mod_cleanup /usr/share/${PN}
}