Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Jellyfin not installing correctly #1032

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1d7b4da
fix(apt): :construction: Switch Jellyfin over to the new official rep…
Jul 3, 2023
a3e7477
style(apt): :construction: Fix typo in a comment explaining something
Jul 3, 2023
1d3e3f2
fix(apt): :package: Switch Jellyfin to the new repositories.
Jul 3, 2023
bbe6273
style(shellcheck): :fire: Remove unnecessary variables
Jul 3, 2023
cacdb90
style(echos): :art: Added some echos to better describe what is happe…
Jul 4, 2023
a0a231c
style(echos): :art: Echo improvements
Jul 4, 2023
43b7a57
fix: :bug: Checking architecture errors out install script before any…
Jul 4, 2023
fade94a
fix: :bug: BASE_OS must be present in order to get the right repository
Jul 4, 2023
94ddc93
fix: :bug: dist_info not found, removed.
Jul 4, 2023
1ecbff5
fix: :bug: Version checking is redundant as swizzin is only supported…
Jul 4, 2023
870fc5f
fix(setup): :bug: Added a way to fetch and install signing key
Jul 4, 2023
cc216ec
fix: :bug: Script failing to get signing keys due to improper impleme…
Jul 4, 2023
89a5568
fix: :bug: Use curl -fsSL to get key. Previous implementation causing…
Jul 4, 2023
799c871
style: :fire: Remove unnecessary echoes
Jul 4, 2023
41d641e
style: :art: Changed verbiage of some echoes and changed echo type fo…
Jul 4, 2023
6f83dd6
style(echos): :art: Further improvements to echoes.
Jul 4, 2023
bdf19c9
fix: :bug: Fixing same issue that I found in the install script.
Jul 4, 2023
2404dae
fix(shellcheck): :art: Shellcheck was complaining about this
Jul 4, 2023
2678a36
refactor: :art: More elegant way of disabling and removing services.
Jul 4, 2023
b70e6e8
style(echos): :art: Making some echoes look nice
Jul 4, 2023
4d83319
feat: :sparkles: Automatically update the Jellyfin key
Jul 4, 2023
1b2839e
fix: Trying to fix merge conflict
Jul 18, 2023
fb90ac2
Merge branch 'swizzin:develop' into develop
KatieTheDev Jul 18, 2023
7f73a11
style(echos): :art: Modify echoes
Jul 18, 2023
2b25b27
style(apt): :art: Remove unsupported distros from switching.
Jul 18, 2023
de9d67b
style: :art: Use some more builtins
Jul 18, 2023
4be6eee
fix: :art: Remove Ubuntu-centric "universe" repo
Jul 18, 2023
f746309
style: :art: Use more builtins
Jul 18, 2023
83b0a17
style: :art: Move repo-adding to a seperate function as it is replica…
Jul 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 42 additions & 12 deletions scripts/install/jellyfin.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# authors: liara userdocs flying-sausages
# authors: liara userdocs flying-sausages katiethedev
#
# Licensed under GNU General Public License v3.0 GPL-3 (in short)
#
Expand All @@ -11,16 +11,10 @@
# Source the global functions we require for this script.
. /etc/swizzin/sources/functions/utils
. /etc/swizzin/sources/functions/ssl
#
# awaiting pull to remove
function dist_info() {
DIST_CODENAME="$(source /etc/os-release && echo "$VERSION_CODENAME")"
DIST_ID="$(source /etc/os-release && echo "$ID")"
}

#
# Get our some useful information from functions in the sourced utils script
username="$(_get_master_username)"
dist_info # get our distribution ID, set to DIST_ID, and VERSION_CODENAME, set to DIST_CODENAME, from /etc/os-release

if [[ $(systemctl is-active emby) == "active" ]]; then
active=emby
Expand All @@ -40,6 +34,17 @@ if [[ -n $active ]]; then
fi
fi

#
## Get the path to gpg or install it
GNUPG=$(which gpg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gnupg2 is a global dependency of swizzin. You can safely assume every user has this installed already.

if [[ -z ${GNUPG} ]]; then
echo "Failed to find the GNUPG binary, but we'll install 'gnupg' automatically."
# shellcheck disable=SC2206
# We are OK with word-splitting here since we control the contents
INSTALL_PKGS=(${INSTALL_PKGS[@]} gnupg)
echo
fi

#
########
######## Variables End
Expand Down Expand Up @@ -114,14 +119,39 @@ cat > /etc/jellyfin/network.xml <<- CONFIG
CONFIG

#
# Add the jellyfin official repository and key to our installation so we can use apt-get to install it jellyfin and jellyfin-ffmepg.
curl -s "https://repo.jellyfin.org/$DIST_ID/jellyfin_team.gpg.key" | gpg --dearmor > /usr/share/keyrings/jellyfin-archive-keyring.gpg 2>> "${log}"
echo "deb [signed-by=/usr/share/keyrings/jellyfin-archive-keyring.gpg arch=$(dpkg --print-architecture)] https://repo.jellyfin.org/$DIST_ID $DIST_CODENAME main" > /etc/apt/sources.list.d/jellyfin.list
# Check if old, outdated repository for jellyfin is installed
# If old repository is found, delete it.
if [[ -f /etc/apt/sources.list.d/jellyfin.list ]]; then
echo_progress_start "Found old-style '/etc/apt/sources.list.d/jellyfin.list' configuration; removing it."
rm -f /etc/apt/sources.list.d/jellyfin.list
echo_progress_done "Removed old configuration."
echo_success "Old repository has been removed."
fi

#
# install jellyfin and jellyfin-ffmepg using apt functions.
# Add Jellyfin signing key
curl -fsSL https://repo.jellyfin.org/jellyfin_team.gpg.key | gpg --dearmor --yes --output /etc/apt/keyrings/jellyfin.gpg
echo_success "Jellyfin Signing Key Added"

#
# Install the Deb822 format jellyfin.sources entry
add_jellyfin_repo

#
# Update apt repositories to fetch Jellyfin repository
apt_update #forces apt refresh

#
# Install Jellyfin and dependencies using apt
# Dependencies are automatically grabbed by apt
apt_install jellyfin

#
# Make sure Jellyfin finishes starting up before continuing.
echo_progress_start "Waiting for Jellyfin to start."
sleep 15
echo_progress_done "Jellyfin should be started."

#
# Add the jellyfin user to the master user's group.
usermod -a -G "${username}" jellyfin
Expand Down
45 changes: 32 additions & 13 deletions scripts/update/jellyfin.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
#!/usr/bin/env bash
#
if [[ -f /install/.jellyfin.lock ]]; then
# awaiting pull to remove
function dist_info() {
DIST_CODENAME="$(source /etc/os-release && echo "$VERSION_CODENAME")"
DIST_ID="$(source /etc/os-release && echo "$ID")"
}
# source the functions we need for this script.
#shellcheck source=sources/functions/utils
. /etc/swizzin/sources/functions/utils
# Get our main user credentials using a util function.
username="$(_get_master_username)"
dist_info # get our distribution ID, set to DIST_ID, and VERSION_CODENAME, set to DIST_CODENAME, from /etc/os-release
#
# remove the old service and remove legacy files.
if [[ -f /etc/systemd/system/jellyfin.service ]]; then
echo_progress_start "Removing old Jellyfin service"
systemctl stop jellyfin.service
systemctl -q disable --now jellyfin.service
rm_if_exists /etc/systemd/system/jellyfin.service
kill -9 $(ps xU "${username}" | grep "/opt/jellyfin/jellyfin -d /home/${username}/.config/Jellyfin$" | awk '{print $1}') > /dev/null 2>&1
rm_if_exists /opt/jellyfin
rm_if_exists /opt/ffmpeg
echo_progress_done "Old JF service removed"
Expand Down Expand Up @@ -68,17 +62,42 @@ if [[ -f /install/.jellyfin.lock ]]; then
fi
#
if ! check_installed jellyfin; then
echo_progress_start "Moving Jellyfin to apt-managed installation"
echo_progress_start "Updating Jellyfin installation using apt."

#
# Add the jellyfin official repository and key to our installation so we can use apt-get to install it jellyfin and jellyfin-ffmepg.
curl -s https://repo.jellyfin.org/$DIST_ID/jellyfin_team.gpg.key | gpg --dearmor > /usr/share/keyrings/jellyfin-archive-keyring.gpg 2>> "${log}"
echo "deb [signed-by=/usr/share/keyrings/jellyfin-archive-keyring.gpg arch=$(dpkg --print-architecture)] https://repo.jellyfin.org/$DIST_ID $DIST_CODENAME main" > /etc/apt/sources.list.d/jellyfin.list
# Check if old, outdated repository for jellyfin is installed
# If old repository is found, delete it.
if [[ -f /etc/apt/sources.list.d/jellyfin.list ]]; then
echo_progress_start "Found old-style '/etc/apt/sources.list.d/jellyfin.list' configuration; removing it."
rm -f /etc/apt/sources.list.d/jellyfin.list
rm -f /etc/apt/keyrings/jellyfin.gpg
echo_progress_done "Removed old repository."
fi

#
# Add Jellyfin signing key if not already present
if [[ ! -f /etc/apt/keyrings/jellyfin.gpg ]]; then
echo_progress_start "> Did not find signing key. Adding it."
curl -fsSL https://repo.jellyfin.org/jellyfin_team.gpg.key | gpg --dearmor --yes --output /etc/apt/keyrings/jellyfin.gpg
echo_progress_done "Jellyfin Signing Key Added"
fi

#
# install jellyfin and jellyfin-ffmepg using apt functions.
# Install the Deb822 format jellyfin.sources entry
add_jellyfin_repo
#
# Update apt repositories to fetch Jellyfin repository
apt_update #forces apt refresh
apt_install jellyfin jellyfin-ffmpeg

#
# Install Jellyfin and dependencies using apt
# Dependencies are automatically grabbed by apt
apt_install jellyfin
echo_progress_done "Finished updating Jellyfin via apt."

#
# Configure the new jellyfin service.
echo_progress_start "Configuring Jellyfin"
systemctl -q stop jellyfin.service
#
# Add the jellyfin user to the master user's group to use our ssl certs.
Expand Down
32 changes: 32 additions & 0 deletions sources/functions/jellyfin
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Contributers: katiethedev
# This functions file is created to resolve some replicated code between the install and update functions.

# This function adds the Jellyfin repository.
function add_jellyfin_repo() {
# Set required variables
ARCHITECTURE="$(_os_arch)"
BASE_OS="$(_os_distro)"
case "${BASE_OS}" in
raspbian)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think raspbian will pass this check so we don't need to write a case for it

# Raspbian uses the Debian repository
REPO_OS="debian"
;;
*)
REPO_OS="${BASE_OS}"
VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
;;
esac

# Install the Deb822 format jellyfin.sources entry
echo_progress_start "Adding Jellyfin repository to apt."
cat << EOF | tee /etc/apt/sources.list.d/jellyfin.sources
Types: deb
URIs: https://repo.jellyfin.org/${REPO_OS}
Suites: ${VERSION}
Components: main
Architectures: ${ARCHITECTURE}
Signed-By: /etc/apt/keyrings/jellyfin.gpg
EOF
echo_progress_done "Jellyfin repository added."
}