-
Notifications
You must be signed in to change notification settings - Fork 44
Archlinux
This guide accomplishes the same thing as the other guide but instead of Ubuntu as the OS, this guide uses Archlinux as the OS.
I use Archlinux now personally and highly recommend it.
This guide will help you setup the ultimate automatic torrent downloading solution. You will setup and configure, on Archlinux, rTorrent+ruTorrent, Sonarr, Radarr, Lidarr and Caddy as a reverse proxy for all these. This guide assumes that you would like to be able to access all these interfaces from anywhere on the Internet (using a login form secured with an SSL certificate) and that you have a domain name you will use. If you don't have a domain name yet see the section called Domain Name and Dynamic DNS at the end of this guide. Your domain name should alredy be set up and pointing to your external ip address which in turn should be forwarding to your Archlinux box. The following ports need to be open in your firewall and forwarded to your Archlinux box: 80 and 443 for access to the web interfaces. The port that rTorrent is configured to use needs to be open, in this guide its 49155 by default.
We will configure Sonarr, Radarr and Lidarr to use the rTorrent xmlrpc interface so they can add torrents directly. When the downloads finish, they will create a hard link to a final TV directory, AND we can continue to seed with the original file in the download directory with no problems. Even when we delete the file in the download directory, it won't affect the other hard link in the place where Sonarr placed it.
We'll also create some Ratio Rules that will seed a torrent of a specific tracker to a specified ratio and then automatically delete the torrent. So you won't have to monitor your torrents and manually clean them up when they've seeded enough, they will automatically seed to the perfect amount and then delete themselves.
The end result will be: you add a show to Sonarr, Sonarr will automatically search for new episodes and add it to rTorrent. The torrent will be downloaded in rTorrent and as soon as the download is complete, Sonarr will create a hard link of the file, rename it and place it in a nice, organized TV Shows folder. Meanwhile rTorrent will still be seeding the original file until it reaches the defined ratio, and then will auto delete the torrent and the original file from the download dir. 100% automated TV downloading! Radarr does the same thing for movies. Lidarr does the same thing for music.
You will probably want to download other torrents outside of Sonarr, Radarr and Lidarr. We will use the ruTorrent plugins autotools, ratio & extratio to accomplish what we want. The way these plugins work is best described by an example:
Say you have a directory /torrent for your torrent downloads. What you would do is create three sub dirs in that directory called watch, download and complete. Inside these directories will contain a mirrored directory structure for the different categories of torrents you download. So your structure might look like this:
So if you drop a torrent into /torrent/watch/tv, the torrent download is started in /torrent/download/tv. Also a label is automatically applied to the torrent based on the directory: in this example our torrent would receive the label tv. Once the torrent is finished downloading, a hard link will be created in /torrent/complete/tv. A hard link means that a duplicate file is made, but it shares the same data as the original. This is better than copying because it is instant and you don't have to duplicate the data on your hard drive. You can use the watch folders for other torrents you might download manually.
Login as your user then execute these commands one line at a time.
Update Archlinux
sudo pacman -Syu
Create a group named media. All the apps will be part of this group.
sudo groupadd --system media
sudo usermod -aG media $USER
Install yay package manager and Prereqs
sudo pacman -S --noconfirm git
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si --noconfirm
cd ~
sudo rm -r yay
yay --editor vim --save
yay -S --noconfirm zip unzip rar mediainfo ffmpeg php-fpm php-geoip rtorrent caddy xcaddy-bin
Create the webserver root for Caddy
sudo mkdir -p /var/www/public
Create and change directory to where you are going to download all your torrents to. For an example, this guide will use /data.
On your server, you will probably have a large chunk of storage configured on a certain mount point. The mount point is where you will want to change directories to.
It's important to realize that /data is just an example path that this guide uses, therefore, whenever you see /data in this guide be sure to change it to what the path to your storage actually is.
sudo mkdir /data
cd /data
Then execute this command which will create the folder structure I illustrated earlier:
sudo mkdir -p torrent/{complete/{movie/radarr,music/lidarr,tv/sonarr,game,book,software,other},download/{movie/radarr,music/lidarr,tv/sonarr,game,book,software,other},watch/{movie/radarr,music/lidarr,tv/sonarr,game,book,software,other}} Media/{Movies,'TV Shows',Music}
Make your user the owner of these folders and set the default permissions by executing these commands:
sudo chown -R $USER:media /data/*
sudo chmod -R 775 /data/*
or whatever your path is.
Then run the following to set the group ID and the default group ACLs on the data folders:
sudo find /data/* -type d -exec chmod g+s {} +
sudo find /data/* -type d -exec setfacl -m default:group::rwX {} +
Edit /etc/php/php.ini and search for the line that contains date.timezone =. Set the value for your timezone from PHP Timezones. Mine looks like:
date.timezone = America/Denver
Edit /etc/php/php-fpm.d/www.conf and change group and listen.group to:
group = media
listen.group = media
Search for env[PATH] and uncomment the line by deleting the semicolon:
env[PATH] = /usr/local/bin:/usr/bin:/bin
Edit /etc/php/conf.d/geoip.ini and uncomment the line by deleting the semicolon:
extension=geoip.so
sudo usermod -aG media http
sudo usermod -aG media caddy
sudo systemctl enable --now php-fpm.service
sudo mkdir -p /etc/caddy/auth/local
sudo chown -R caddy /etc/caddy/auth/local/
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/Caddyfile -o /etc/caddy/Caddyfile
Edit /etc/caddy/Caddyfile and change the 4 instances of this to your actual domain name.
yourdomain.com
And change this to your actual email address.
Run:
sudo systemctl edit caddy.service
Paste this into the file and save it:
[Service]
Group=media
ReadWritePaths=/etc/caddy/auth/local
Run:
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/update-caddy -o /usr/local/bin/update-caddy
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/caddy.hook -o /usr/share/libalpm/hooks/caddy.hook
sudo chmod +x /usr/local/bin/update-caddy
sudo update-caddy
sudo systemctl enable --now caddy.service
journalctl -u caddy.service | grep webadmin
This will return the line that looks like this:
{"level":"info","ts":1657896017.8892446,"logger":"security","msg":"created default admin user for the database","username":"webadmin","email":"[email protected]","secret":"607a7d42-c736-4b7b-a89b-e712ca15316d","roles":["authp/admin"]}
The "username" and "secret" are the credentials you will use to login initially.
Browse to https://yourdomain.com/auth/settings/password and login with those credentials. Type in the current default password and then set a new password for your user. (We'll change the username later.)
sudo systemctl stop caddy.service
Edit /etc/caddy/auth/local/users.json and change
"username" to the username you want to login with
"address" to your email address
"domain" to the domain of your email address.
sudo systemctl start caddy.service
From now on, you will login with the username you set in the users.json file and the password you set earlier.
Create rtorrent user and directories
sudo useradd -r -m -d /var/lib/rtorrent -U -G media -s /sbin/nologin rtorrent
sudo chmod 755 /var/lib/rtorrent
sudo mkdir -p /var/lib/rtorrent/session
sudo mkdir -p /etc/rtorrent
Get rTorrent config file:
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/rtorrent.rc -o /etc/rtorrent/rtorrent.rc
Edit /etc/rtorrent/rtorrent.rc and look for where it says
/CHANGE/THIS/PATH
for the directory path and edit the path for your setup. In our example, the directory path is the download directory we created previously, /data/torrent/download. Look for
HTPASSWD_WEBAUTH_USER
at the bottom and change it to the username you configured earlier in the caddy users.json file. Change any other random options that you want.
sudo chown -R rtorrent:media /var/lib/rtorrent/*
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/rtorrent.service -o /etc/systemd/system/rtorrent.service
sudo systemctl enable --now rtorrent.service
The script update-rutorrent will install ruTorrent and plugins automatically. Then whenever you run it again it will update ruTorrent and plugins that have updates.
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/update-rutorrent -o /usr/local/bin/update-rutorrent
sudo chmod +x /usr/local/bin/update-rutorrent
sudo update-rutorrent
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/plugins.ini -o /var/www/rutorrent/conf/plugins.ini
Edit /var/www/rutorrent/conf/plugins.ini
Edit to disable the plugins you don't want to use. You can leave it as it is to use the plugins that I use. The ones you have to keep are autotools, ratio, extratio and throttle.
Edit /var/www/rutorrent/conf/config.php
Change:
$saveUploadedTorrents = false;
Change $topDirectory to the top directory where your torrents are downloaded. In our example:
$topDirectory = '/data/';
Comment out existing $scgi_port and $scgi_host. Uncomment the ones below and change:
$scgi_port = 0;
$scgi_host = "unix:///var/lib/rtorrent/rtorrent.sock";
Change:
$profileMask = 0775;
Edit /var/www/rutorrent/plugins/autotools/conf.php
The $autowatch_interval variable is how often in seconds it looks in the watch folders for new torrent files. I changed mine to:
$autowatch_interval = 60;
Edit /var/www/rutorrent/plugins/unpack/conf.php
Set the following variable values:
$deleteAutoArchives = true;
$unpackToTemp = true;
Set permissions on share directory
sudo chown -R http:media /var/www/rutorrent/share/*
sudo find /var/www/rutorrent/share/* -type d -exec chmod 775 {} \;
sudo find /var/www/rutorrent/share/* -type f -exec chmod 664 {} \;
sudo systemctl restart rtorrent.service
yay -S --noconfirm sonarr
sudo usermod -aG media sonarr
sudo systemctl enable --now sonarr.service
sudo systemctl stop sonarr.service
Edit /var/lib/sonarr/config.xml and change:
<UrlBase>/sonarr</UrlBase>
sudo systemctl start sonarr.service
yay -S --noconfirm radarr
sudo usermod -aG media radarr
sudo systemctl enable --now radarr.service
sudo systemctl stop radarr.service
Edit /var/lib/radarr/config.xml and change:
<UrlBase>/radarr</UrlBase>
sudo systemctl start radarr.service
yay -S --noconfirm lidarr
sudo usermod -aG media lidarr
sudo systemctl enable --now lidarr.service
sudo systemctl stop lidarr.service
Edit /var/lib/lidarr/config.xml and change:
<UrlBase>/lidarr</UrlBase>
sudo systemctl start lidarr.service
First browse to https://yourdomain.com/rutorrent
You will be presented with the login window:
Login with the username and password you created earlier.
Click on the gear cog to enter the settings.
In Autotools enable all the options and browse to your complete and watch directories. Also, be sure to select Hard Link for the operation type. Enter the following in the Automove filter box:
/^(?!tv\/sonarr$|movie\/radarr$|music\/lidarr$).*$/
In History I only check Deletion. This is nice because Sonarr could download a torrent, seed it to 2.0, and delete it all while you are sleeping. So the History plugin will let you see a record of when it was deleted and what your ratio was, just for your sanity:
In Unpack check enable autounpacking:
In Ratio Groups set up a default group and a Sonarr group:
Click ok. Then click on the wrench/screwdriver next to the gear cog and click on Ratio Rules. Set up a rule for Sonarr:
You can setup another Ratio Rule for Radarr downloads too, if you want. Alternatively, you could set up ratio rules for each individual tracker by selecting "One of torrent's tracker URLs contain" from the drop down list.
Now when you add a torrent you just click on the directory button and choose which category it is. Then it will automatically receive that label and it will download to the proper directory.
Now browse to https://yourdomain.com/sonarr
Click on Settings and you'll see the Media Managment tab.
Move the switch to Shown next to Advanced Settings. Switch Rename Episodes to Yes. Set the renaming formats to the way you want. Mine are set to conform to Plex naming standards.
Enable Delete empty folders and Ignore Deleted Episodes.
Change the File chmod mask to 0664 and the Folder chmod mask t0 0775 and the chown Group to media.
Click the Save button.
Click on the Indexers tab.
Click the plus button to add your desired providers. Configure the provider with the info it asks for, which you will usually find in your respective rss feed url for the tracker. If your tracker does not support search, I would suggest checking out Jackett. It is a separate webapp that adds search capabilities to many trackers. I haven't used it personally, but I've heard it works well.
Click on the Download Client tab.
Click the plus sign and click rTorrent. Use these settings. In our example the Directory value would be /data/torrent/download/tv/sonarr.
Click on the General tab.
Turn Open browser on start to No. Change Log Level to Debug.
Click on Series -> Add Series -> Import Existing Series On Disk
Browse to your TV Shows folder. In our example it would be /data/Media/TV Shows/
Click the close button.
Now browse to https://yourdomain.com/radarr
Click on Settings and you'll see the Media Managment tab.
Move the switch to Shown next to Advanced Settings. Switch Rename Movies to Yes. Set the renaming formats to the way you want. Mine are set to conform to Plex naming standards.
Enable Ignore Deleted Movies. Set File chmod mask to 0664 and Folder chmod mask to 0775 and chown Group to media.
Click the Save button.
Click on the Indexers tab.
Click the plus button to add your desired providers. Configure the provider with the info it asks for, which you will usually find in your respective rss feed url for the tracker. (Required Flags is optional. My setting makes it so it will only download approved torrents from PTP.) If your tracker does not support search, I would suggest checking out Jackett. It is a separate webapp that adds search capabilities to many trackers. I haven't used it personally, but I've heard it works well.
Click on the Download Client tab.
Click the plus sign and click rTorrent. Use these settings. In our example the Directory value would be /data/torrent/download/movie/radarr.
(Optional) Click on the Custom Formats tab.
Custom formats are a very powerful advanced feature. You can use them to fine tune how you search for releases. This example is for PTP.
Click the plus button and click Custom. These settings match any release that is not labeled Scene by PTP.
Add another Custom format. These settings match Golden Popcorn releases from PTP.
(Optional cont.) Click on the Profiles tab.
Click on the Profile you plan to use.
Set a Custom Format Cutoff and set the order of the Custom Formats (higher in the list is more preferred). This example creates a profile that will download a scene release if it's the only release available, will upgrade to a non-scene release if/when it becomes available, and will upgrade to the Golden Popcorn release if/when it becomes available.
Click on the General tab.
Turn Open browser on start to No. Change Log Level to Debug.
Click on Add Movies -> Bulk Import Movies
Browse to your Movies folder. In our example it would be /data/Media/Movies/
Click Ok then click the green check mark.
Now browse to https://yourdomain.com/lidarr
Click on Settings and click the Media Managment tab.
Check Rename Tracks. Set the renaming formats to the way you want.
Check Delete empty folders.
Check Ignore Deleted Tracks.
Set File chmod mask to 0664 and Folder chmod mask to 0775 and chown Group to media.
Click the Save Changes button.
Click on the Indexers tab.
Click the plus button to add your desired providers. Configure the provider with the info it asks for, which you will usually find in your respective rss feed url for the tracker. If your tracker does not support search, I would suggest checking out Jackett. It is a separate webapp that adds search capabilities to many trackers. I haven't used it personally, but I've heard it works well.
Click on the Download Clients tab.
Click the plus sign and click rTorrent. Use these settings. In our example the Directory value would be /data/torrent/download/music/lidarr.
Click on the General tab.
Uncheck Open browser on start. Change Log Level to Debug.
Click on Artist -> Import Existing Artist(s) and click Start Import
Browse to your Music folder. In our example it would be /data/Media/Music/
Click Ok.
Now that everything is configured you can add TV shows to Sonarr and movies to Radarr and watch the magic. You can update rTorrent, Sonarr, Radarr and Caddy using yay. You can keep ruTorrent up to date by running the update-rutorrent script again.
Enjoy 100% automated TV and movie downloading!
These are some additional things you can do that make this setup even better.
Sonarr, Radarr and Lidarr have the ability to notify you when they start a download and finish a download. My favorite provider, and the one I use, is Pushover. Pushover supports both iOS and Android and is simply a one time purchase rather than a monthly subscription.
Click Settings -> Connect. Check Pushover (or your provider of choice) and configure the settings.
Now you will receive a notification when ever a show or movie starts and finishes downloading.
Now that everything is setup, you'll probably find yourself wanting to access these interfaces from your mobile device. I have an iPhone, so all the screenshots will be from that, but since these are all webapps, this should work from any device.
A mobile plugin was created by zebraxxl, but it appears he has abandoned it. I have created a fork of rutorrentMobile and made a number of enhancements.
The update-rutorrent script is set to automatically install this plugin so it should already be installed. Now from your mobile browser, browse to https://yourdomain.com/rutorrent and you should see the mobile interface for rutorrent. Add to your mobile home screen to create a web app.
Sonarr, Radarr and Lidarr have a responsive design that is very functional on a mobile device. From your mobile browser, browse to https://yourdomain.com/sonarr and you should see the interface for Sonarr. Add to your mobile home screen to create a web app. Do the same for Radarr and Lidarr.
Resilio Sync is like Dropbox, but instead of syncing to the cloud first, the folders sync from Peer to Peer. We can set up Resilio Sync on our watch directory so that we are able to drop .torrent files into those directories from any device. On iOS for instance, you can download a .torrent file in Safari and then use the Open with... option to place the file in one of the watch folders, depending on the category. Then Resilio Sync will sync that file to all the Peers connected to it, includng our Archlinux server, which means the .torrent file will be downloaded to the correct watch folder and picked up by ruTorrent immediately!
yay -S --noconfirm rslsync
sudo usermod -aG media rslsync
sudo systemctl edit rslsync.service
Add this to the file and save:
[Service]
Group=media
UMask=0002
sudo systemctl enable --now rslsync.service
Now browse to https://yourdomain.com/sync
Fill in a username only and click Continue.
Fill in a name, agree to the terms and click the Get started button.
Click the + button and Standard Folder button:
Browse to your watch directory. In our example it is /data/torrent/watch/. Then click the Open button.
Now click the 3 dots menu next to the folder and click Preferences:
Configure it how you want. This is how I have mine configured.
Now you can click the Share button and use the Key to add your Desktop client or the QR code to add the mobile client.
When you download a torrent click the Open in > Copy to Sync option and then the Sync app will launch.
Just browse to the correct watch folder, based on the category of torrent, and then it will sync back to your Archlinux server and be picked up and started immediately by ruTorrent and receive the correct label based on the folder you placed it in.
In order to view all your media you will want to use a media server. My media server of choice is Plex and we can run Plex Media Server right on our Archlinux box that contains all our media.
yay -S --noconfirm plex-media-server-plexpass
sudo usermod -aG media plex
sudo systemctl enable --now plexmediaserver.service
From a computer on the same network as your Archlinux server, browse to http://archlinux.server.local.ip:32400/web and login with your Plex credentials.
If your Archlinux server is on a different network (in the cloud for example), you'll first need to set up an SSH tunnel so that you can access things as if they were local. This is only necessary for the initial setup.
Follow the instructions here at the bottom of the page where it says "On a Different Network" to set up the ssh tunnel.
Name the server and click Next.
Click Add Library.
Click Moves and click Next.
Browse to your Movies folder. In our example it was /data/Media/Movies
Click Add Library again and select TV Shows.
Browse to your TV Shows folder. In our example it was /data/Media/TV Shows
Click Next and then click Done.
Click the settings button in the top right and click the Server section. Click on the Library tab and click the Show Advanced button. Enable Update my library automatically. Enable thumbnail generation when media is added.
Click on Scheduled Tasks and enable all the tasks.
Edit any other settings you might want then restart Plex Media Server.
sudo systemctl restart plexmediaserver.service
Now that Plex Media Server is running you can access your media using one of the Plex clients and stream your media where ever you want! Plex will attempt to use UPnP to automatically configure your firewall to allow access remotly. If your router/firewall does not support that, you will need to manually open port 32400. Then in the Server settings enable Manually specify public port in the Remote Access settings.
Tautulli is a 3rd party application that you can run alongside your Plex Media Server to monitor activity and track various statistics. Most importantly, these statistics include what has been watched, who watched it, when and where they watched it, and how it was watched. You can also use it for notifications for recently added items to Plex libraries and start of playback, etc.
yay -S --noconfirm tautulli
sudo systemctl enable --now tautulli.service
sudo systemctl stop tautulli.service
Edit /var/lib/tautulli/config.ini and change:
http_root = /tautulli
sudo systemctl start tautulli.service
Now browse to https://yourdomain.com/tuatulli
Click Next to start the wizard.
Login to your Plex account and click Next.
Select your Plex instance on it's local IP Address and Click Verify. Then click Next.
Click Next through the other prompts and finally click Finish.
Click on the gear cogs in the top right to enter settings. Click the Show Advanced button and then click on the Web Interface menu.
Uncheck Launch Browser on Startup and check Enable HTTP Proxy. Click the Save button. (don't restart if it ask you to)
Click on the Plex Media Server Menu.
In the Logs Folder box paste in /var/lib/plex/Plex Media Server/Logs/. Check Monitor Plex Updates and choose your Update Channel and choose Linux - Fedora 64-bit for the Release. Check Monitor Plex Remote Access.
Click on the Notifications & Newsletter menu.
Check Group Notifications by Season or Album and Group Notifications by TV Show or Artist.
Click the Notification Agents menu and click Add new notification agent.
Configure your Pushover (or other provider) settings. Then click the Triggers tab.
Check the boxes for the events you want notifications for. I check Playback Start, Buffer Warning, User Concurrent Streams, Recently Added, Plex Update Available, Tautulli Update Available.
Click the Test Notifications tab.
Click the Test button and confirm that you receive the test notification and then click Save.
To be able to access your resources remotely and secured with an SSL certificate, you will need to set up a domain name. You'll need to purchase a domain name from a registrar and then configure the DNS records to point to your IP address. Most often, with residential ISP accounts, you will have a dynamic IP address that changes often. In order to configure a domain name to point to your IP address you will need to use a dynamic dns service that will update your DNS records whenever your IP address changes. The registrar I chose, Namecheap, is inexpensive and also includes a free dynamic dns service. In this section I'll show you how to purchase your domain name and configure the dynamic dns client to run on the Archlinux machine.
Browse to https://www.namecheap.com and search for a domain name you want in the search box. Once you find a domain you want that is available, continue on to purchase the domain name.
Once you have your domain name purchased, follow the instructions here to enable Dynamic DNS on your account and get your Dynamic DNS Password. Then follow the instructions here to create the host record that will be updated dynamically.
Now we'll install the dynamic DNS client on the Archlinux machine.
yay -S --noconfirm ddclient
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/ddclient.conf -o /etc/ddclient/ddclient.conf
Edit /etc/ddclient/ddclient.conf
Change the login and password fields to be your domain name and your Dynamic DNS Password that we got earlier. For more information on this config file, check out this Knowlagebase Article.
sudo systemctl enable --now ddclient.service
The dynamic dns client should be working now and will automatically update your DNS records whenever your IP address changes. Check your DNS records in Namecheap to make sure that it has automatically added a DNS record.