Dietpi + Emby. Updating Emby and enabling SSL

Guides and tutorials for various stuff. Posted by DietPi users.
Post Reply
trigrhappy
Posts: 4
Joined: Sat Aug 31, 2019 5:38 am

Dietpi + Emby. Updating Emby and enabling SSL

Post by trigrhappy »

I use my Raspberry Pi 4 4GB as my file server and Emby server. Dietpi does an awesome job of simplifying the installation and configuration of Radarr, Sonarr, Deluge, NZBGet, and Jackett..... so there's no point in me talking about that. It also does a great job of initially installing emby, but after that, its pretty much on you.

Disclaimer: I am by no means an expert, in either linux or Dietpi. With that said, I've spent a lot of time and effort on getting Emby set up exactly how I want. I suspect others have duplicated my efforts with mixed results, and my hope is to help in their endeavors. Even if it doesn't, just putting this on the internet allows me a quick place to reference it if I have to do this again.


Updating Emby:

So a new version of Emby comes out and you want to update to it. There is no easy way to update within Emby like there is for some of the other programs listed above. The only solution is to download the new version and manually install. Dietpi, takes the work out of it for us, however. (thanks to DietPi's twitter for this solution: https://twitter.com/DietPi_/status/1200 ... 26656?s=20)

Step 1: Perform a backup of DietPi. I've done this twice now and did not lose my settings either time, but having a backup will allow you to easily restore it in case Step 2 is more eventful for you than it has been for me.

Step 2: Login to your dietpi as root, and run the following:

Code: Select all

dietpi-software reinstall 41
This will pull the latest version and install it over the current version. It should retain all your settings, but just in case... you performed step 1, right?

Done.

Configuring Emby with encryption (and having it automatically renew your certificates)

A couple pre-requisites:
You'll need some sort of ddns server pointing at your dietpi server (otherwise this is pointless anyway, right?)
Create the directories on your DietPi installation of "/certs" and "/certs/old/"
Some sort of port forwarding from your router. I'll leave this to you, but ports 80, 443, and 8920 are what I point at my DietPi.

Step 1: Get certificates (this is the part I said DietPi makes easy)
on your dietpi,

Code: Select all

run dietpi-letsencrypt
The "domain" should be the DDNS address pointing at your dietpi server, the rest is pretty much up to you.

Step 2: Convert the letsencrypt *.pem files to the Emby friendly *.pfx format. (replace "emby.domain.com" with the DDNS address that points at your dietpi server).
First off, all credit here goes to ICSY7867 from the Emby forums for the script. This will both convert the files to the Emby format as well as automatically renew them every time dietpi-letsencrypt renews the original certificates automatically.
Create a file called embycert.sh and paste in the following code:

Code: Select all

#!/bin/bash

today=`date +%Y-%m-%d`
mv /certs/embycert.pfx /certs/old/emby.$today

privkey=/etc/letsencrypt/live/emby.domain.com/privkey.pem
cert=/etc/letsencrypt/live/emby.domain.com/cert.pem
chain=/etc/letsencrypt/live/emby.domain.com/chain.pem

openssl pkcs12 -export -out /certs/embycert.pfx -inkey $privkey -in $cert -certfile $chain -password pass:

service emby-server restart
Now save that file, and place it in "/etc/letsencrypt/renewal-hooks/post"

Now every time letsencrypt renews the certificates, it will run this script, which converts the new certificates to a format that Emby requires.

NOTE: If you created the embycert.sh file on windows. Do the following while in the "/etc/letsencrypt/renewal-hooks/post" folder:

Code: Select all

apt-get install dos2unix
dos2unix embycert.sh
Step 3: While in /etc/letsencrypt/renewal-hooks/post/ run the command "chmod 777 embycert.sh" to prevent any issues (i had some that this solved.... ymmv).

Step 4: While in "/certs" run "chmod 777 emby.pfx" (this also solved issues that may or not be unique to me)

Step 5: Go to your emby server in a web browser and under "networking", in the "custom ssl certificate path" select the file "/certs/embycert.pfx". Then scroll down and click "save".

Now restart your emby server.

You're done. Let me know if you run any issues and we can troubleshoot/update this guide.

PROTIP: If you want to enable hardware accelerated h264 encoding (likely for the purpose of transcoding) on the Raspberry Pi, you will need to dedicate at least 128mb to GPU memory. Otherwise it will fail and fall back to software encoding.
Last edited by trigrhappy on Wed Dec 04, 2019 11:59 pm, edited 1 time in total.

User avatar
johnvick
Legend
Posts: 691
Joined: Wed Jun 08, 2016 10:53 am
Location: New Zealand

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by johnvick »

Nice guide, thanks for this. Possibly an easier way is to download the .deb and then install via dpkg -i *.deb.

If you are concerned about exposing ports to access emby from ouside your LAN you can setup a reverse proxy.

trigrhappy
Posts: 4
Joined: Sat Aug 31, 2019 5:38 am

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by trigrhappy »

I didn't go the reverse proxy route, but I saw that a lot of people had success with it. As for the download and install the *.deb route for updating, that appears to be exactly what "dietpi-software reinstall 41" does.... at least by my understanding of it. Either way, it worked extremely smoothly for me and I didn't have to do anything manually to do it.

Post Reply