Skip to content

Instantly share code, notes, and snippets.

@rlambert27
Last active April 4, 2022 01:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rlambert27/fbe1532b25c3898211d2bb3f55a91c86 to your computer and use it in GitHub Desktop.
Save rlambert27/fbe1532b25c3898211d2bb3f55a91c86 to your computer and use it in GitHub Desktop.
Guide for getting Plex, SickRage, CouchPotato, Transmission, PlexPY, OpenVPN (PIA) up and running on dual rpi's or headless ubuntu
Setup guide for
- Static IPs for NAS and rpi3deluge
- UPnP and port forwarding - TO BE REVISED (is UPnP secure?)
- Ubuntu install
- Install Plex Media Server on ubuplex
- rpi3deluge with fresh install
-- Mount NAS drives to rpi3deluge or ubuplex
-- Mount ubuntu drive on rpi3
- Plex Media server (ubuplex)
- CouchPotato (ubuplex)
- SickRage (ubuplex)
- PlexPY (ubuplex)
- Install OpenVPN on rpi3deluge
- Deluge (rpi3deluge)
- Rasplex (rpi3rasplex)
- Backup rpi3deluge SD card
- Add dynamic DNS setup for easy external access
- Install PlexRequests
- Useful linux commands for rpi's or ubuntu
IMPORTANT: For any installation below make sure to run << sudo apt-get update >> followed by << sudo apt-get upgrade >> before installing anything.
- Setup static IPs for NAS and rpi3
Login to Google Wifi application and find the MAC addresses for the rpi's, NAS and Plex media server PC. Now go to "Network settings > Advanced networking > DHCP IP reservations".
rpi3deluge - B8:27:EB:46:3F:A9 - 192.168.86.60
MBLD-STRG - 00:90:A9:BD:54:76 - 192.168.86.50
ubuplex - 4C:CC:6A:D2:52:C1 - 192.168.86.75
Router reboot is not be required. Have your device reboot will force router to assign new IP.
- UPnP and port forwarding - TO BE REVISED (is UPnP secure?)
UPnP is on by default with Google Wifi router. To be revised later to see if this is necessary.
For port forwarding go to "Network settings > Advanced networking > Port Forwarding". We'll need to add 4 entries in this section for SickRage, CouchPotato, Plex and Deluge. This will allow us to remotely access our software so we can do stuff while not at home. It's important that all 4 services are password protected otherwise bad shit will happen! DO NOT use auto-login or no-login on any of these services. I repeat, BAD SHIT WILL HAPPEN if you do!
So to setup see article (https://support.google.com/wifi/answer/6274503?hl=en):
Port from - SickRage = 8081 / CouchPotato = 5050 / Plex = 32400 / Deluge = 51413
IP address - SickRage, CouchPotato and Plex all use 192.168.86.75 / Deluge will use 192.168.86.60
Good to go, we can make sure these are working later by testing from a remote location. You can grab your current IP from https://www.whatismyip.com/ which I bookmarked in FF and from work I can put in the IP using the port and voilà, remote access!
- Ubuntu install
This section is for the Ubuntu install if you're using that instead of the rpi3. I purchased a headless ubuntu box at Canada Computers for 500$. The CPU is the most important part, only need 8GB of memory and get an SSD HDD. Any shit video card will do because it's only for the setup anyway. Get heat sink for the CPU so you don't hear the fan.
Ubuntu Server 16.04.2 LTS : https://www.ubuntu.com/download/server
Install guide : https://www.ubuntu.com/download/server/install-ubuntu-server
Create bootable Ubuntu USB drive : https://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows
Issues? Yes :-( For some reason the install guide sucks if it doesn't have a CD-ROM. Took me an hour to figure out that my mouse plugged in was causing issues (don't need a mouse anyway). Also check this (https://askubuntu.com/questions/593002/fail-to-install-ubuntu-server-14-04-64bit-lts-from-usb-drive), I plugged my USB key into the same port that had the mouse and suddenly it worked.
We also need to install rar/unrar for CouchPotato and SickRage to extract RAR files. Follow this guide : https://www.kjbweb.net/install-rar-unrar-ubuntu-16-04-lts-xenial/
Make sure you don't forget your superuser login/password otherwise I think you're SOL.
- Install Plex Media Server on ubuplex
Follow guide here : https://www.htpcguides.com/install-plex-media-server-ubuntu-16-x-and-later/
Alternate guide : https://www.linode.com/docs/applications/media-servers/install-plex-media-server-on-ubuntu-16-04
On the HTPC guide switch the first steps for the ones in the linode guide:
<< wget https://downloads.plex.tv/plex-media-server/1.5.6.3790-4613ce077/plexmediaserver_1.5.6.3790-4613ce077_amd64.deb >> (check the URL on Plex downloads for the latest version).
<< sudo dpkg -i plexmediaserver*.deb >>
<< sudo systemctl enable plexmediaserver.service >>
Now continue on HTPC guide from "Fix Plex Permission Issues". To fix permissions use Option 2 but I run as root/root.
Check the Plex local URL to see if it worked.
To update PMS use this guide : https://brianli.com/how-to-update-plex-media-server-on-ubuntu-be002870fdc5
- rpi3deluge with fresh install
Follow guide here : https://pimylifeup.com/noobs-raspberry-pi/
Alternate guide : http://lifehacker.com/the-always-up-to-date-guide-to-setting-up-your-raspberr-1781419054
Next we need rpi3 to boot to command line instead of GUI and set gpu_mem to 16 and GUI is not needed.
Follow guide here : https://www.modmypi.com/blog/boot-to-command-line-raspbian-jessie
Also enable SSH access before rebooting and set correct locales.
The Raspberry Pi default login for Raspbian is username pi with the password raspberry. CHANGE PASSWORD!
-- Mount NAS drives to rpi3(deluge) or ubuplex
Latest : https://gordonlesti.com/mount-ext4-usb-flash-drive-to-raspberry-pi/ (mounting the ext4 USB HDD to rpi3deluge)
Once done intall SAMBA : https://www.raspberrypi.org/magpi/samba-file-server/
Don't forget to update /etc/exports so that the drive is available on other Linux systems. First install nfs-kernel-server.
****** The rest here doesn't apply anymore I think ******
We need to install cifs-utils for the rpi3-deluge.
Now run << sudo apt-get install cifs-utils >> (make sure it's up to date).
Now we've got cifs-utils installed. Now run this command for making directory << sudo mkdir /mnt/plexnas >>.
Now let's edit fstab so it automounts when booting up. This is what is required in /etc/fstab (<< sudo nano /etc/fstab >>), follow guide here : https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=22957 (see post by lewmur » Thu Nov 15, 2012 4:37 pm)
CIFS-UTILS:
//192.168.86.50/FLMOVIES /mnt/plexnas/movies cifs guest 0 0
//192.168.86.50/KIDSMOVIES /mnt/plexnas/kidsmovies cifs guest 0 0
//192.168.86.50/FLTVSHOWS /mnt/plexnas/tvshows cifs guest 0 0
//192.168.86.50/FLMUSIC /mnt/plexnas/music cifs guest 0 0
Add later after the ubuntu drive has been mounted:
192.168.86.75:/mnt/downloads /mnt/downloads nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
****** The rest above here doesn't apply anymore I think ******
Follow this guide : https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-16-04 - This is used to setup the drive export on Ubuntu so that rpi3 can write to that drive.
Now we need to edit raspi-config if you haven't already set "Wait for network". The reason is that /etc/fstab will run before network is ready and drives will not be auto-mounted. To manually mount you can use command << sudo mount -a >>. To avoid this be sure that the network is ready during the boot, there is an option Wait for Network at Boot in raspi-config.
Now run << sudo raspi-config >> to get to raspberry configuration.
Set the Wait for Network at Boot option to Slow wait for network connection before completing boot and reboot. Of course the boot up time may well be affected but if that's not critical, this method can be used.
Now we need to reboot so run << sudo reboot >>
Now test Plex Media Server by going to : 192.168.86.75:32400/web/
-- Mount ubuntu drive on rpi3
Follow this guide here : https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-16-04
Once done go back to rpi3deluge and edit fstab to add the NFS share for the downloads. Worked great!
At this point we can also setup ubuntu to share drives to windows, I use it for copying sometimes although doing it straight from command line is faster.
Guide : https://help.ubuntu.com/community/How%20to%20Create%20a%20Network%20Share%20Via%20Samba%20Via%20CLI%20%28Command-line%20interface/Linux%20Terminal%29%20-%20Uncomplicated%2C%20Simple%20and%20Brief%20Way%21
- Plex Media server (ubuplex)
Now that we can access Plex Media Server (PMS) we can do the initial configuration. Change the name (rlambert27-rpi3plex).
Now add libraries. I used (Movies, Kids movies, Films français, TV shows, Séries télé, Documentaries and Cartoons). Always keep english and french in different folders so you can add to Plex in correct language.
Depending on how much stuff you have to add this is a good time for a break while Plex scans and catalogs everything.
If you had friends in your account you'll need to go update their account to share your libraries.
- CouchPotato
CouchPotato is strictly used to "snatch" movie torrents and send them to deluge for download.
Follow guide here : https://www.htpcguides.com/install-couchpotato-raspberry-pi-raspbian/
Now test CouchPotato by going to : 192.168.86.75:5050/home/
You can now login and go through all the configuration options.
- SickRage
SickRage is strictly use to "snatch" TV torrents and send them to deluge for download.
Follow guide here (rpi3) : https://www.htpcguides.com/install-sickrage-raspberry-pi-usenet-torrent-tv/
Follow guide here (ubuntu) : https://github.com/SickRage/SickRage/wiki/Sickrage-installation-Debian-Ubuntu-14-15-16
On Ubuntu you need to install the packages first before running the auto-script, otherwise the guide works great! Also if you use the auto-script, go into << cd /etc/systemd/system/ >> and modify the << sudo nano sickrage.service >> file to run as root. Then run << sudo systemctl daemon-reload >> to reload the config file and then << sudo systemctl restart sickrage >>.
For rpi3 install when you run << wget http://sourceforge.net/projects/bananapi/files/unrar_5.2.6-1_armhf.deb >> put << sudo >> in front otherwise it might not work.
- PlexPY
I did this on rpi3 but don't remember which guide I used, I forgot to update this guide. It should be the same as the Ubuntu one though:
Follow guide here (ubuntu) : https://www.htpcguides.com/install-plexpy-ubuntu-plex-monitoring/
- Install OpenVPN on rpi3tra (p9087814)
Now on the rpi3deluge we need to install OpenVPN and PIA. I'm using a wired connection. I first tried to use a WiFi setup but I had to format eveyrthing and start over. I'm assuming the guides only work with wired setups. Follow guide here : https://www.htpcguides.com/autoconnect-private-internet-access-vpn-boot-linux/
Small difference is to rename the US East.ovpn to USEast.ovpn file. Run:
<< cd /etc/openvpn >>
<< sudo mv US\ East.ovpn USEast.ovpn >>
Also I had to manually update /etc/resolv.conf and /etc/openvpn/update-resolv-conf files with the PIA nameservers and the third option as a Google DNS:
/etc/openvpn/update-resolv-conf file:
foreign_option_1='dhcp-option DNS 209.222.18.222'
foreign_option_2='dhcp-option DNS 209.222.18.218'
foreign_option_3='dhcp-option DNS 8.8.8.8'
/etc/resolv.conf file:
# Generated by resolvconf
nameserver 209.222.18.222
nameserver 209.222.18.218
In the USEast.ovpn file don't use us-east.privateinternetaccess.com, use the IP instead. Ping the server and use the IP. If I used us-east.privateinternetaccess.com my OpenVPN service would not start. I should eventually investigate why!
To test your IP you can use the following command : curl ipecho.net/plain; echo
Alternate guide that may work but untested: https://gist.github.com/superjamie/ac55b6d2c080582a3e64
- Deluge (rpi3deluge)
Deluge is used to download all the torrents behind the PIA VPN installed in the previous step.
Follow guide here : https://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/
Once everything is setup you can check what your deluge is exposing as an IP by going to : https://ipleak.net/ (follow the instructions in section "Torrent Address detection").
- Rasplex (rpi3rasplex)
Got a TV that isn't SMART? Turn your rpi3 into a smart TV with Rasplex, follow this guide:
https://www.linux.com/learn/turn-raspberry-pi-3-powerful-media-player-rasplex
Took literally 5 minutes and my TV was soo much smarter!
- Backup rpi3deluge/rpi3rasplex SD card
Now, everything is great! How many hours did you spend on this? The first time I did this I must have spent over 40-45 hours getting everything working correctly. Don't make this wasted time by not backing up your SD card.
Follow guide here : http://lifehacker.com/how-to-clone-your-raspberry-pi-sd-card-for-super-easy-r-1261113524
If anything happens or SD card becomes corrupted you've got a clean install ready to go! Although I haven't had to do this yet i'm not sure if the MAC addresses will stay the same, they might change so you may need to update router with new MAC addresses.
- Add dynamic DNS setup for easy external access
I'm using noip.com for dynamic DNS using the Plus or Enhanced plan. I setup my domain with my own registrar and pointed the domain to noip.com. I setup the MX records so I could get email on my personal server. I setup one record like *.rlplex.ca so that any subdomain simply gets sent to nginx.
Follow this guide : https://gist.github.com/daz/ae4c7a8c21e9e447be3d97fe54d9ec92 but it's based on this guide directly from noip.com http://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client-on-ubuntu/
Now we need to setup ubuntu to use nginx for reverse proxy : https://www.htpcguides.com/configure-plex-media-server-reverse-proxy-nginx-linux/
Because I needed different subdomains for each section of my setup (Plex, SR, CP, PY) I needed nginx to also filter traffic for subdomains. So I setup noip.com with a wildcard and followed this guide to setup each subdomain : https://whatididtodowhatidid.wordpress.com/2014/03/14/subdomains-for-ports-on-same-ubuntu-server-with-nginx-reverse-proxy/
COPY OF FILE FOR NGINX REVERSE PROXY :
##################################
# If not using Organizr forward straight to Plex
server {
listen 8080;
server_name rlplex.ca 192.168.86.75;
location / {
proxy_pass http://192.168.86.75:32400;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# If using Organizr
server {
listen 8080;
server_name rlplex.ca 192.168.86.75;
root /var/www/html/Organizr;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
server {
listen 32400;
server_name pms.rlplex.ca 192.168.86.75;
location / {
proxy_pass http://192.168.86.75:32400;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 5050;
server_name cp.rlplex.ca 192.168.86.75;
location / {
proxy_pass http://192.168.86.75:5050;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 8081;
server_name sr.rlplex.ca 192.168.86.75;
location / {
proxy_pass http://192.168.86.75:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 8181;
server_name py.rlplex.ca 192.168.86.75;
location / {
proxy_pass http://192.168.86.75:8181;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 3579;
server_name pr.rlplex.ca 192.168.86.75;
location / {
proxy_pass http://192.168.86.75:3579;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 8112;
server_name dl.rlplex.ca 192.168.86.75;
location / {
proxy_pass http://192.168.86.60:8112;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 8082;
server_name pd.rlplex.ca 192.168.86.75;
root /var/www/html/plexDash;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
##################################
- Install PlexRequests
Follow this guide : https://www.htpcguides.com/install-plex-requests-ubuntu-14-x/
- Useful linux commands for rpi's or ubuntu
I use the software putty to SSH into the rpi's and my headless ubuntu, here are some basic / useful commands
ls / cd / mkdir / rmdir / rm / cp / mv (these you should know, if not go google some shit)
ls -l (will show you current user/group permissions)
sudo (run a command as a superuser, this is done most of the time in my guides)
free -m (check current memory usage, free memory might be low but this is unimportant, see (https://raspberrypi.stackexchange.com/questions/37913/freeing-up-cache-when-memory-is-low))
top (check the top current running executables)
curl ipecho.net/plain; echo (check your current public IP)
ip addr show (show current network interface IPs, usually on eth0, wlan0 is your wifi)
ping (duh!)
cat (file name) (show the contents of a file)
chown (change the user/group ownership of a file)
chmod (change the permissions of a file)
unzip (duh!)
wget (download a file from the web)
grep (used for search, ex: grep "openvpn" *.txt)
exit (log out of SSH)
lsb_release -a (check your Ubuntu version)
systemctl status application.service (check service status)
mount (display all mounted drives)
df -h (or -m) (display a better looking mount information)
file -sL /dev/sd* (find hdd partition type)
sudo fdisk –l (find partitions)
mkfs.ntfs /dev/sdb* (format disk partition type)
rm -r mydir (remove folder and all contents of mydir folder, you can put folder in double quotes to avoid escaping characters)
To UNRAR files:
cd /mnt/plexmsdlds/TV-show or Movie
unrar e *.rar (add -r after e to do recursive in directories)
Instructions from : http://www.beginninglinux.com/home/data-compression/unrar-all-files-from-multiple-subdirectories-at-once
- Current ubuplex structure
-- sda1 - plexmsstrg1
--- /mnt/movies
--- /mnt/kidsmovies
-- sdb2 - plexmsstrg2
--- /mnt/tvshows
-- sdb3 - plexdlds
--- /mnt/downloads
- How to partition disk drives for Linux
Here is the guide I used : https://www.digitalocean.com/community/tutorials/how-to-partition-and-format-storage-devices-in-linux
Don't forget to update the new HDD everywhere (/etc/fstab and /etc/exports) and on the rpi3.
- How to use rsync
So to use rsync I found this guide : https://www.linux.com/blog/howto-using-rsync-move-mountain-data
Example that I used :
rsync -av /path/to/files/ /destination/path/to/files/
rsync -av /mnt/plexnas/tvshows/ /mnt/plexmsstrg/tvshows/
Sample to copy movie
rsync -av /mnt/plexmsdlds/completed/4K/(movie folder name) /mnt/plexmsstrg/4K/movies/
rsync -av /mnt/plexmsdlds/completed/4K/Saving.Private.Ryan.1998.2160p.UHD.BluRay.X265-IAMABLE /mnt/plexmsstrg/4K/movies/
If permissions issues add sudo to command. If files are not ok run "sudo chmod -R 777 (folder name)"
- How to make HDDs available via network
Use this guide : https://help.ubuntu.com/community/How%20to%20Create%20a%20Network%20Share%20Via%20Samba%20Via%20CLI%20%28Command-line%20interface/Linux%20Terminal%29%20-%20Uncomplicated%2C%20Simple%20and%20Brief%20Way%21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment