Dietpi + Emby. Updating Emby and enabling SSL

Guides and tutorials for various stuff. Posted by DietPi users.
trigrhappy
Posts: 7
Joined: Sat Aug 31, 2019 6: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 Thu Dec 05, 2019 12:59 am, edited 1 time in total.

User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11: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: 7
Joined: Sat Aug 31, 2019 6: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.

climbrather
Posts: 2
Joined: Sun Mar 08, 2020 9:08 am

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by climbrather »

Code: Select all

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).
The command does not seem to do anything for me. I'm running raspberry pi 4b with dietpi. All files and folders are available as required in the script but no files are generated in the /certs folder. Would you please have any suggestions?

User avatar
Joulinar
Posts: 1780
Joined: Sat Nov 16, 2019 12:49 am

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by Joulinar »

HI,

what exactly is the command you are going to execute that is not working?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team

climbrather
Posts: 2
Joined: Sun Mar 08, 2020 9:08 am

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by climbrather »

This command "chmod 777 embycert.sh"

User avatar
Joulinar
Posts: 1780
Joined: Sat Nov 16, 2019 12:49 am

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by Joulinar »

this command is changing file system permissions only. it did not execute anything. Did you checked file system permissions of embycert.sh??
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team

trigrhappy
Posts: 7
Joined: Sat Aug 31, 2019 6:38 am

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by trigrhappy »

climbrather wrote:
Sun Mar 08, 2020 9:14 am

Code: Select all

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).
The command does not seem to do anything for me. I'm running raspberry pi 4b with dietpi. All files and folders are available as required in the script but no files are generated in the /certs folder. Would you please have any suggestions?
As Joulinar said, that command is only modifying permissions (making the .sh file executable, to be specific). It will not generate any new files.

Crake
Posts: 2
Joined: Mon Apr 13, 2020 7:01 pm

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by Crake »

Sorry to ask for help but i'm a newbie here!
I want to update my Emby server 4.3.1.0 (it's working ok btw) to the latest stable version available, ok?
In the beginning you say "...The only solution is to download the new version and manually install..." but i don't know where to download it.
CAn you help me here?
Thanks in advance

User avatar
Joulinar
Posts: 1780
Joined: Sat Nov 16, 2019 12:49 am

Re: Dietpi + Emby. Updating Emby and enabling SSL

Post by Joulinar »

I guess this is described on first post - step 2
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.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team

Post Reply