mirror of
https://github.com/Radarr/Radarr.git
synced 2024-06-30 17:43:59 +02:00
Updated Autostart on Linux (markdown)
parent
24ddc29bfc
commit
c7629e1103
|
@ -74,121 +74,191 @@ exec mono --debug $DIR/Radarr.exe
|
||||||
sudo start radarr
|
sudo start radarr
|
||||||
|
|
||||||
|
|
||||||
## LSB init-script (Debian/Ubuntu)
|
## Init.d Script (Debian/Ubuntu)
|
||||||
|
# Autostart on Debian using init.d script
|
||||||
|
|
||||||
### Init File
|
The instructions for Ubuntu/Debian did not seem to work for Debian very well, and the pid got lost whenever Radarr was restarted via the web-ui, so I've included a working script here init.d script here. You'll need to have already created an radarr user.
|
||||||
The init.d file should be saved as `/etc/init.d/radarr`
|
|
||||||
|
|
||||||
```bash
|
**Create and edit the radarr init.d script**
|
||||||
|
|
||||||
#!/bin/bash
|
sudo nano /etc/init.d/radarr
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
**Paste the following, changing applicable variables**
|
||||||
# Provides: radarr
|
````bash
|
||||||
# Required-Start: $local_fs $network $remote_fs
|
|
||||||
# Required-Stop: $local_fs $network $remote_fs
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: radarr
|
|
||||||
# Description: Radarr
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
#! /bin/sh
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: Radarr
|
||||||
|
# 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 Radarr
|
||||||
|
# Description: starts instance of Radarr using start-stop-daemon
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
#set -e
|
############### EDIT ME ##################
|
||||||
|
# path to app
|
||||||
|
APP_PATH=/opt/Radarr
|
||||||
|
|
||||||
NAME=radarr
|
# user
|
||||||
DESC="Radarr"
|
RUN_AS=root
|
||||||
MONO=$(which mono)
|
|
||||||
|
|
||||||
DAEMON=/opt/radarr/Radarr.exe
|
# path to mono bin
|
||||||
DAEMONOPTS=""
|
DAEMON=$(which mono)
|
||||||
|
|
||||||
PIDDIR=/var/run/${NAME}
|
# Path to store PID file
|
||||||
PIDFILE=${PIDDIR}/${NAME}.pid
|
PID_FILE=/var/run/radarr/radarr.pid
|
||||||
|
PID_PATH=$(dirname $PID_FILE)
|
||||||
|
|
||||||
RUNASUSER=user
|
# script name
|
||||||
RUNASGROUP=group
|
NAME=radarr
|
||||||
RUNAS=$RUNASUSER:$RUNASGROUP
|
|
||||||
|
|
||||||
DATADIR=/home/$RUNASUSER/
|
# app name
|
||||||
|
DESC=Radarr
|
||||||
|
|
||||||
if ! [ -r ${DAEMON} ]; then echo "Can't read: ${DAEMON}" 2>&1; exit 1; fi
|
# startup args
|
||||||
if ! [ -x ${MONO} ]; then echo "Not executable: ${MONO}" 2>&1; exit 1; fi
|
EXENAME="Radarr.exe"
|
||||||
if ! [ -d ${DATADIR} ]; then echo "No such directory: ${DATADIR}" 2>&1; exit 1; fi
|
DAEMON_OPTS=" "$EXENAME
|
||||||
|
|
||||||
if [ ! -d ${PIDDIR} ]; then
|
############### END EDIT ME ##################
|
||||||
mkdir -p ${PIDDIR}; chown ${RUNASUSER}:root ${PIDDIR}; chmod 0750 ${PIDDIR};
|
|
||||||
|
RADARR_PID=`ps auxf | grep Radarr.exe | grep -v grep | awk '{print $2}'`
|
||||||
|
|
||||||
|
test -x $DAEMON || exit 0
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#Look for PID and create if doesn't exist
|
||||||
|
if [ ! -d $PID_PATH ]; then
|
||||||
|
mkdir -p $PID_PATH
|
||||||
|
chown $RUN_AS $PID_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $DATA_DIR ]; then
|
||||||
|
mkdir -p $DATA_DIR
|
||||||
|
chown $RUN_AS $DATA_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e $PID_FILE ]; then
|
||||||
|
PID=`cat $PID_FILE`
|
||||||
|
if ! kill -0 $PID > /dev/null 2>&1; then
|
||||||
|
echo "Removing stale $PID_FILE"
|
||||||
|
rm $PID_FILE
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
do_start() {
|
echo $RADARR_PID > $PID_FILE
|
||||||
RETVAL=1
|
|
||||||
if [ -e ${PIDFILE} ]; then
|
|
||||||
if ! kill -0 $(cat ${PIDFILE}) &> /dev/null; then
|
|
||||||
rm -f $PIDFILE
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_daemon_msg "Starting ${DESC}" "${NAME}"
|
case "$1" in
|
||||||
if pgrep -f "^${MONO} ${DAEMON}" > /dev/null 2>&1; then
|
|
||||||
log_progress_msg "(already running?)"
|
|
||||||
else
|
|
||||||
start-stop-daemon -q -d ${DATADIR} -c $RUNAS --start --background --make-pidfile --pidfile $PIDFILE --exec $MONO -- $DAEMON $DAEMON_OPTS
|
|
||||||
RETVAL=$?
|
|
||||||
fi
|
|
||||||
log_end_msg $RETVAL
|
|
||||||
}
|
|
||||||
do_stop() {
|
|
||||||
RETVAL=1
|
|
||||||
log_daemon_msg "Stopping ${DESC}" "${NAME}"
|
|
||||||
if ! pgrep -f "^${MONO} ${DAEMON}" > /dev/null 2>&1; then
|
|
||||||
log_progress_msg "(not running?)"
|
|
||||||
else
|
|
||||||
start-stop-daemon -q --stop --pidfile $PIDFILE --retry 15
|
|
||||||
RETVAL=$?
|
|
||||||
fi
|
|
||||||
log_end_msg $RETVAL
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
start)
|
||||||
do_start
|
if [ -z "${RADARR_PID}" ]; then
|
||||||
|
echo "Starting $DESC"
|
||||||
|
rm -rf $PID_PATH || return 1
|
||||||
|
install -d --mode=0755 -o $RUN_AS $PID_PATH || return 1
|
||||||
|
start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
|
||||||
|
else
|
||||||
|
echo "Radarr already running."
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
do_stop
|
echo "Stopping $DESC"
|
||||||
;;
|
echo $RADARR_PID > $PID_FILE
|
||||||
|
start-stop-daemon --stop --pidfile $PID_FILE --retry 15
|
||||||
status)
|
|
||||||
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
do_stop;
|
echo "Restarting $DESC"
|
||||||
do_start;
|
start-stop-daemon --stop --pidfile $PID_FILE --retry 15
|
||||||
|
start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
# Use LSB function library if it exists
|
||||||
|
if [ -f /lib/lsb/init-functions ]; then
|
||||||
|
. /lib/lsb/init-functions
|
||||||
|
if [ -e $PID_FILE ]; then
|
||||||
|
status_of_proc -p $PID_FILE "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||||
|
else
|
||||||
|
log_daemon_msg "$NAME is not running"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
# Use basic functions
|
||||||
|
if [ -e $PID_FILE ]; then
|
||||||
|
PID=`cat $PID_FILE`
|
||||||
|
if kill -0 $PID > /dev/null 2>&1; then
|
||||||
|
echo " * $NAME is running"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " * $NAME is not running"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
N=/etc/init.d/$NAME
|
N=/etc/init.d/$NAME
|
||||||
echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2
|
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
```
|
|
||||||
|
|
||||||
### Make init.d script executable
|
````
|
||||||
`sudo chmod +x /etc/init.d/radarr`
|
|
||||||
|
|
||||||
### Run insserv
|
**Make it executable**
|
||||||
`sudo insserv -v radarr`
|
|
||||||
|
|
||||||
Note: May need to run `sudo ln -s /usr/lib/insserv/insserv /sbin/insserv` first if insserv is not found.
|
sudo chmod +x /etc/init.d/radarr
|
||||||
|
|
||||||
## Start init.d script
|
**Update rc.d**
|
||||||
`sudo /etc/init.d/radarr start`
|
|
||||||
|
|
||||||
Note: The script by default runs as root. I suggest adding an radarr user (`useradd -m -d /var/lib/radarr --gid nogroup radarr`) and adjusting the script so that RUNASUSER=radarr & RUNASGROUP=nogroup.
|
sudo update-rc.d radarr defaults
|
||||||
|
|
||||||
|
**Create radarr user**
|
||||||
|
|
||||||
|
useradd radarr
|
||||||
|
|
||||||
|
**Start Radarr**
|
||||||
|
|
||||||
|
sudo service radarr start
|
||||||
|
|
||||||
|
**Security Note**
|
||||||
|
|
||||||
|
For security purposes, you can prevent this account from being logged into by editing the '/etc/passwd' entry for user radarr and changing it to '/bin/false' or /usr/sbin/nologin'. I've also removed the password from '/etc/shadow'. From researching, these both appear to be the manual ways to perform the '--disable-login' and '--disable-password' while creating a new user. Alternatively, you can accomplish this same task by creating a user with the '--system' option.
|
||||||
|
|
||||||
|
/etc/passwd 'radarr:x:1001:1001:Radarr Movie Media:/opt/Radarr:/bin/false'
|
||||||
|
/etc/shadow 'radarr:*:17124:0:99999:7:::'
|
||||||
|
|
||||||
|
Utilizing the '/usr/sbin/nologin' option will output what's seen below, when attempting to change to that user from root.
|
||||||
|
|
||||||
|
su - radarr
|
||||||
|
This account is currently not available.
|
||||||
|
|
||||||
|
Now, recursively edit the /opt/Radarr directory to only allow read, write and executable access to the directory owner and other users in the same group as this directory.
|
||||||
|
|
||||||
|
chmod 770 /opt/Radarr -R
|
||||||
|
|
||||||
|
Add the directory to the group 'radarr' and modify the owner to 'radarr'
|
||||||
|
|
||||||
|
chown radarr:radarr /opt/Radarr -R
|
||||||
|
|
||||||
|
If all is well, you should see the following outputs.
|
||||||
|
|
||||||
|
ls -ld /opt/Radarr/
|
||||||
|
drwxrwx--- 4 radarr radarr 4096 Nov 23 17:31 /opt/Radarr/
|
||||||
|
|
||||||
|
ls -la /opt/Radarr/Radarr.exe
|
||||||
|
-rwxrwx--- 1 radarr radarr 23552 Nov 6 13:05 /opt/Radarr/Radarr.exe
|
||||||
|
|
||||||
|
Test from a different user account to confirm these user and group permissions
|
||||||
|
|
||||||
|
su - test123
|
||||||
|
cd /opt/Radarr/
|
||||||
|
-su cd: /opt/Radarr/: Permission denied
|
||||||
|
|
||||||
## FreeBSD/FreeNAS
|
## FreeBSD/FreeNAS
|
||||||
https://raw.github.com/tofagerl/freedrone/master/nzbdrone
|
https://raw.github.com/tofagerl/freedrone/master/nzbdrone
|
||||||
|
|
Loading…
Reference in New Issue
Block a user