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

Apply example_ynh

This commit is contained in:
yalh76 2022-07-14 02:14:07 +02:00
parent ae830aeae1
commit 61ff69efe9
12 changed files with 206 additions and 205 deletions

View file

@ -1,12 +1,9 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
path="/path" path="/path"
admin="john"
is_public=1 is_public=1
admin="john"
discovery=1 discovery=1
; Checks ; Checks
pkg_linter=1 pkg_linter=1
@ -16,6 +13,8 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 10.8.0~ynh1
upgrade=1 from_commit=384dcd2ff1dbf4b0085edb7f12e4d15f00508e2b
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0 port_already_use=0
@ -23,6 +22,3 @@
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none
;;; Upgrade options
# ; commit=
# name=

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Media System that manage and stream your media.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Système multimédia qui gère et diffuse vos médias.

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.8.0~ynh1", "version": "10.8.0~ynh2",
"url": "https://jellyfin.org", "url": "https://jellyfin.org",
"upstream": { "upstream": {
"license": "GPL-2.0-only", "license": "GPL-2.0-only",
@ -17,8 +17,8 @@
}, },
"license": "GPL-2.0-only", "license": "GPL-2.0-only",
"maintainer": { "maintainer": {
"name": "tituspijean", "name": "tituspijean",
"email": "tituspijean@outlook.com" "email": "tituspijean@outlook.com"
}, },
"previous_maintainers": [ "previous_maintainers": [
{ {
@ -27,14 +27,14 @@
} }
], ],
"requirements": { "requirements": {
"yunohost": ">=4.3" "yunohost": ">= 4.3.0"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
@ -45,10 +45,6 @@
"example": "/jellyfin", "example": "/jellyfin",
"default": "/jellyfin" "default": "/jellyfin"
}, },
{
"name": "admin",
"type": "user"
},
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
@ -58,6 +54,10 @@
"fr": "Jellyfin a son propre système de connexion, vous devriez la laisser publique pour permettre la connexion de clients externes (app mobile, etc.)." "fr": "Jellyfin a son propre système de connexion, vous devriez la laisser publique pour permettre la connexion de clients externes (app mobile, etc.)."
} }
}, },
{
"name": "admin",
"type": "user"
},
{ {
"name": "discovery", "name": "discovery",
"type": "boolean", "type": "boolean",

View file

@ -4,15 +4,12 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
debian=$(lsb_release --codename --short)
pkg_version="10.8.0-1" pkg_version="10.8.0-1"
version=$(echo "$pkg_version" | cut -d '-' -f 1) version=$(echo "$pkg_version" | cut -d '-' -f 1)
ffmpeg_pkg_version="5.0.1-5" ffmpeg_pkg_version="5.0.1-5"
ldap_pkg_version="15.0.0.0" ldap_pkg_version="15.0.0.0"
architecture=$(dpkg --print-architecture)
discovery_service_port=1900 discovery_service_port=1900
discovery_client_port=7359 discovery_client_port=7359
@ -43,12 +40,12 @@ ffmpeg_deps=(
zlib1g zlib1g
) )
case "$debian" in case "$(lsb_release --codename --short)" in
buster) ffmpeg_deps+=( libvpx5 libx264-155 libx265-165 ) ;; buster) ffmpeg_deps+=( libvpx5 libx264-155 libx265-165 ) ;;
bullseye) ffmpeg_deps+=( libvpx6 libx264-160 libx265-192 ) ;; bullseye) ffmpeg_deps+=( libvpx6 libx264-160 libx265-192 ) ;;
*) echo "Unknown release: $debian" >&2; exit 1 ;; *) echo "Unknown release: $(lsb_release --codename --short)" >&2; exit 1 ;;
esac esac
case "$architecture" in case "$YNH_ARCH" in
arm64) : ;; arm64) : ;;
armhf) : ;; armhf) : ;;
*) ffmpeg_deps+=( libdrm-intel1 libopencl1 ) ;; *) ffmpeg_deps+=( libdrm-intel1 libopencl1 ) ;;
@ -64,15 +61,15 @@ pkg_dependencies="${ffmpeg_deps[*]} ${jellyfin_deps[*]}"
install_jellyfin_packages() { install_jellyfin_packages() {
# In case of a new version, the url change from # In case of a new version, the url change from
# https://repo.jellyfin.org/releases/server/debian/versions/stable/server/X.X.X/jellyfin-server_X.X.X-1_$architecture.deb to # https://repo.jellyfin.org/releases/server/debian/versions/stable/server/X.X.X/jellyfin-server_X.X.X-1_$YNH_ARCH.deb to
# https://repo.jellyfin.org/archive/debian/stable/X.X.X/server/jellyfin-server_X.X.X-1_$architecture.deb # https://repo.jellyfin.org/archive/debian/stable/X.X.X/server/jellyfin-server_X.X.X-1_$YNH_ARCH.deb
for pkg in web server; do for pkg in web server; do
src_url=$(grep 'SOURCE_URL=' "$YNH_APP_BASEDIR/conf/$pkg.$debian.$architecture.src" | cut -d= -f2-) src_url=$(grep 'SOURCE_URL=' "$YNH_APP_BASEDIR/conf/$pkg.$(lsb_release --codename --short).$YNH_ARCH.src" | cut -d= -f2-)
if ! curl --output /dev/null --silent --head --fail "$src_url"; then if ! curl --output /dev/null --silent --head --fail "$src_url"; then
ynh_replace_string \ ynh_replace_string \
--match_string="releases/server/debian/versions/stable/$pkg/$version/" \ --match_string="releases/server/debian/versions/stable/$pkg/$version/" \
--replace_string="archive/debian/stable/$version/$pkg/" \ --replace_string="archive/debian/stable/$version/$pkg/" \
--target_file="$YNH_APP_BASEDIR/conf/$pkg.$debian.$architecture.src" --target_file="$YNH_APP_BASEDIR/conf/$pkg.$(lsb_release --codename --short).$YNH_ARCH.src"
fi fi
done done
@ -80,22 +77,22 @@ install_jellyfin_packages() {
tempdir="$(mktemp -d)" tempdir="$(mktemp -d)"
# Download the deb files # Download the deb files
ynh_setup_source --dest_dir=$tempdir --source_id="ffmpeg.$debian.$architecture" ynh_setup_source --dest_dir=$tempdir --source_id="ffmpeg.$(lsb_release --codename --short).$YNH_ARCH"
ynh_setup_source --dest_dir=$tempdir --source_id="server.$debian.$architecture" ynh_setup_source --dest_dir=$tempdir --source_id="server.$(lsb_release --codename --short).$YNH_ARCH"
ynh_setup_source --dest_dir=$tempdir --source_id="web.$debian.$architecture" ynh_setup_source --dest_dir=$tempdir --source_id="web.$(lsb_release --codename --short).$YNH_ARCH"
# Install the packages # Install the packages
ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-ffmpeg5.deb ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-ffmpeg5.deb
ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-server.deb ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-server.deb
ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-web.deb ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-web.deb
rm -rf "$tempdir" ynh_secure_remove --file="$tempdir"
# 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 \ ynh_install_app_dependencies \
jellyfin-ffmpeg5="$ffmpeg_pkg_version-$debian" \ jellyfin-ffmpeg5="$ffmpeg_pkg_version-$(lsb_release --codename --short)" \
jellyfin-server="$pkg_version" \ jellyfin-server="$pkg_version" \
jellyfin-web="$pkg_version" jellyfin-web="$pkg_version"
} }

View file

@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors

View file

@ -21,9 +21,6 @@ new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
port=$(ynh_app_setting_get --app="$app" --key=port)
config_path=$(ynh_app_setting_get --app="$app" --key=config_path)
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
@ -32,14 +29,19 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
port=$(ynh_app_setting_get --app=$app --key=port)
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=10 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=10
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"

View file

@ -25,8 +25,8 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
discovery=$YNH_APP_ARG_DISCOVERY discovery=$YNH_APP_ARG_DISCOVERY
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -41,9 +41,8 @@ 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 [[ ! "$YNH_ARCH" =~ ^(amd64|arm64|armhf)$ ]]; then
if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then ynh_die "Jellyfin is not compatible with your architecture, $YNH_ARCH, which is neither amd64, arm64, or armhf." 1
ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1
fi fi
# Register (book) web path # Register (book) web path
@ -105,21 +104,6 @@ ynh_script_progression --message="Installing dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# INSTALL PACKAGES
#=================================================
ynh_script_progression --message="Installing packages..." --weight=1
install_jellyfin_packages
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=6
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -134,12 +118,28 @@ if grep -q "^render:" /etc/group; then
fi fi
#================================================= #=================================================
# MODIFY A CONFIG FILE # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Waiting 30s to let Jellyfin fully start a first time..." ynh_script_progression --message="Configuring NGINX web server..." --weight=6
sleep 30
ynh_script_progression --message="Configuring the settings..." --weight=1 # Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# INSTALL PACKAGES
#=================================================
ynh_script_progression --message="Installing packages..." --weight=1
install_jellyfin_packages
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
sleep 30
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15
@ -166,8 +166,6 @@ ynh_multimedia_build_main_dir
# Allow Jellyfin to write into these directories # Allow Jellyfin to write into these directories
ynh_multimedia_addaccess $app ynh_multimedia_addaccess $app
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
@ -177,6 +175,8 @@ ynh_script_progression --message="Securing files and directories..."
chown -R $app: $final_path chown -R $app: $final_path
chown -R $app: $config_path chown -R $app: $config_path
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================

View file

@ -17,9 +17,9 @@ 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)
discovery_client=$(ynh_app_setting_get --app=$app --key=discovery_client) discovery_client=$(ynh_app_setting_get --app=$app --key=discovery_client)
discovery_service=$(ynh_app_setting_get --app=$app --key=discovery_service) discovery_service=$(ynh_app_setting_get --app=$app --key=discovery_service)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path)
#================================================= #=================================================
@ -35,6 +35,22 @@ then
yunohost service remove $app yunohost service remove $app
fi fi
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
@ -51,32 +67,6 @@ dpkg --remove jellyfin-web
dpkg --remove jellyfin-server dpkg --remove jellyfin-server
dpkg --remove jellyfin-ffmpeg5 dpkg --remove jellyfin-ffmpeg5
#=================================================
# 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
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated 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
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
@ -93,6 +83,18 @@ then
ynh_exec_warn_less yunohost firewall disallow UDP 7359 ynh_exec_warn_less yunohost firewall disallow UDP 7359
fi fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --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"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -23,7 +23,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -43,13 +43,72 @@ 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 [[ ! "$YNH_ARCH" =~ ^(amd64|arm64|armhf)$ ]]; then
if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then ynh_die "Jellyfin is not compatible with your architecture, $YNH_ARCH, which is neither amd64, arm64, or armhf." 1
ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1
fi fi
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$config_path"
ynh_restore_file --origin_path="/etc/default/jellyfin" --not_mandatory
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# REINSTALL PACKAGES
#=================================================
ynh_script_progression --message="Reinstalling packages..." --weight=7
install_jellyfin_packages
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app: $final_path
chown -R $app: $config_path
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=2
# Build YunoHost multimedia directories
ynh_multimedia_build_main_dir
# Allow Jellyfin to write into these directories
ynh_multimedia_addaccess $app
#================================================= #=================================================
# OPEN PORTS # OPEN PORTS
#================================================= #=================================================
@ -80,47 +139,6 @@ fi
ynh_app_setting_set --app=$app --key=discovery_service --value=$discovery_service ynh_app_setting_set --app=$app --key=discovery_service --value=$discovery_service
ynh_app_setting_set --app=$app --key=discovery_client --value=$discovery_client ynh_app_setting_set --app=$app --key=discovery_client --value=$discovery_client
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$config_path"
ynh_restore_file --origin_path="/etc/default/jellyfin" --not_mandatory
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# REINSTALL PACKAGES
#=================================================
ynh_script_progression --message="Reinstalling packages..." --weight=7
install_jellyfin_packages
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
@ -129,6 +147,13 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" --not_mandatory ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" --not_mandatory
systemctl enable jellyfin.service --quiet systemctl enable jellyfin.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -142,22 +167,6 @@ needed_ports=()
# Integrate service and require to expose the ports if needed # Integrate service and require to expose the ports if needed
yunohost service add $app --description="Jellyfin media center" ${needed_ports:+--needs_exposed_ports} "${needed_ports[@]}" yunohost service add $app --description="Jellyfin media center" ${needed_ports:+--needs_exposed_ports} "${needed_ports[@]}"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --time --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app: $final_path
chown -R $app: $config_path
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
@ -165,16 +174,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
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="restart" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=2
# Build YunoHost multimedia directories
ynh_multimedia_build_main_dir
# Allow Jellyfin to write into these directories
ynh_multimedia_addaccess $app
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -73,9 +73,9 @@ debians=("buster" "bullseye")
architectures=("amd64" "arm64" "armhf") architectures=("amd64" "arm64" "armhf")
for debian in "${debians[@]}"; do for debian in "${debians[@]}"; do
for architecture in "${architectures[@]}"; do for architecture in "${architectures[@]}"; do
prepare_source --template="../conf/ffmpeg.src.default" --destination="../conf/ffmpeg.$debian.$architecture.src" --architecture="$architecture" prepare_source --template="../conf/ffmpeg.src.default" --destination="../conf/ffmpeg.$(lsb_release --codename --short).$YNH_ARCH.src" --architecture="$YNH_ARCH"
prepare_source --template="../conf/web.src.default" --destination="../conf/web.$debian.$architecture.src" --architecture="$architecture" prepare_source --template="../conf/web.src.default" --destination="../conf/web.$(lsb_release --codename --short).$YNH_ARCH.src" --architecture="$YNH_ARCH"
prepare_source --template="../conf/server.src.default" --destination="../conf/server.$debian.$architecture.src" --architecture="$architecture" prepare_source --template="../conf/server.src.default" --destination="../conf/server.$(lsb_release --codename --short).$YNH_ARCH.src" --architecture="$YNH_ARCH"
done done
done done

View file

@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers
ynh_script_progression --message="Loading installation settings..." --weight=1 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)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
@ -30,14 +31,37 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
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" --timeout=15
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
architecture=$(dpkg --print-architecture) if [[ ! "$YNH_ARCH" =~ ^(amd64|arm64|armhf)$ ]]; then
if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then ynh_die "Jellyfin is not compatible with your architecture, $YNH_ARCH, which is neither amd64, arm64, or armhf." 1
ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1
fi fi
# If path keys do not exist, create them # If path keys do not exist, create them
@ -77,22 +101,6 @@ if [ ! -f "/etc/logrotate.d/$app" ]; then
ynh_use_logrotate ynh_use_logrotate
fi fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# OPEN PORTS # OPEN PORTS
#================================================= #=================================================
@ -125,11 +133,19 @@ ynh_app_setting_set --app=$app --key=discovery_client --value=$discovery_client
#================================================= #=================================================
# STOP SYSTEMD SERVICE # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15 # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -140,31 +156,18 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # SPECIFIC UPGRADE
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5 # UPGRADE PACKAGES
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# UPGRADE packages
#================================================= #=================================================
ynh_script_progression --message="Upgrading packages..." --weight=3 ynh_script_progression --message="Upgrading packages..." --weight=3
install_jellyfin_packages install_jellyfin_packages
#================================================= #=================================================
# CREATE DEDICATED USER # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=2
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Setting up configuration files..." --weight=2
# TODO: investigate if we can avoid overriding system.xml # TODO: investigate if we can avoid overriding system.xml
#ynh_add_config --template="system.xml" --destination="$config_path/system.xml" #ynh_add_config --template="system.xml" --destination="$config_path/system.xml"
@ -190,8 +193,6 @@ ynh_multimedia_build_main_dir
# Allow Jellyfin to write into these directories # Allow Jellyfin to write into these directories
ynh_multimedia_addaccess $app ynh_multimedia_addaccess $app
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
@ -200,12 +201,14 @@ ynh_multimedia_addaccess $app
chown -R $app: $final_path chown -R $app: $final_path
chown -R $app: $config_path chown -R $app: $config_path
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage application logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
#================================================= #=================================================