mirror of
https://github.com/Radarr/Radarr
synced 2025-02-28 08:55:51 +00:00
Destroyed Autostart on Debian (markdown)
parent
7a03078ef3
commit
efb142b321
1 changed files with 0 additions and 184 deletions
|
@ -1,184 +0,0 @@
|
||||||
# Autostart on Debian using init.d script
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
**Create and edit the radarr init.d script**
|
|
||||||
|
|
||||||
sudo nano /etc/init.d/radarr
|
|
||||||
|
|
||||||
**Paste the following, changing applicable variables**
|
|
||||||
````bash
|
|
||||||
|
|
||||||
#! /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
|
|
||||||
|
|
||||||
############### EDIT ME ##################
|
|
||||||
# path to app
|
|
||||||
APP_PATH=/opt/Radarr
|
|
||||||
|
|
||||||
# user
|
|
||||||
RUN_AS=root
|
|
||||||
|
|
||||||
# path to mono bin
|
|
||||||
DAEMON=$(which mono)
|
|
||||||
|
|
||||||
# Path to store PID file
|
|
||||||
PID_FILE=/var/run/radarr/radarr.pid
|
|
||||||
PID_PATH=$(dirname $PID_FILE)
|
|
||||||
|
|
||||||
# script name
|
|
||||||
NAME=radarr
|
|
||||||
|
|
||||||
# app name
|
|
||||||
DESC=Radarr
|
|
||||||
|
|
||||||
# startup args
|
|
||||||
EXENAME="Radarr.exe"
|
|
||||||
DAEMON_OPTS=" "$EXENAME
|
|
||||||
|
|
||||||
############### END EDIT ME ##################
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
echo $RADARR_PID > $PID_FILE
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
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)
|
|
||||||
echo "Stopping $DESC"
|
|
||||||
echo $RADARR_PID > $PID_FILE
|
|
||||||
start-stop-daemon --stop --pidfile $PID_FILE --retry 15
|
|
||||||
;;
|
|
||||||
|
|
||||||
restart|force-reload)
|
|
||||||
echo "Restarting $DESC"
|
|
||||||
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
|
|
||||||
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
````
|
|
||||||
|
|
||||||
**Make it executable**
|
|
||||||
|
|
||||||
sudo chmod +x /etc/init.d/radarr
|
|
||||||
|
|
||||||
**Update rc.d**
|
|
||||||
|
|
||||||
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
|
|
Loading…
Reference in a new issue