Last active
June 30, 2019 11:16
-
-
Save Nachtalb/0f71d70c5fa69bb7d498af39b4f13440 to your computer and use it in GitHub Desktop.
Centos 6 - Init.d - Install Sonarr / Radarr / Lidarr + mono + sqlite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# # # # # # # # # # # # # # # | |
# Install yum prerequisites # | |
# # # # # # # # # # # # # # # | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Starting the installation of Sonarr + Mono + SQLitee." | |
echo "--------------------------------------------------------------------------------------------" | |
sleep 5 | |
# Install EPEL & OpenSuse repository | |
rpm -ivh "http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm" | |
wget "https://copr.fedoraproject.org/coprs/tpokorra/mono-opt/repo/epel-6/tpokorra-mono-opt-epel-6.repo" -O /etc/yum.repos.d/mono.repo | |
# Install mono repo | |
rpm --import "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" | |
su -c 'curl https://download.mono-project.com/repo/centos6-stable.repo | tee /etc/yum.repos.d/mono-centos6-stable.repo' | |
# Install mediainfo | |
rpm -Uvh "https://mediaarea.net/repo/rpm/releases/repo-MediaArea-1.0-9.noarch.rpm" | |
yum install -y mono-complete bison gettext glib2 freetype fontconfig libpng \ | |
libpng-devel referenceassemblies-pcl libX11 libX11-devel \ | |
glib2-devel libgdi* libexif glibc-devel urw-fonts java unzip \ | |
gcc gcc-c++ automake autoconf libtool make bzip2 wget mediainfo gettext | |
# # # # # # # # # # # # # # # # # | |
# Install sqlite # | |
# # # # # # # # # # # # # # # # # | |
echo "--------------------------------------------------------------------------------------------" | |
echo "We will now install SQLitee." | |
echo "--------------------------------------------------------------------------------------------" | |
sleep 5 | |
# Download / Extract sqlite | |
wget "http://www.sqlite.org/2014/sqlite-autoconf-3080500.tar.gz" -O /tmp/sqlite-autoconf-3080500.tar.gz | |
tar -zxvf /tmp/sqlite-autoconf-*.tar.gz -C /tmp/ | |
cd /tmp/sqlite-autoconf* | |
# Install sqlite | |
./configure --prefix=/opt/sqlite3.8.5 \ | |
--disable-static \ | |
CFLAGS=" -Os \ | |
-frecord-gcc-switches \ | |
-DSQLITE_ENABLE_COLUMN_METADATA=1" | |
make && make install | |
export PATH=$PATH:/opt/sqlite3.8.5/bin | |
export LD_LIBRARY_PATH=/opt/sqlite3.8.5/lib | |
echo "export PATH=$PATH:/opt/sqlite3.8.5/bin" >> ~/.bash_profile | |
echo "export LD_LIBRARY_PATH=/opt/sqlite3.8.5/lib" >> ~/.bash_profile | |
# # # # # # # # # # | |
# Install Sonarr # | |
# # # # # # # # # # | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Starting the installation of Sonarr itself" | |
echo "--------------------------------------------------------------------------------------------" | |
sleep 10 | |
# Create user | |
adduser nzbdrone | |
# Download / Extract Sonarr | |
wget "http://download.sonarr.tv/v2/master/mono/NzbDrone.master.tar.gz" -O /tmp/NzbDrone.master.tar.gz | |
tar zxvf /tmp/NzbDrone.master.tar.gz -C /opt/ | |
mv /opt/NzbDrone /opt/nzbdrone | |
chown nzbdrone:nzbdrone -R /opt/nzbdrone | |
# # # # # # # # # # | |
# Install service # | |
# # # # # # # # # # | |
wget "https://gist.githubusercontent.com/Nachtalb/0f71d70c5fa69bb7d498af39b4f13440/raw/nzbdrone.sh" -O /etc/init.d/nzbdrone | |
chmod +x /etc/init.d/nzbdrone | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Sonarr is now installed and can be run with \"$ service nzbdrone start\"" | |
echo "--------------------------------------------------------------------------------------------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh - | |
### BEGIN INIT INFO | |
# Provides: NzbDrone | |
# Required-Start: $local_fs $network $remote_fs | |
# Required-Stop: $local_fs $network $remote_fs | |
# Should-Start: $NetworkManager | |
# Should-Stop: $NetworkManager | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts instance of Sonarr | |
# Description: starts instance of Sonarr using start-stop-daemon | |
### END INIT INFO | |
############### EDIT ME ################## | |
# path to app | |
APP_PATH=/opt/nzbdrone | |
# options for app | |
APP_OPTS="-nobrowser" | |
# user | |
RUN_AS=nzbdrone | |
# path to mono bin | |
DAEMON=/usr/bin/mono | |
# Path to store PID file | |
PID_PATH=/var/run/nzbdrone | |
# User to start the program as | |
USER=nzbdrone | |
############### END EDIT ME ################## | |
get_pid () { | |
echo `ps auxf | grep $EXENAME | grep -v grep | awk '{print $2}'` | |
} | |
mkdir -p ${PID_PATH} | |
PID_FILE=${PID_PATH}/nzbdrone.pid | |
EXENAME=`basename ${APP_PATH}/NzbDrone.exe` | |
DESC=`basename ${APP_PATH}/NzbDrone.exe .exe` | |
LOG_FILE=/var/log/nzbdrone.log | |
PID=`get_pid` | |
ENV="LD_LIBRARY_PATH=/opt/sqlite3.8.5/lib PATH=/opt/sqlite3.8.5/bin:\$PATH" | |
test -x $DAEMON || { echo "$DAEMON must be executable."; exit 1; } | |
set -e | |
echo $PID > $PID_FILE | |
start () { | |
PID=`get_pid` | |
if [ -z "${PID}" ]; then | |
echo "Starting $DESC" | tee $LOG_FILE | |
rm ${PID_FILE} || return 1 | |
su - $USER -c "$ENV $DAEMON $APP_PATH\/$EXENAME $APP_OPTS" > $LOG_FILE 2>&1 & | |
PID=`get_pid` | |
echo $PID > $PID_FILE | |
else | |
echo "${DESC} already running." | tee $LOG_FILE | |
fi | |
} | |
stop () { | |
if [ -z "${PID}" ]; then | |
echo "Not running $DESC" | |
else | |
echo "Stopping $DESC" | tee $LOG_FILE | |
kill $PID | |
fi | |
} | |
restart () { | |
echo "Restarting $DESC" | tee $LOG_FILE | |
stop | |
sleep 3 | |
start | |
} | |
status () { | |
echo "Status $DESC" | |
tail $LOG_FILE | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart|force-reload) | |
restart | |
;; | |
status) | |
status | |
;; | |
*) | |
echo "Usage: `basename $0` {start|stop|restart|force-reload|status}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use with Radarr / Lidarr
The
nzbdrone.sh
init.d script can also be used for Radarr/Lidarr. Just replace thenzbdrone
strings with radarr/lidarr and create new users for the services:Lidarr Dependencies
Lidarr additionally wants
chromaprint-tools
which can be installed like so:Firewall
You may need to add Sonarr to your Firewall. With
iptables
this can be done with this: