1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jellyfin_ynh.git synced 2024-09-03 19:26:29 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:20:06 +02:00 committed by GitHub
commit 85bc12ef85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 116 additions and 130 deletions

View file

@ -21,7 +21,8 @@ cpe = "cpe:2.3:a:jellyfin:jellyfin"
fund = "https://opencollective.com/jellyfin" fund = "https://opencollective.com/jellyfin"
[integration] [integration]
yunohost = ">= 11.2" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["armhf", "arm64", "amd64"] architectures = ["armhf", "arm64", "amd64"]
multi_instance = false multi_instance = false
ldap = true ldap = true

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
debian=$(lsb_release --codename --short) debian=$(lsb_release --codename --short)
@ -24,21 +24,16 @@ config_path="/etc/$app"
log_path="/var/log/$app" log_path="/var/log/$app"
cache_path="/var/cache/$app" cache_path="/var/cache/$app"
#=================================================
# PERSONAL HELPERS
#=================================================
install_jellyfin_packages() { install_jellyfin_packages() {
# Get version numbers from manifest UNUSED because update_version.py uses the hard-coded variables # Get version numbers from manifest UNUSED because update_version.py uses the hard-coded variables
# pkg_version="$(ynh_app_upstream_version)" # pkg_version="$(ynh_app_upstream_version)"
# ffmpeg_url="$(ynh_read_manifest --manifest_key="resources.sources.ffmpeg_${debian}.${YNH_ARCH}.url")" # ffmpeg_url="$(ynh_read_manifest
# ffmpeg_pkg_version="$(echo "$ffmpeg_url" | sed "s/.*\/jellyfin-ffmpeg[0-9]*_\([0-9.-]*\)-${debian}_${YNH_ARCH}.deb/\1/")" # ffmpeg_pkg_version="$(echo "$ffmpeg_url" | sed "s/.*\/jellyfin-ffmpeg[0-9]*_\([0-9.-]*\)-${debian}_${YNH_ARCH}.deb/\1/")"
# This should only run on upgrade, to fix https://github.com/YunoHost-Apps/jellyfin_ynh/issues/163 # This should only run on upgrade, to fix https://github.com/YunoHost-Apps/jellyfin_ynh/issues/163
# Previously the package depended on exact package versions, so upgrade was broken. # Previously the package depended on exact package versions, so upgrade was broken.
if ynh_package_is_installed --package="$app-ynh-deps" && ynh_package_is_installed --package="jellyfin-server"; then if _ynh_apt_package_is_installed"$app-ynh-deps" && _ynh_apt_package_is_installed"jellyfin-server"; then
ynh_install_app_dependencies jellyfin-web jellyfin-ffmpeg6 jellyfin-server ynh_apt_install_dependencies jellyfin-web jellyfin-ffmpeg6 jellyfin-server
fi fi
# Create the temporary directory # Create the temporary directory
@ -50,23 +45,23 @@ install_jellyfin_packages() {
ynh_setup_source --dest_dir="$tempdir" --source_id="server_$debian" ynh_setup_source --dest_dir="$tempdir" --source_id="server_$debian"
# Install the packages. Allow downgrades because apt decided bullseye > bookworm # Install the packages. Allow downgrades because apt decided bullseye > bookworm
ynh_package_install --allow-downgrades \ _ynh_apt_install --allow-downgrades \
"$tempdir/jellyfin-web.deb" \ "$tempdir/jellyfin-web.deb" \
"$tempdir/jellyfin-server.deb" "$tempdir/jellyfin-server.deb"
# We need to workaround yunohoost passing --no-remove to replace jellyfin-ffmpeg5... # We need to workaround yunohoost passing --no-remove to replace jellyfin-ffmpeg5...
if ynh_package_is_installed "jellyfin-ffmpeg5"; then if _ynh_apt_package_is_installed"jellyfin-ffmpeg5"; then
ynh_package_remove "jellyfin-ffmpeg5" ynh_package_remove "jellyfin-ffmpeg5"
fi fi
# Install the packages. Allow downgrades because apt decided bullseye > bookworm # Install the packages. Allow downgrades because apt decided bullseye > bookworm
ynh_package_install --allow-downgrades \ _ynh_apt_install --allow-downgrades \
"${tempdir}/jellyfin-ffmpeg6.deb" "${tempdir}/jellyfin-ffmpeg6.deb"
# The doc says it should be called only once, # The doc says it should be called only once,
# but the code says multiple calls are supported. # but the code says multiple calls are supported.
# Also, they're already installed so that should be quasi instantaneous. # Also, they're already installed so that should be quasi instantaneous.
ynh_install_app_dependencies jellyfin-web jellyfin-ffmpeg6 jellyfin-server ynh_apt_install_dependencies jellyfin-web jellyfin-ffmpeg6 jellyfin-server
# Mark packages as dependencies, to allow automatic removal # Mark packages as dependencies, to allow automatic removal
apt-mark auto jellyfin-server jellyfin-web jellyfin-ffmpeg6 apt-mark auto jellyfin-server jellyfin-web jellyfin-ffmpeg6
@ -81,7 +76,7 @@ configure_jellyfin_discovery_ports() {
remove_jellyfin_discovery_ports remove_jellyfin_discovery_ports
;; ;;
*) *)
ynh_print_warn --message="Invalid script calling configure_jellyfin_discovery_ports with args (should be install|remove): $@" ynh_print_warn "Invalid script calling configure_jellyfin_discovery_ports with args (should be install|remove): $@"
;; ;;
esac esac
} }
@ -89,12 +84,12 @@ configure_jellyfin_discovery_ports() {
remove_jellyfin_discovery_ports() { remove_jellyfin_discovery_ports() {
if [[ $discovery_service -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_service_port$" if [[ $discovery_service -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_service_port$"
then then
ynh_exec_warn_less yunohost firewall disallow UDP $discovery_service_port ynh_hide_warnings yunohost firewall disallow UDP $discovery_service_port
fi fi
if [[ $discovery_client -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_client_port$" if [[ $discovery_client -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_client_port$"
then then
ynh_exec_warn_less yunohost firewall disallow UDP $discovery_client_port ynh_hide_warnings yunohost firewall disallow UDP $discovery_client_port
fi fi
} }
@ -107,30 +102,22 @@ install_jellyfin_discovery_ports() {
opened_ports=($discovery_service_port $discovery_client_port) opened_ports=($discovery_service_port $discovery_client_port)
# Open port $discovery_service_port for service auto-discovery # Open port $discovery_service_port for service auto-discovery
if ynh_port_available --port=$discovery_service_port; then if #REMOVEME? ynh_port_available --port=$discovery_service_port; then
ynh_exec_warn_less yunohost firewall allow UDP $discovery_service_port ynh_hide_warnings yunohost firewall allow UDP $discovery_service_port
else else
discovery_service=0 discovery_service=0
ynh_print_warn --message="Port $discovery_service_port (for service auto-discovery) is not available. Continuing nonetheless." ynh_print_warn "Port $discovery_service_port (for service auto-discovery) is not available. Continuing nonetheless."
fi fi
# Open port $discovery_client_port for client auto-discovery # Open port $discovery_client_port for client auto-discovery
if ynh_port_available --port=$discovery_client_port; then if #REMOVEME? ynh_port_available --port=$discovery_client_port; then
ynh_exec_warn_less yunohost firewall allow UDP $discovery_client_port ynh_hide_warnings yunohost firewall allow UDP $discovery_client_port
else else
discovery_client=0 discovery_client=0
ynh_print_warn --message="Port $discovery_client_port (for client auto-discovery) is not available. Continuing nonetheless." ynh_print_warn "Port $discovery_client_port (for client auto-discovery) is not available. Continuing nonetheless."
fi fi
fi fi
ynh_app_setting_set --app="$app" --key=discovery_service --value="$discovery_service" ynh_app_setting_set --key=discovery_service --value="$discovery_service"
ynh_app_setting_set --app="$app" --key=discovery_client --value="$discovery_client" ynh_app_setting_set --key=discovery_client --value="$discovery_client"
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -8,31 +8,28 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$data_path" ynh_backup "$data_path"
ynh_backup --src_path="$config_path" ynh_backup "$config_path"
ynh_backup --src_path="/etc/default/jellyfin" --not_mandatory ynh_backup "/etc/default/jellyfin" || true
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/jellyfin.service.d" --not_mandatory ynh_backup "/etc/systemd/system/jellyfin.service.d" || true
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -10,16 +10,16 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping $app's systemd service..." --weight=2 ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15 ynh_systemctl --service="$app" --action="stop" --log_path="systemd" --timeout=15
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config ynh_config_change_url_nginx
#================================================= #=================================================
# BASE URL # BASE URL
@ -29,21 +29,21 @@ ynh_change_url_nginx_config
if [ $change_path -eq 1 ]; then if [ $change_path -eq 1 ]; then
# If somehow <BaseUrl /> was not replaced during install # If somehow <BaseUrl /> was not replaced during install
if grep -q "<BaseUrl />" "$config_path/network.xml"; then if grep -q "<BaseUrl />" "$config_path/network.xml"; then
ynh_replace_string --match_string="<BaseUrl />" --replace_string="<BaseUrl>$new_path</BaseUrl>" --target_file="$config_path/network.xml" ynh_replace --match="<BaseUrl />" --replace="<BaseUrl>$new_path</BaseUrl>" --file="$config_path/network.xml"
else else
ynh_replace_string --match_string="<BaseUrl>$old_path</BaseUrl>" --replace_string="<BaseUrl>$new_path</BaseUrl>" --target_file="$config_path/network.xml" ynh_replace --match="<BaseUrl>$old_path</BaseUrl>" --replace="<BaseUrl>$new_path</BaseUrl>" --file="$config_path/network.xml"
fi fi
fi fi
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=2 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --timeout=15 ynh_systemctl --service="$app" --action="start" --log_path="systemd" --timeout=15
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression "Change of URL completed for $app"

View file

@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
if [ -d "$config_path" ]; then if [ -d "$config_path" ]; then
ynh_die --message="There is already a directory: $config_path " ynh_die "There is already a directory: $config_path "
fi fi
ynh_app_setting_set --app="$app" --key=config_path --value="$config_path" ynh_app_setting_set --key=config_path --value="$config_path"
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#=================================================ç #=================================================ç
ynh_script_progression --message="Configuring the dedicated system user..." --weight=1 ynh_script_progression "Configuring the dedicated system user..."
if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then
# Add user to render group # Add user to render group
@ -29,7 +29,7 @@ fi
#================================================= #=================================================
# OPEN PORTS # OPEN PORTS
#================================================= #=================================================
ynh_script_progression --message="Checking whether to open ports..." --weight=1 ynh_script_progression "Checking whether to open ports..."
configure_jellyfin_discovery_ports install configure_jellyfin_discovery_ports install
ports_args=() ports_args=()
@ -40,38 +40,38 @@ fi
#================================================= #=================================================
# INSTALL PACKAGES # INSTALL PACKAGES
#================================================= #=================================================
ynh_script_progression --message="Installing packages..." --weight=1 ynh_script_progression "Installing packages..."
install_jellyfin_packages install_jellyfin_packages
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Waiting 30s to let Jellyfin fully start a first time..." ynh_print_info "Waiting 30s to let Jellyfin fully start a first time..."
sleep 30 sleep 30
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression "Adding $app's configuration..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15 ynh_systemctl --service="$app" --action="stop" --log_path="systemd" --timeout=15
ynh_add_config --template="system.xml" --destination="$config_path/system.xml" ynh_config_add --template="system.xml" --destination="$config_path/system.xml"
ynh_add_config --template="network.xml" --destination="$config_path/network.xml" ynh_config_add --template="network.xml" --destination="$config_path/network.xml"
ynh_add_config --template="logging.json" --destination="$config_path/logging.json" ynh_config_add --template="logging.json" --destination="$config_path/logging.json"
#================================================= #=================================================
# INSTALL LDAP PLUGIN # INSTALL LDAP PLUGIN
#================================================= #=================================================
ynh_script_progression --message="Installing LDAP plugin..." --weight=2 ynh_script_progression "Installing LDAP plugin..."
ynh_setup_source --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=plugin_ldap ynh_setup_source --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=plugin_ldap
mkdir -p /var/lib/jellyfin/plugins/configurations/ mkdir -p /var/lib/jellyfin/plugins/configurations/
ynh_add_config --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml" ynh_config_add --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml"
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_script_progression --message="Securing files and directories..." ynh_script_progression "Securing files and directories..."
# Set permissions to app files # Set permissions to app files
chown -R "$app:" "$data_path" chown -R "$app:" "$data_path"
@ -80,7 +80,7 @@ chown -R "$app:" "$config_path"
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=2 ynh_script_progression "Adding multimedia directories..."
# Build YunoHost multimedia directories # Build YunoHost multimedia directories
ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir
@ -91,28 +91,28 @@ ynh_multimedia_addaccess "$app"
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated NGINX config using the conf/nginx.conf template # Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_nginx_config ynh_config_add_nginx
ynh_add_config --template="systemd.service" --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf" ynh_config_add --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf"
systemctl daemon-reload systemctl daemon-reload
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}" yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --timeout=15 ynh_systemctl --service="$app" --action="start" --log_path="systemd" --timeout=15
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -10,42 +10,42 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_script_progression "Removing system configurations related to $app..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
yunohost service remove "$app" yunohost service remove "$app"
fi fi
ynh_remove_logrotate ynh_config_remove_logrotate
ynh_remove_nginx_config ynh_config_remove_nginx
#================================================= #=================================================
# REMOVE PACKAGES # REMOVE PACKAGES
#================================================= #=================================================
ynh_script_progression --message="Removing packages..." --weight=1 ynh_script_progression "Removing packages..."
ynh_remove_app_dependencies ynh_apt_remove_dependencies
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
ynh_script_progression --message="Closing ports..." --weight=1 ynh_script_progression "Closing ports..."
configure_jellyfin_discovery_ports remove configure_jellyfin_discovery_ports remove
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." --weight=1 ynh_script_progression "Removing various files..."
ynh_secure_remove --file="$config_path" ynh_safe_rm "$config_path"
ynh_secure_remove --file="/etc/systemd/system/jellyfin.service.d" ynh_safe_rm "/etc/systemd/system/jellyfin.service.d"
ynh_secure_remove --file="/etc/sudoers.d/jellyfin-sudoers" ynh_safe_rm "/etc/sudoers.d/jellyfin-sudoers"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Reconfiguring the dedicated system user..." --weight=1 ynh_script_progression "Reconfiguring the dedicated system user..."
# It could be created later by the deb, but it's cleaner here # It could be created later by the deb, but it's cleaner here
if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then
@ -22,7 +22,7 @@ fi
#================================================= #=================================================
# OPEN PORTS # OPEN PORTS
#================================================= #=================================================
ynh_script_progression --message="Checking whether to open ports..." --weight=1 ynh_script_progression "Checking whether to open ports..."
configure_jellyfin_discovery_ports install configure_jellyfin_discovery_ports install
ports_args=() ports_args=()
@ -33,23 +33,23 @@ fi
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=2 ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$data_path" ynh_restore "$data_path"
ynh_restore_file --origin_path="$config_path" ynh_restore "$config_path"
ynh_restore_file --origin_path="/etc/default/jellyfin" --not_mandatory ynh_restore "/etc/default/jellyfin" || true
#================================================= #=================================================
# REINSTALL PACKAGES # REINSTALL PACKAGES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling packages..." --weight=7 ynh_script_progression "Reinstalling packages..."
install_jellyfin_packages install_jellyfin_packages
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
ynh_script_progression --message="Restoring user rights..." ynh_script_progression "Restoring user rights..."
# Restore permissions on app files # Restore permissions on app files
chown -R "$app:" "$data_path" chown -R "$app:" "$data_path"
@ -58,7 +58,7 @@ chown -R "$app:" "$config_path"
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=2 ynh_script_progression "Adding multimedia directories..."
# Build YunoHost multimedia directories # Build YunoHost multimedia directories
ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir
@ -69,27 +69,27 @@ ynh_multimedia_addaccess "$app"
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" --not_mandatory ynh_restore "/etc/systemd/system/jellyfin.service.d" || true
systemctl enable jellyfin.service --quiet systemctl enable jellyfin.service --quiet
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}" yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore "/etc/logrotate.d/$app"
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" --timeout=15 ynh_systemctl --service="$app" --action="restart" --log_path="systemd" --timeout=15
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -10,14 +10,14 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15 ynh_systemctl --service="$app" --action="stop" --log_path="systemd" --timeout=15
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression "Ensuring downward compatibility..."
# If render group exists, and system user doesn't belong to it, add it # If render group exists, and system user doesn't belong to it, add it
if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then
@ -28,26 +28,27 @@ fi
# If config_path is mixed up with install_dir, fix them # If config_path is mixed up with install_dir, fix them
if [ -z "$config_path" ] || [[ $config_path = "/var/lib/jellyfin" ]]; then if [ -z "$config_path" ] || [[ $config_path = "/var/lib/jellyfin" ]]; then
config_path=/etc/jellyfin config_path=/etc/jellyfin
ynh_app_setting_set --app="$app" --key=config_path --value=$config_path ynh_app_setting_set --key=config_path --value=$config_path
fi fi
ynh_app_setting_delete --app="$app" --key=is_public ynh_app_setting_delete --key=is_public
# If discovery key does not exist, create it # If discovery key does not exist, create it
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=discovery --value=0
if [ -z "${discovery:-}" ]; then if [ -z "${discovery:-}" ]; then
discovery=0 discovery=0
ynh_app_setting_set --app="$app" --key=discovery --value=$discovery ynh_app_setting_set --key=discovery --value=$discovery
fi fi
if [ ! -f "/etc/logrotate.d/$app" ]; then if [ ! -f "/etc/logrotate.d/$app" ]; then
# Fix possibly missing file due to buggy restore: # Fix possibly missing file due to buggy restore:
ynh_use_logrotate ynh_config_add_logrotate
fi fi
#================================================= #=================================================
# OPEN PORTS # OPEN PORTS
#================================================= #=================================================
ynh_script_progression --message="Checking whether to open ports..." --weight=1 ynh_script_progression "Checking whether to open ports..."
configure_jellyfin_discovery_ports install configure_jellyfin_discovery_ports install
ports_args=() ports_args=()
@ -58,7 +59,7 @@ fi
#================================================= #=================================================
# UPGRADE PACKAGES # UPGRADE PACKAGES
#================================================= #=================================================
ynh_script_progression --message="Upgrading packages..." --weight=3 ynh_script_progression "Upgrading packages..."
# Backup the configuration files to prevent yunohost to see a manual edit # Backup the configuration files to prevent yunohost to see a manual edit
bakdir=$(mktemp -d) bakdir=$(mktemp -d)
@ -71,16 +72,16 @@ install_jellyfin_packages
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2 ynh_script_progression "Updating configuration..."
# Restore the files we just backed up before installing the debs... # Restore the files we just backed up before installing the debs...
for name in system.xml network.xml logging.json; do for name in system.xml network.xml logging.json; do
mv -f "$bakdir/$name" "$config_path/$name" mv -f "$bakdir/$name" "$config_path/$name"
done done
ynh_secure_remove "$bakdir" ynh_safe_rm "$bakdir"
ynh_add_config --template="network.xml" --destination="$config_path/network.xml" ynh_config_add --template="network.xml" --destination="$config_path/network.xml"
ynh_add_config --template="logging.json" --destination="$config_path/logging.json" ynh_config_add --template="logging.json" --destination="$config_path/logging.json"
#================================================= #=================================================
# ENSURE NO OLD/INCOMPATIBLE PLUGINS ARE LEFT # ENSURE NO OLD/INCOMPATIBLE PLUGINS ARE LEFT
@ -97,7 +98,7 @@ if [ -d /var/lib/jellyfin/plugins ]; then
fi fi
if [ ! -f "$directory"/meta.json ]; then if [ ! -f "$directory"/meta.json ]; then
ynh_print_warn --message="Jellyfin plugin '$name' looks legacy (missing meta.json). Moving to /var/lib/jellyfin/plugins-backup." ynh_print_warn "Jellyfin plugin '$name' looks legacy (missing meta.json). Moving to /var/lib/jellyfin/plugins-backup."
mv "$directory" /var/lib/jellyfin/plugins-backup/ mv "$directory" /var/lib/jellyfin/plugins-backup/
fi fi
@ -107,7 +108,7 @@ if [ -d /var/lib/jellyfin/plugins ]; then
abi="$(jq -r '.targetAbi' "$directory/meta.json")" abi="$(jq -r '.targetAbi' "$directory/meta.json")"
if dpkg --compare-versions "$abi" lt "$plugin_abi"; then if dpkg --compare-versions "$abi" lt "$plugin_abi"; then
ynh_print_warn --message="Jellyfin plugin '$name' ABI $abi is lower than expected $plugin_abi. Moving to /var/lib/jellyfin/plugins-backup." ynh_print_warn "Jellyfin plugin '$name' ABI $abi is lower than expected $plugin_abi. Moving to /var/lib/jellyfin/plugins-backup."
mv "$directory" /var/lib/jellyfin/plugins-backup/ mv "$directory" /var/lib/jellyfin/plugins-backup/
fi fi
done done
@ -116,11 +117,11 @@ fi
#================================================= #=================================================
# INSTALL LDAP PLUGIN # INSTALL LDAP PLUGIN
#================================================= #=================================================
ynh_script_progression --message="Installing LDAP plugin..." --weight=2 ynh_script_progression "Installing LDAP plugin..."
ynh_setup_source --full_replace=1 --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=plugin_ldap ynh_setup_source --full_replace --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=plugin_ldap
mkdir -p /var/lib/jellyfin/plugins/configurations/ mkdir -p /var/lib/jellyfin/plugins/configurations/
ynh_add_config --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml" ynh_config_add --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml"
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
@ -133,7 +134,7 @@ chown -R "$app:" "$config_path"
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=2 ynh_script_progression "Adding multimedia directories..."
# Build YunoHost multimedia directories # Build YunoHost multimedia directories
ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir
@ -144,28 +145,28 @@ ynh_multimedia_addaccess "$app"
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 ynh_script_progression "Upgrading system configurations related to $app..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
ynh_add_config --template="systemd.service" --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf" ynh_config_add --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf"
systemctl daemon-reload systemctl daemon-reload
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate ynh_config_add_logrotate
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}" yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" --timeout=15 ynh_systemctl --service="$app" --action="restart" --log_path="systemd" --timeout=15
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"