Page 1 of 1

Problem /etc/init.d and /usr/bin/SABnzbd.py

Posted: August 16th, 2009, 8:40 am
by larsa
Hi guys!

Found this site when using my Ubuntu box, and had no problems installing and using it there. Over on my Sabayon box, I was however not able to find any overlays I could use to make sure I had an up to date and working installation, so I started to make my own ebuilds from older versions. After messing around some with the ebuilds, I was finally able to emerge SABnzbd to my system. Second problem now, is that I am not able to run SABnzbd... :P

The emerging of SABnzbd worked pretty good. The only messages that might give some concerns are this:

Code: Select all

!!! newconfd: /usr/local/portage/net-nntp/sabnzbd/files/sabnzbd.conf does not exist
>>> Completed installing sabnzbd-0.4.11 into /var/tmp/portage/net-nntp/sabnzbd-0.4.11/image/

 * QA Notice: file does not exist:
 * 
 * 	newconfd: /usr/local/portage/net-nntp/sabnzbd/files/sabnzbd.conf does not exist
However, the compiling ends up with this message:

Code: Select all

>>> /usr/share/sabnzbd -> /usr/share/sabnzbd-0.4.11
 * Byte compiling python modules for python-2.5 .. ...                                                 [ ok ]
 * Default directory: /var/lib/sabnzbd
 * Templates can be found in: /usr/share/sabnzbd-0.4.11
 * 
 * Run: gpasswd -a <user> sabnzbd
 * to add an user to the sabnzbd group so it can edit sabnzbd files
 * 
 * Please configure /etc/conf.d/sabnzbd before starting!
 * 
 * Start with /etc/init.d/sabnzbd start

>>> Recording net-nntp/sabnzbd in "world" favorites file...
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.
So I assume that everything should be OK after all??

/etc/conf.d/sabnzbd does not exist after emerging though.. And when trying to run /etc/init.d/sabnzbd start, I only end up with ERROR: sabnzbd failed to start. I have also manually tried to run /usr/bin/SABnzbd.py but that also ends up with errors, that the themes does not exist, even though it is clearly listed where the themes might be found above (* Templates can be found in: /usr/share/sabnzbd-0.4.11):

Code: Select all

2009-08-16 09:48:29,254::ERROR::Cannot find standard template: /usr/bin/interfaces/Default
Traceback (most recent call last):
  File "./usr/bin/SABnzbd.py", line 200, in Web_Template
    wdir = cfg['misc'][key]
  File "//usr/lib/python2.5/site-packages/sabnzbd/utils/configobj.py", line 580, in __getitem__
    val = dict.__getitem__(self, key)
KeyError: 'web_dir'
2009-08-16 09:48:29,256::INFO::Lauching browser with /tmp/tmpL2yPNT.html
I am not quite sure where I have failed here, as I am pretty new to making ebuilds myself, assume that I have missed something in the configurations etc? Or does anyone here know if there are any other solutions?? Will post the files used for building below in 2 sec.

Re: Problem /etc/init.d and /usr/bin/SABnzbd.py

Posted: August 16th, 2009, 8:41 am
by larsa
This is the main sabnzbd ebuild file:

Code: Select all

# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="1"

inherit distutils

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

DESCRIPTION="Binary Newsgrabber written in Python, server-oriented using a web-interface.The active successor of the abandoned SABnzbd project."
HOMEPAGE="http://www.sabnzbd.org/"
SRC_URI="mirror://sourceforge/sabnzbdplus/${MY_P}-src.tar.gz"

HOMEDIR="${ROOT}var/lib/${PN}"
DHOMEDIR="/var/lib/${PN}"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="+rar unzip rss +yenc ssl"

RDEPEND=">=dev-lang/python-2.4.4
		>=dev-python/celementtree-1.0.5
		=dev-python/cherrypy-2*
		>=dev-python/cheetah-2.0.1
		>=app-arch/par2cmdline-0.4
		rar? ( app-arch/rar )
		unzip? ( >=app-arch/unzip-5.5.2 )
		rss? ( >=dev-python/feedparser-4.1 )
		yenc? ( >=dev-python/yenc-0.3 )
		ssl? ( dev-python/pyopenssl )
		openssl? ( dev-libs/openssl )"
DEPEND="${RDEPEND}
		app-text/dos2unix"

S="${WORKDIR}/${MY_P}"
DOCS="CHANGELOG.txt ISSUES.txt INSTALL.txt README.txt"

src_unpack() {
	unpack ${A}
	cp "${FILESDIR}/${PN}-gentoo-setup.py" "${S}/setup.py"
}

pkg_setup() {
	#Create group and user
	enewgroup "${PN}"
	enewuser "${PN}" -1 -1 "${HOMEDIR}" "${PN}"
}

src_install() {
	distutils_src_install

	#Init scripts
	newinitd "${FILESDIR}/${PN}.init" "${PN}"
	newconfd "${FILESDIR}/${PN}.conf" "${PN}"

	#Example config
	insinto /etc
	newins "${FILESDIR}/${PN}.ini" "${PN}.conf"
	fowners root:${PN} /etc/${PN}.conf
	fperms 660 /etc/${PN}.conf

	#Create all default dirs
	keepdir ${DHOMEDIR}

	for i in download dirscan complete nzb_backup cache scripts; do
		keepdir ${DHOMEDIR}/${i}
	done
	fowners -R ${PN}:${PN} ${DHOMEDIR}
	fperms -R 775 ${DHOMEDIR}

	keepdir /var/log/sabnzbd
	fowners -R ${PN}:${PN} /var/log/${PN}
	fperms -R 775 /var/log/${PN}

	#Add themes
	cd "${D}"
	mv usr/interfaces usr/share/${P}

	#fix permission on themes
	fowners -R root:sabnzbd /usr/share/${P}

	#create symlink to keep the initial conf version free
	dosym /usr/share/${P} /usr/share/${PN}
}

pkg_postinst() {
	distutils_pkg_postinst

	einfo "Default directory: ${HOMEDIR}"
	einfo "Templates can be found in: ${ROOT}usr/share/${P}"
	einfo ""
	einfo "Run: gpasswd -a <user> sabnzbd"
	einfo "to add an user to the sabnzbd group so it can edit sabnzbd files"
	einfo ""
	ewarn "Please configure /etc/conf.d/${PN} before starting!"
	einfo ""
	einfo "Start with ${ROOT}etc/init.d/${PN} start"
}

Re: Problem /etc/init.d and /usr/bin/SABnzbd.py

Posted: August 16th, 2009, 8:45 am
by larsa
I had to make a own folder called "file" and copy this file in there, in order for emerge to compile properly. This file is called sabnzbd-gentoo-setup.py

Code: Select all

#!/usr/bin/env python

Win32ConsoleName = 'SABnzbd-console.exe'
Win32WindowName  = 'SABnzbd.exe'

import sabnzbd
from distutils.core import setup

# py2exe usage: python setup.py py2exe

try:
    import glob
    import sys
    import os
    import py2exe
except ImportError:
    py2exe = None

print sys.argv[0]

if (len(sys.argv) < 2) or sys.argv[1] != 'py2exe':
    py2exe = None

options = dict(
      name = 'SABnzbd',
      version = sabnzbd.__version__,
      url = 'http://sourceforge.net/projects/sabnzbdplus',
      author = 'The ShyPike & Gregor Kaufmann',
      author_email = 'shypike@users.sourceforge.net',
      description = 'SABnzbd ' + str(sabnzbd.__version__),
      scripts = ['SABnzbd.py'],
      packages = ['sabnzbd', 'sabnzbd.utils', 'sabnzbd.utils.multiauth'],
      platforms = ['posix'],
      license = 'GNU General Public License 2 (GPL2)',
      data_files = [
          ('interfaces/Default/templates', glob.glob("interfaces/Default/templates/*.tmpl")),
          ('interfaces/Default/templates/static/stylesheets', glob.glob('interfaces/Default/templates/static/stylesheets/*.*')),
	  ('interfaces/Default/templates/static/stylesheets/colorschemes', glob.glob('interfaces/Default/templates/static/stylesheets/colorschemes/*.*')),
          ('interfaces/Default/templates/static/images', glob.glob('interfaces/Default/templates/static/images/*.ico')),
	  ('interfaces/Default/templates/static/javascript', glob.glob('interfaces/Default/templates/static/javascript/*.js')),

          ('interfaces/smpl/templates', glob.glob("interfaces/smpl/templates/*.*")),
          ('interfaces/smpl/templates/static', glob.glob("interfaces/smpl/templates/static/*.*")),
          ('interfaces/smpl/templates/static/images', glob.glob("interfaces/smpl/templates/static/images/*.*")),
	  ('interfaces/smpl/templates/static/images/nuvola', glob.glob("interfaces/smpl/templates/static/images/nuvola/*.*")),
          ('interfaces/smpl/templates/static/MochiKit', glob.glob("interfaces/smpl/templates/static/MochiKit/*.*")),
          ('interfaces/smpl/templates/static/PlotKit', glob.glob("interfaces/smpl/templates/static/PlotKit/*.*")),
          ('interfaces/smpl/templates/static/excanvas', glob.glob("interfaces/smpl/templates/static/excanvas/*.*")),
          ('interfaces/smpl/templates/static/stylesheets', glob.glob("interfaces/smpl/templates/static/stylesheets/*.*")),
	  ('interfaces/smpl/templates/static/stylesheets/colorschemes', glob.glob("interfaces/smpl/templates/static/stylesheets/colorschemes/*.*")),

          ('interfaces/Plush/templates', glob.glob("interfaces/Plush/templates/*.*")),
          ('interfaces/Plush/templates/static', glob.glob("interfaces/Plush/templates/static/*.*")),
          ('interfaces/Plush/templates/static/images', glob.glob("interfaces/Plush/templates/static/images/*.*")),
          ('interfaces/Plush/templates/static/images/plush-default', glob.glob("interfaces/Plush/templates/static/images/plush-default/*.*")),
          ('interfaces/Plush/templates/static/images/plush-default/config', glob.glob("interfaces/Plush/templates/static/images/plush-default/config/*.*")),
          ('interfaces/Plush/templates/static/images/plush-default/nzo', glob.glob("interfaces/Plush/templates/static/images/plush-default/nzo/*.*")),
          ('interfaces/Plush/templates/static/javascripts', glob.glob("interfaces/Plush/templates/static/javascripts/*.*")),
          ('interfaces/Plush/templates/static/stylesheets', glob.glob("interfaces/Plush/templates/static/stylesheets/*.*")),

	  ('interfaces/iphone/templates', glob.glob("interfaces/iphone/templates/*.*")),
	  ('interfaces/iphone/templates/static', glob.glob("interfaces/iphone/templates/static/*.*")),
	  ('interfaces/iphone/templates/static/iui', glob.glob("interfaces/iphone/templates/static/iui/*.*")),
	  ('interfaces/iphone/templates/MochiKit', glob.glob("interfaces/iphone/templates/static/MochiKit/*.*")),
      ]
)

if py2exe:
    program = [ {'script' : 'SABnzbd.py', 'icon_resources' : [(0, "interfaces/Default/templates/static/images/favicon.ico")] } ]
    options['options'] = {"py2exe": {"bundle_files": 1, "packages": "xml,cherrypy.filters,Cheetah", "optimize": 2, "compressed": 0}}

    # Generate the console-app
    options['console'] = program
    setup(**options)
    try:
        if os.path.exists("dist/%s" % Win32ConsoleName):
            os.remove("dist/%s" % Win32ConsoleName)
        os.rename("dist/%s" % Win32WindowName, "dist/%s" % Win32ConsoleName)
    except:
        print "Cannot create dist/%s" % Win32ConsoleName
        exit(1)
    
    # Make sure that the root files are DOS format
    for file in options['data_files'][0][1]:
        os.system("unix2dos --safe dist/%s" % file)
    os.remove('dist/Sample-PostProc.sh')

    # Generate the windowed-app (skip datafiles now)
    del options['console']
    del options['data_files']
    options['windows'] = program
    setup(**options)

else:
    # Prepare Source distribution package.
    # Make sure all source files are Unix format
    import shutil

    root = 'srcdist'
    root = os.path.normpath(os.path.abspath(root))
    if not os.path.exists(root):
        os.mkdir(root)

    # Copy the data files
    for set in options['data_files']:
        dest, src = set
        ndir = root + '/' + dest
        ndir = os.path.normpath(os.path.abspath(ndir))
        if not os.path.exists(ndir):
            os.makedirs(ndir)
        for file in src:
            shutil.copy2(file, ndir)
            front, ext = os.path.splitext(file)
            base = os.path.basename(file)
            if ext.lower() in ('.py', '.pl', '.txt', '.html', '.css', '.tmpl', ''):
                os.system("dos2unix --quiet --safe %s" % ndir + '/' + base)

    # Copy the script files
    for name in options['scripts']:
        file = os.path.normpath(os.path.abspath(name))
        shutil.copy2(file, root)
        base = os.path.basename(file)
        fullname = os.path.normpath(os.path.abspath(root + '/' + base))
        os.system("dos2unix --quiet --safe %s" % fullname)

    # Copy all content of the packages (but skip backups and pre-compiled stuff)
    for unit in options['packages']:
        unitpath = unit.replace('.','/')
        dest = os.path.normpath(os.path.abspath(root + '/' + unitpath))
        if not os.path.exists(dest):
            os.makedirs(dest)
        for name in glob.glob("%s/*.*" % unitpath):
            file = os.path.normpath(os.path.abspath(name))
            front, ext = os.path.splitext(file)
            base = os.path.basename(file)
            fullname = os.path.normpath(os.path.abspath(dest + '/' + base))
            if ext.lower() not in ('.pyc', '.pyo', '.bak'):
                shutil.copy2(file, dest)
                os.system("dos2unix --quiet --safe %s" % fullname)


setup(**options)

Re: Problem /etc/init.d and /usr/bin/SABnzbd.py

Posted: August 16th, 2009, 8:48 am
by larsa
In the same folder (file) I also have two other files. This one is called sabnzbd.ini and is later copied to /etc/sabnzbd.conf

Code: Select all

__version__ = 18
[misc]
log_dir = /var/log/sabnzbd
auto_browser = 0
permissions = 0775
check_new_rel = 1
replace_spaces = 0
fail_on_crc = 0
enable_filejoin = 0
enable_unzip = 1
enable_unrar = 1
enable_par_cleanup = 1
par_option = ""
config_lock = 0
safe_postproc = 0
pause_on_post_processing = 0
cleanup_list = ""
ignore_samples = 0
send_group = 0
download_dir = /var/lib/sabnzbd/download
download_free = 0
incomplete_dir = /var/lib/sabnzbd/incomplete
complete_dir = /var/lib/sabnzbd/complete
script_dir = /var/lib/sabnzbd/scripts
nzb_backup_dir = /var/lib/sabnzbd/nzb_backup
cache_dir = /var/lib/sabnzbd/cache
dirscan_dir = /var/lib/sabnzbd/dirscan
dirscan_speed = 5
refresh_rate = 0
rss_rate = 60
bandwith_limit = 0
cache_limit = 0
email_server = ""
email_to = ""
email_from = ""
email_account = ""
email_pwd = ""
email_endjob = 0
email_full = 0
schedlines = ,
dirscan_opts = 3
dirscan_script = ""
top_only = 1
auto_sort = 0
enable_tv_sorting = 0
tv_sort_string = ""
web_color = ""
web_color2 = ""
host = localhost
port = 8080
web_dir = /usr/share/sabnzbd/Default
web_dir2 = ""
username = ""
password = ""
[logging]
enable_cherrypy_logging = 1
log_level = 1
max_log_size = 5M
log_backups = 5
[newzbin]
username = ""
password = ""
bookmarks = 0
unbookmark = 0
bookmark_rate = 60
[servers]
[rss]
[categories]
[[unknown]]
newzbin = Unknown
dir = Unknown
[[anime]]
newzbin = Anime
dir = Anime
[[apps]]
newzbin = Apps
dir = Apps
[[books]]
newzbin = Books
dir = Books
[[consoles]]
newzbin = Consoles
dir = Consoles
[[emulation]]
newzbin = Emulation
dir = Emulation
[[games]]
newzbin = Games
dir = Games
[[misc]]
newzbin = Misc
dir = Misc
[[movies]]
newzbin = Movies
dir = Movies
[[music]]
newzbin = Music
dir = Music
[[pda]]
newzbin = PDA
dir = PDA
[[resources]]
newzbin = Resources
dir = Resources
[[tv]]
newzbin = TV
dir = TV

Re: Problem /etc/init.d and /usr/bin/SABnzbd.py

Posted: August 16th, 2009, 8:50 am
by larsa
The last file in the "file" folder is sabnzbd.init I am not quite sure where it ends at last, but it is the start/stop script..

Code: Select all

#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $


opts="start stop"

depend() {
    need net
}

start() {
    ebegin "Starting SABnzbd"
    if ! check_config ; then
        eend 1
        return 1
    fi

    start-stop-daemon --quiet --start -c ${SAB_USER} -g ${SAB_GROUP} \
        --name SABnzbd.py --exec /usr/bin/SABnzbd.py -- \
        -s ${SAB_HOSTNAME}:${SAB_PORT} -f ${SAB_CONFIGFILE} -d &> /dev/null
    eend $?
}

stop() {
    ebegin "Stopping SABnzbd"
    URL="http://${SAB_HOSTNAME}:${SAB_PORT}/sabnzbd/shutdown"
    if [ -x /usr/bin/wget ] ; then
	/usr/bin/wget -q --delete-after "${URL}"
    elif [ -x /usr/bin/curl ] ; then
	/usr/bin/curl --silent "${URL}" > /dev/null 2> /dev/null
    else
	ewarn "missing wget and curl, ending all processes named SABnzbd.py"
	start-stop-daemon --quiet --stop --name SABnzbd.py
    fi
    eend $?
}

check_config() {
    if [ ! -e ${SAB_CONFIGFILE} ] ; then
        eerror "ERROR: can't find ${SAB_CONFIGFILE}."
        return 1
    else
        return 0
    fi
}

Re: Problem /etc/init.d and /usr/bin/SABnzbd.py

Posted: August 16th, 2009, 8:52 am
by larsa
So, if anyone is able to help me solve the problem (or improve/enhance the ebuilds), I would really appreciate it! Will also post the ebuilds on the bugtrackers and make them available for others as soon as it is working properly.

Thank you in advance for any inputs!

/Larsa

Re: Problem /etc/init.d and /usr/bin/SABnzbd.py

Posted: August 16th, 2009, 9:25 am
by shypike
Are you creating your own ebuild (whatever that is) or do you have trouble installing one?
The SABnzbd core team doesn't maintain package files for specific platforms (except Windows and OSX).
There is an active member on this forum (jcpf), who maintains the Ubuntu/Debian package.
I hope he may be able to help you out. The core team cannot.

Re: Problem /etc/init.d and /usr/bin/SABnzbd.py

Posted: August 16th, 2009, 9:37 am
by larsa
Hi shypike, yes, I am trying to make an up to date ebuild for Gentoo systems, so that other than Ubuntu users are able to easily take advantage of SABnzbd as well. :)