scripts/jellyfin_sslsetup.sh

34 lines
948 B
Bash
Executable File

#!/bin/bash
#
# Rsync jellyfin valid ssl certificate from edge server.
#
# This helps make sure the server has valid SSL certificate for local
# clients can validate.
#
# Example: My TV connects directly to the media-center, skipping going over
# the internet. The local media-center needs a valid certificate
# if I want the TV to connect to the SSL port.
source /usr/local/etc/jellyfin_sslsetup.conf
#################################
tmpdir=$(mktemp --directory)
# Grab certificates and store them locally
for i in {1..5};
do
sftp -q "$remotehost:$certpath" $tmpdir/ && s=0 && break || s=1 && sleep 3;
done
if [ $s -eq 0 ]; then
# create the p12 file and restart jellyfin
openssl pkcs12 -export -out /var/lib/jellyfin/jellyfin.p12 -inkey "$tmpdir/$key" -in "$tmpdir/$cert" -passout "pass:$password"
sudo systemctl restart jellyfin
else
echo "Error: Can't reach edge server"
rm -fR $tmpdir
exit 1
fi
rm -fR $tmpdir