Install NZBHydra on Debian for Universal Usenet Searching

nzbhydraInstall NZBHydra on Debian for universal usenet searching to replace NZBMegaSearch. NZBMegaSearch has halted development but mirabis attempted to keep it alive. theotherp decided to create NZBHydra as an NZBMegaSearch alternative to integrate with Sonarr, SickRage, CouchPotato and other automation software. Users who like reverse proxies will be happy to know that NZBHydra works with reverse proxies out of the box. This NZBHydra tutorial will show you how to install on all Debian versions (tested on Wheezy and Jessie) and includes an init.d script and systemd service.

Note that NZBHydra is still in its early stages so report any bugs or issues on github.

Usenet Provider
Backbone
Retention
Speed
Connections
VPN
Monthly
Annual
UsenetServer
UsenetServer
3199
Unlimited
30
Yes
$10
$95.40
Newshosting
Newshosting
3199
Unlimited
30
Yes
$10
$99
Frugal
Frugal
3000
Unlimited
20
No
$4.16
$50
Usenetlink
Cloudgate
2000
100 Mbit
30
No
$15
$140

Install NZBHydra on Debian

If you are on Debian Wheezy or Debian Jessie then use this ppa to make sure you get Python 2.7.11

echo "deb http://ppa.launchpad.net/fkrull/deadsnakes-python2.7/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/python-2.7.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DB82666C

Update your Debian repository list and install python 2.7 and git

sudo apt-get update
sudo apt-get install python2.7 git-core -y

If you get any errors above, these should resolve them by reinstalling python 2.7

sudo apt-get install python2.7 --reinstall
sudo apt-get install -f

Clone the latest NZBHydra from the official repository

sudo git clone https://github.com/theotherp/nzbhydra /opt/nzbhydra

Change ownership to your preferred user for running programs (replace both instances of htpcguides)

sudo chown -R htpcguides:htpcguides /opt/nzbhydra

Test that NZBHydra runs, you can kill the process afterwards with Ctrl+C in the SSH terminal

cd /opt/nzbhydra
python nzbhydra.py --nobrowser

You should be able to see the NZBHydra web interface on its default listening port 5075

Autostart NZBHydra on Debian

You can use the NZBHydra init.d script on any Debian system. Debian Jessie and and newer users that prefer systemd can use the systemd script.

If you are in doubt whether you are using systemd or init.d (sysvinit)

sudo stat /proc/1/exe | grep -i file | awk '{print $4}'

If you see this line, then you have systemd

‘/lib/systemd/systemd’

NZBHydra init.d Script

Create the NZBHydra init.d script

sudo nano /etc/init.d/nzbhydra

Paste this NZBHydra init.d script, adjust the DAEMON_USER to match the one you used above for the chown command

#!/bin/sh
### BEGIN INIT INFO
# Provides:          NZBHydra
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: NZBHydra
# Description:       Usenet search aggregator
### END INIT INFO
 
 
# Documentation available at
# http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html
# Debian provides some extra functions though
. /lib/lsb/init-functions
 
DAEMON_NAME="NZBHydra"
DAEMON_USER=htpcguides
DAEMON_PATH="/usr/bin/python"
DAEMON_OPTS="nzbhydra.py --nobrowser"
DAEMON_PWD="/opt/nzbhydra"
DAEMON_DESC=$(get_lsb_header_val $0 "Short-Description")
DAEMON_PID="/var/run/${DAEMON_NAME}.pid"
DAEMON_NICE=0
DAEMON_LOG='/var/log/nzbhydra'
 
[ -r "/etc/default/${DAEMON_NAME}" ] && . "/etc/default/${DAEMON_NAME}"
 
do_start() {
  local result
 
	pidofproc -p "${DAEMON_PID}" "${DAEMON_PATH}" > /dev/null
	if [ $? -eq 0 ]; then
		log_warning_msg "${DAEMON_NAME} is already started"
		result=0
	else
		log_daemon_msg "Starting ${DAEMON_DESC}" "${DAEMON_NAME}"
		touch "${DAEMON_LOG}"
		chown $DAEMON_USER "${DAEMON_LOG}"
		chmod u+rw "${DAEMON_LOG}"
		if [ -z "${DAEMON_USER}" ]; then
			start-stop-daemon --start --quiet --oknodo --background \
				--nicelevel $DAEMON_NICE \
				--chdir "${DAEMON_PWD}" \
				--pidfile "${DAEMON_PID}" --make-pidfile \
				--exec "${DAEMON_PATH}" -- $DAEMON_OPTS
			result=$?
		else
			start-stop-daemon --start --quiet --oknodo --background \
				--nicelevel $DAEMON_NICE \
				--chdir "${DAEMON_PWD}" \
				--pidfile "${DAEMON_PID}" --make-pidfile \
				--chuid "${DAEMON_USER}" \
				--exec "${DAEMON_PATH}" -- $DAEMON_OPTS
			result=$?
		fi
		log_end_msg $result
	fi
	return $result
}
 
do_stop() {
	local result
 
	pidofproc -p "${DAEMON_PID}" "${DAEMON_PATH}" > /dev/null
	if [ $? -ne 0 ]; then
		log_warning_msg "${DAEMON_NAME} is not started"
		result=0
	else
		log_daemon_msg "Stopping ${DAEMON_DESC}" "${DAEMON_NAME}"
		killproc -p "${DAEMON_PID}" "${DAEMON_PATH}"
		result=$?
		log_end_msg $result
		rm "${DAEMON_PID}"
	fi
	return $result
}
 
do_restart() {
	local result
	do_stop
	result=$?
	if [ $result = 0 ]; then
		do_start
		result=$?
	fi
	return $result
}
 
do_status() {
	local result
	status_of_proc -p "${DAEMON_PID}" "${DAEMON_PATH}" "${DAEMON_NAME}"
	result=$?
	return $result
}
 
do_usage() {
	echo $"Usage: $0 {start | stop | restart | status}"
	exit 1
}
 
case "$1" in
start)   do_start;   exit $? ;;
stop)    do_stop;    exit $? ;;
restart) do_restart; exit $? ;;
status)  do_status;  exit $? ;;
*)       do_usage;   exit  1 ;;
esac

Ctrl+X, Y and Enter to Save

Make the NZBHydra init.d script on Debian executable

sudo chmod +x /etc/init.d/nzbhydra

Tell your Debian server to use the NZBHydra init.d script by default

sudo update-rc.d nzbhydra defaults

Start NZBHydra init.d service

sudo service nzbhydra start

NZBHydra Systemd Script

Create the NZBHydra systemd script

sudo nano /etc/systemd/system/nzbhydra.service

Paste the NZBHydra systemd script, adjust your User and Group to the one you used in the sudo chown command during the installation phase.

[Unit]
Description=NZBHydra Daemon
Documentation=https://github.com/theotherp/nzbhydra
After=network.target

[Service]
User=htpcguides
Group=htpcguides
Type=simple
ExecStart=/usr/bin/python /opt/nzbhydra/nzbhydra.py --daemon --nobrowser

KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable NZBHydra systemd script on Debian

sudo systemctl enable nzbhydra

Start the NZBHydra systemd service

sudo service nzbhydra start

Now you can configure NZBHydra which is done similarly to NZBMegaSearch.

Remember the default NZBHydra listening port is 5075.