1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jellyfin_ynh.git synced 2024-09-03 19:26:29 +02:00

Merge pull request #64 from YunoHost-Apps/fix-restore

Fix the mess
This commit is contained in:
tituspijean 2021-05-05 21:12:01 +02:00 committed by GitHub
commit f5075d9c97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 429 additions and 24 deletions

View file

@ -11,7 +11,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
Jellyfin enables you to collect, manage, and stream your media. Run the Jellyfin server on your system and gain access to the leading free-software entertainment system, bells and whistles included. Jellyfin enables you to collect, manage, and stream your media. Run the Jellyfin server on your system and gain access to the leading free-software entertainment system, bells and whistles included.
**Shipped version:** 10.7.0 **Shipped version:** 10.7.2
## Screenshots ## Screenshots

View file

@ -3,15 +3,15 @@
[![Niveau d'intégration](https://dash.yunohost.org/integration/jellyfin.svg)](https://dash.yunohost.org/appci/app/jellyfin) ![](https://ci-apps.yunohost.org/ci/badges/jellyfin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/jellyfin.maintain.svg) [![Niveau d'intégration](https://dash.yunohost.org/integration/jellyfin.svg)](https://dash.yunohost.org/appci/app/jellyfin) ![](https://ci-apps.yunohost.org/ci/badges/jellyfin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/jellyfin.maintain.svg)
[![Installer Jellyfin avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=jellyfin) [![Installer Jellyfin avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=jellyfin)
*[Read this readme in english.](./README.md)* *[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Jellyfin rapidement et simplement sur un serveur YunoHost. > *Ce package vous permet d'installer Jellyfin rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
## Vue d'ensemble ## Vue d'ensemble
Jellyfin vous permet de collecter, gérer et diffuser vos médias. Exécutez le serveur Jellyfin sur votre système et accédez au principal système de divertissement à logiciel libre. Jellyfin vous permet de collecter, gérer et diffuser vos médias. Exécutez le serveur Jellyfin sur votre système et accédez au principal système de divertissement à logiciel libre.
**Version incluse :** 10.7.0 **Version incluse :** 10.7.2
## Captures d'écran ## Captures d'écran

View file

@ -24,7 +24,7 @@
# 10.6.4~ynh3 # 10.6.4~ynh3
#upgrade=1 from_commit=5478712c0ca7683503bc1b50cfafe81ea508065e #upgrade=1 from_commit=5478712c0ca7683503bc1b50cfafe81ea508065e
# 10.7.0~ynh1 # 10.7.0~ynh1
upgrade=1 from_commit=63ab03ab79cc088a52b8a36fb4fdf5918bf0e14b #upgrade=1 from_commit=63ab03ab79cc088a52b8a36fb4fdf5918bf0e14b
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0 port_already_use=0

7
conf/ffmpeg.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://repo.jellyfin.org/releases/server/debian/versions/jellyfin-ffmpeg/4.3.2-1/jellyfin-ffmpeg_4.3.2-1-buster_amd64.deb
SOURCE_SUM=54987f4ede995e50e6662e7741df5205005b7e8d881af8145b71d319df6f0cb2
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=false
SOURCE_FILENAME=jellyfin-ffmpeg.deb

7
conf/ffmpeg.src.default Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://repo.jellyfin.org/releases/server/debian/versions/jellyfin-ffmpeg/__FFMPEG_PKG_VERSION__/jellyfin-ffmpeg___FFMPEG_PKG_VERSION__-__DEBIAN___amd64.deb
SOURCE_SUM=https://repo.jellyfin.org/releases/server/debian/versions/jellyfin-ffmpeg/__FFMPEG_PKG_VERSION__/jellyfin-ffmpeg___FFMPEG_PKG_VERSION__-__DEBIAN___amd64.deb.sha256sum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=false
SOURCE_FILENAME=jellyfin-ffmpeg.deb

View file

@ -5,4 +5,3 @@ SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false SOURCE_IN_SUBDIR=false
SOURCE_FILENAME= SOURCE_FILENAME=
SOURCE_EXTRACT=true SOURCE_EXTRACT=true

7
conf/server.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://repo.jellyfin.org/releases/server/debian/versions/stable/server/10.7.2/jellyfin-server_10.7.2-1_amd64.deb
SOURCE_SUM=05d7d7afc9ac7bf44d5fef79d88d56afd1c36f98b0f0746c2b8f37e3b881c353
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=false
SOURCE_FILENAME=jellyfin-server.deb

7
conf/server.src.default Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://repo.jellyfin.org/releases/server/debian/versions/stable/server/__VERSION__/jellyfin-server___PKG_VERSION_____ARCHITECTURE__.deb
SOURCE_SUM=https://repo.jellyfin.org/releases/server/debian/versions/stable/server/__VERSION__/jellyfin-server___PKG_VERSION_____ARCHITECTURE__.deb.sha256sum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=false
SOURCE_FILENAME=jellyfin-server.deb

7
conf/web.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://repo.jellyfin.org/releases/server/debian/versions/stable/web/10.7.2/jellyfin-web_10.7.2-1_all.deb
SOURCE_SUM=a2213212e3c6ef0fd87c7414f64e0c2dc991997eef7b8a4a755734c5878c337a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=false
SOURCE_FILENAME=jellyfin-web.deb

7
conf/web.src.default Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://repo.jellyfin.org/releases/server/debian/versions/stable/web/__VERSION__/jellyfin-web___PKG_VERSION___all.deb
SOURCE_SUM=https://repo.jellyfin.org/releases/server/debian/versions/stable/web/__VERSION__/jellyfin-web___PKG_VERSION___all.deb.sha256sum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=false
SOURCE_FILENAME=jellyfin-web.deb

View file

@ -6,7 +6,7 @@
"en": "Media System that manage and stream your media.", "en": "Media System that manage and stream your media.",
"fr": "Système multimédia qui gère et diffuse vos médias." "fr": "Système multimédia qui gère et diffuse vos médias."
}, },
"version": "10.7.0~ynh2", "version": "10.7.2~ynh1",
"url": "https://github.com/jellyfin/jellyfin", "url": "https://github.com/jellyfin/jellyfin",
"license": "GPL-2.0-only", "license": "GPL-2.0-only",
"maintainer": { "maintainer": {

View file

@ -4,12 +4,180 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
debian=$(lsb_release --codename --short)
pkg_version="10.7.0-1" pkg_version="10.7.0-1"
version=$(echo "$pkg_version" | cut -d '-' -f 1)
ffmpeg_pkg_version="4.3.1-4"
architecture=$(dpkg --print-architecture)
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
#
# usage: ynh_setup_source_2 --dest_dir=dest_dir [--source_id=source_id]
# | arg: -d, --dest_dir= - Directory where to setup sources
# | arg: -s, --source_id= - Name of the app, if the package contains more than one app
#
# The file conf/app.src need to contains:
#
# SOURCE_URL=Address to download the app archive
# SOURCE_SUM can either be the SUM string, or a URL to a file containing the SUM.
# If a URL is provided, the contents of the file will be cut to the first space.
# SOURCE_SUM=Control sum
# # (Optional) Program to check the integrity (sha256sum, md5sum...)
# # default: sha256
# SOURCE_SUM_PRG=sha256
# # (Optional) Archive format
# # default: tar.gz
# SOURCE_FORMAT=tar.gz
# # (Optional) Put false if sources are directly in the archive root
# # default: true
# # Instead of true, SOURCE_IN_SUBDIR could be the number of sub directories
# # to remove.
# SOURCE_IN_SUBDIR=false
# # (Optionnal) Name of the local archive (offline setup support)
# # default: ${src_id}.${src_format}
# SOURCE_FILENAME=example.tar.gz
# # (Optional) If it set as false don't extract the source.
# # (Useful to get a debian package or a python wheel.)
# # default: true
# SOURCE_EXTRACT=(true|false)
#
# Details:
# This helper downloads sources from SOURCE_URL if there is no local source
# archive in /opt/yunohost-apps-src/APP_ID/SOURCE_FILENAME
#
# Next, it checks the integrity with "SOURCE_SUM_PRG -c --status" command.
#
# If it's ok, the source archive will be uncompressed in $dest_dir. If the
# SOURCE_IN_SUBDIR is true, the first level directory of the archive will be
# removed.
# If SOURCE_IN_SUBDIR is a numeric value, 2 for example, the 2 first level
# directories will be removed
#
# Finally, patches named sources/patches/${src_id}-*.patch and extra files in
# sources/extra_files/$src_id will be applied to dest_dir
#
# Requires YunoHost version 2.6.4 or higher.
ynh_setup_source_2 () {
# Declare an array to define the options of this helper.
local legacy_args=ds
local -A args_array=( [d]=dest_dir= [s]=source_id= )
local dest_dir
local source_id
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
source_id="${source_id:-app}" # If the argument is not given, source_id equals "app"
local src_file_path="$YNH_CWD/../conf/${source_id}.src"
# In case of restore script the src file is in an other path.
# So try to use the restore path if the general path point to no file.
if [ ! -e "$src_file_path" ]; then
src_file_path="$YNH_CWD/../settings/conf/${source_id}.src"
fi
# Load value from configuration file (see above for a small doc about this file
# format)
local src_url=$(grep 'SOURCE_URL=' "$src_file_path" | cut --delimiter='=' --fields=2-)
local src_sum=$(grep 'SOURCE_SUM=' "$src_file_path" | cut --delimiter='=' --fields=2-)
local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$src_file_path" | cut --delimiter='=' --fields=2-)
local src_format=$(grep 'SOURCE_FORMAT=' "$src_file_path" | cut --delimiter='=' --fields=2-)
local src_extract=$(grep 'SOURCE_EXTRACT=' "$src_file_path" | cut --delimiter='=' --fields=2-)
local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$src_file_path" | cut --delimiter='=' --fields=2-)
local src_filename=$(grep 'SOURCE_FILENAME=' "$src_file_path" | cut --delimiter='=' --fields=2-)
# Default value
src_sumprg=${src_sumprg:-sha256sum}
src_in_subdir=${src_in_subdir:-true}
src_format=${src_format:-tar.gz}
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
src_extract=${src_extract:-true}
if [ "$src_filename" = "" ]; then
src_filename="${source_id}.${src_format}"
fi
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
if test -e "$local_src"
then # Use the local source file if it is present
cp $local_src $src_filename
else # If not, download the source
# NB. we have to declare the var as local first,
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
# because local always return 0 ...
local out
# Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget)
out=$(wget --tries 3 --no-dns-cache --timeout 900 --no-verbose --output-document=$src_filename $src_url 2>&1) \
|| ynh_die --message="$out"
fi
# Get the control sum if a URL was provided
# Only retain the part before the first space
if [[ "${src_sum}" =~ ^http[s+]:// ]]; then
src_sum=$(curl -L -s "${src_sum}" | cut -d ' ' -f 1)
fi
# Check the control sum
echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status \
|| ynh_die --message="Corrupt source"
# Extract source into the app dir
mkdir --parents "$dest_dir"
if ! "$src_extract"
then
mv $src_filename $dest_dir
elif [ "$src_format" = "zip" ]
then
# Zip format
# Using of a temp directory, because unzip doesn't manage --strip-components
if $src_in_subdir
then
local tmp_dir=$(mktemp --directory)
unzip -quo $src_filename -d "$tmp_dir"
cp --archive $tmp_dir/*/. "$dest_dir"
ynh_secure_remove --file="$tmp_dir"
else
unzip -quo $src_filename -d "$dest_dir"
fi
else
local strip=""
if [ "$src_in_subdir" != "false" ]
then
if [ "$src_in_subdir" == "true" ]
then
local sub_dirs=1
else
local sub_dirs="$src_in_subdir"
fi
strip="--strip-components $sub_dirs"
fi
if [[ "$src_format" =~ ^tar.gz|tar.bz2|tar.xz$ ]]
then
tar --extract --file=$src_filename --directory="$dest_dir" $strip
else
ynh_die --message="Archive format unrecognized."
fi
fi
# Apply patches
if (( $(find $YNH_CWD/../sources/patches/ -type f -name "${source_id}-*.patch" 2> /dev/null | wc --lines) > "0" ))
then
(cd "$dest_dir"
for p in $YNH_CWD/../sources/patches/${source_id}-*.patch
do
patch --strip=1 < $p
done) || ynh_die --message="Unable to apply patches"
fi
# Add supplementary files
if test -e "$YNH_CWD/../sources/extra_files/${source_id}"; then
cp --archive $YNH_CWD/../sources/extra_files/$source_id/. "$dest_dir"
fi
}
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -50,6 +50,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================

View file

@ -72,7 +72,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=2 ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
@ -127,7 +127,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" --timeout=15
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX

View file

@ -40,6 +40,11 @@ config_path=/etc/jellyfin
test ! -e "$final_path" || ynh_die --message="There is already a directory: $final_path " test ! -e "$final_path" || ynh_die --message="There is already a directory: $final_path "
test ! -e "$config_path" || ynh_die --message="There is already a directory: $config_path " test ! -e "$config_path" || ynh_die --message="There is already a directory: $config_path "
architecture=$(dpkg --print-architecture)
if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then
ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1
fi
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -70,7 +75,23 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/$( awk -F'=' '/^ID=/{ print $NF }' /etc/os-release ) $( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release ) main" --key="https://repo.jellyfin.org/jellyfin_team.gpg.key" --package="jellyfin=$pkg_version" # Prepare the source files (replace the placeholders with version, architecture, etc.
ynh_add_config --template="../conf/ffmpeg.src.default" --destination="../conf/ffmpeg.src"
ynh_add_config --template="../conf/server.src.default" --destination="../conf/server.src"
ynh_add_config --template="../conf/web.src.default" --destination="../conf/web.src"
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download the deb files
ynh_setup_source_2 --dest_dir=$tempdir --source_id=ffmpeg
ynh_setup_source_2 --dest_dir=$tempdir --source_id=server
ynh_setup_source_2 --dest_dir=$tempdir --source_id=web
# Install the packages
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-ffmpeg.deb -y
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-server.deb -y
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-web.deb -y
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -94,8 +115,8 @@ ynh_system_user_create --username=$app
ynh_script_progression --message="Configuring the settings..." --weight=1 ynh_script_progression --message="Configuring the settings..." --weight=1
# Load services once to generate system.xml # Load services once to generate system.xml
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Startup complete" ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15
# Port config # Port config
ynh_replace_string --match_string="<PublicPort>8096</PublicPort>" --replace_string="<PublicPort>$port</PublicPort>" --target_file="$config_path/network.xml" ynh_replace_string --match_string="<PublicPort>8096</PublicPort>" --replace_string="<PublicPort>$port</PublicPort>" --target_file="$config_path/network.xml"
@ -107,6 +128,10 @@ ynh_replace_string --match_string="<BaseUrl />" --replace_string="<BaseUrl>$path
# Disable Setup Wizard # Disable Setup Wizard
ynh_replace_string --match_string="<IsStartupWizardCompleted>false</IsStartupWizardCompleted>" --replace_string="<IsStartupWizardCompleted>true</IsStartupWizardCompleted>" --target_file="$config_path/system.xml" ynh_replace_string --match_string="<IsStartupWizardCompleted>false</IsStartupWizardCompleted>" --replace_string="<IsStartupWizardCompleted>true</IsStartupWizardCompleted>" --target_file="$config_path/system.xml"
# Lower logging verbosity
cp "$config_path/logging.default.json" "$config_path/logging.json"
ynh_replace_string --match_string="\"Default\": \"Information\"" --replace_string="\"Default\": \"Error\"" --target_file="$config_path/logging.json"
ynh_store_file_checksum --file="$config_path/network.xml" ynh_store_file_checksum --file="$config_path/network.xml"
ynh_store_file_checksum --file="$config_path/system.xml" ynh_store_file_checksum --file="$config_path/system.xml"
@ -129,6 +154,14 @@ ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files # Set permissions to app files
chown -R $app: $final_path chown -R $app: $final_path
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -142,7 +175,7 @@ yunohost service add $app --description="Jellyfin media center" --log_type="syst
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT

View file

@ -17,6 +17,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -36,8 +38,19 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies apt-get remove jellyfin-web -y
ynh_remove_app_dependencies apt-get remove jellyfin-server -y
apt-get remove jellyfin-ffmpeg -y
#=================================================
# REMOVE APP DIRECTORIES
#=================================================
ynh_script_progression --message="Removing app directories..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="$config_path"
ynh_secure_remove --file="/etc/systemd/system/jellyfin.service.d"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -47,6 +60,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -44,6 +44,11 @@ test ! -d $final_path \
test ! -d $config_path \ test ! -d $config_path \
|| ynh_die --message="There is already a directory: $config_path " || ynh_die --message="There is already a directory: $config_path "
architecture=$(dpkg --print-architecture)
if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then
ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1
fi
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
@ -84,8 +89,23 @@ chown -R $app: $final_path
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=7 ynh_script_progression --message="Reinstalling dependencies..." --weight=7
# Define and install dependencies # Prepare the source files (replace the placeholders with version, architecture, etc.
ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/debian $( lsb_release -c -s ) main" --package="jellyfin" --key="https://repo.jellyfin.org/debian/jellyfin_team.gpg.key" ynh_add_config --template="../conf/ffmpeg.src.default" --destination="../settings/conf/ffmpeg.src"
ynh_add_config --template="../conf/server.src.default" --destination="../settings/conf/server.src"
ynh_add_config --template="../conf/web.src.default" --destination="../settings/conf/web.src"
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download the deb files
ynh_setup_source_2 --dest_dir=$tempdir --source_id=ffmpeg
ynh_setup_source_2 --dest_dir=$tempdir --source_id=server
ynh_setup_source_2 --dest_dir=$tempdir --source_id=web
# Install the packages
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-ffmpeg.deb -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-server.deb -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-web.deb -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
@ -99,7 +119,13 @@ yunohost service add $app --description="Jellyfin media center" --log_type="syst
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Startup complete" ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

77
scripts/update_version.sh Executable file
View file

@ -0,0 +1,77 @@
#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# META HELPER FOR PACKAGE RELEASES
#=================================================
# This script is meant to be manually run by the app packagers
# to automatically update the source files.
# Edit version numbers in _common.sh before running the script.
prepare_source () {
# Declare an array to define the options of this helper.
local legacy_args=tdv
local -A args_array=( [t]=template= [d]=destination= )
local template
local destination
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local template_path
if [ -f "../conf/$template" ]; then
template_path="../conf/$template"
elif [ -f "../settings/conf/$template" ]; then
template_path="../settings/conf/$template"
elif [ -f "$template" ]; then
template_path=$template
else
ynh_die --message="The provided template $template doesn't exist"
fi
cp "$template_path" "$destination"
ynh_replace_vars --file="$destination"
local official_checksum
local official_checksum_url
local filename
local checksum
local url
# Create the temporary directory
tempdir="$(mktemp -d)"
official_checksum_url=$(grep "SOURCE_SUM=" "$destination" | cut -d "=" -f 2)
official_checksum=$(curl -L -s "${official_checksum_url}" | cut -d ' ' -f 1)
echo $official_checksum
url=$(grep "SOURCE_URL=" "$destination" | cut -d "=" -f 2)
echo $url
filename=${url##*/}
echo $filename
curl -s -4 -L $url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
ynh_secure_remove $tempdir
if [[ "$official_checksum" != "$checksum" ]]; then
echo "Downloaded file checksum ($checksum) does not match official checksum ($official_checksum)"
exit 1
else
sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${checksum}/" "$destination"
echo "$destination updated"
fi
}
prepare_source --template="../conf/ffmpeg.src.default" --destination="../conf/ffmpeg.src"
prepare_source --template="../conf/web.src.default" --destination="../conf/web.src"
prepare_source --template="../conf/server.src.default" --destination="../conf/server.src"
sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${version}#" ../README.md
sed -i "s#\*\*Version incluse :\*\*.*#\*\*Version incluse :\*\* ${version}#" ../README_fr.md
sed -i "s# \"version\": \".*# \"version\": \"${version}\~ynh1\",#" ../manifest.json
git commit ../README.md ../README_fr.md ../manifest.json ../conf/ffmpeg.src ../conf/web.src ../conf/server.src -m "Upgrade to v$version"

View file

@ -34,7 +34,12 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If db_name doesn't exist, create it architecture=$(dpkg --print-architecture)
if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then
ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1
fi
# If path keys do not exist, create it
if [ -z "$config_path" ]; then if [ -z "$config_path" ]; then
config_path=/var/lib/jellyfin config_path=/var/lib/jellyfin
ynh_app_setting_set --app=$app --key=config_path --value=$config_path ynh_app_setting_set --app=$app --key=config_path --value=$config_path
@ -75,7 +80,7 @@ ynh_abort_if_errors
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -90,7 +95,23 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=3 ynh_script_progression --message="Upgrading dependencies..." --weight=3
ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/$( awk -F'=' '/^ID=/{ print $NF }' /etc/os-release ) $( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release ) main" --key="https://repo.jellyfin.org/jellyfin_team.gpg.key" --package="jellyfin=$pkg_version" # Prepare the source files (replace the placeholders with version, architecture, etc.
ynh_add_config --template="../conf/ffmpeg.src.default" --destination="../conf/ffmpeg.src"
ynh_add_config --template="../conf/server.src.default" --destination="../conf/server.src"
ynh_add_config --template="../conf/web.src.default" --destination="../conf/web.src"
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download the deb files
ynh_setup_source_2 --dest_dir=$tempdir --source_id=ffmpeg
ynh_setup_source_2 --dest_dir=$tempdir --source_id=server
ynh_setup_source_2 --dest_dir=$tempdir --source_id=web
# Install the packages
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-ffmpeg.deb -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-server.deb -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew
ynh_exec_warn_less apt-get -f install $tempdir/jellyfin-web.deb -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -112,8 +133,8 @@ if [ -z "/etc/jellyfin/network.xml" ]; then
ynh_backup_if_checksum_is_different --file="$config_path/system.xml" ynh_backup_if_checksum_is_different --file="$config_path/system.xml"
# Load services once to generate network.xml # Load services once to generate network.xml
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Startup complete" ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15
# Port config # Port config
ynh_replace_string --match_string="<PublicPort>8096</PublicPort>" --replace_string="<PublicPort>$port</PublicPort>" --target_file="$config_path/network.xml" ynh_replace_string --match_string="<PublicPort>8096</PublicPort>" --replace_string="<PublicPort>$port</PublicPort>" --target_file="$config_path/network.xml"
@ -126,6 +147,10 @@ if [ -z "/etc/jellyfin/network.xml" ]; then
ynh_store_file_checksum --file="$config_path/system.xml" ynh_store_file_checksum --file="$config_path/system.xml"
fi fi
# Lower logging verbosity
cp "$config_path/logging.default.json" "$config_path/logging.json"
ynh_replace_string --match_string="\"Default\": \"Information\"" --replace_string="\"Default\": \"Error\"" --target_file="$config_path/logging.json"
#================================================= #=================================================
# INSTALL LDAP PLUGIN # INSTALL LDAP PLUGIN
#================================================= #=================================================
@ -148,6 +173,14 @@ fi
# Set permissions on app files # Set permissions on app files
chown -R $app: $final_path chown -R $app: $final_path
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --non-append
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -160,7 +193,7 @@ yunohost service add $app --description="Jellyfin media center" --log_type="syst
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX