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

Apply last example_ynh (#65)

* Apply last example_ynh

* missing config_path

* Update check_process

* Update manifest.json
This commit is contained in:
yalh76 2021-03-19 14:06:07 +01:00 committed by GitHub
parent 592db328d1
commit 22ad337c76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 89 additions and 138 deletions

View file

@ -8,10 +8,7 @@
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
# language="fr"
is_public=1 (PUBLIC|public=1|private=0)
# password="pass"
port="666" (PORT)
; Checks
pkg_linter=1
setup_sub_dir=1
@ -20,8 +17,14 @@
setup_private=1
setup_public=1
upgrade=1
# Disabled because Jellyfin's team decided to remove old package...
# upgrade=1 from_commit=3e38d2ec954f6b333c3c2ed95e0e75c0df2fe966
# 10.6.4~ynh1
#upgrade=1 from_commit=dc5ab412fe599ce6d558c2f55fe53d2c21956c08
# 10.6.4~ynh2
#upgrade=1 from_commit=2aab8003d64ffabe65bd11ebe5933cfef519b061
# 10.6.4~ynh3
#upgrade=1 from_commit=5478712c0ca7683503bc1b50cfafe81ea508065e
# 10.7.0~ynh1
upgrade=1 from_commit=63ab03ab79cc088a52b8a36fb4fdf5918bf0e14b
backup_restore=1
multi_instance=0
port_already_use=0
@ -30,6 +33,11 @@
Email=
Notification=none
;;; Upgrade options
; commit=3e38d2ec954f6b333c3c2ed95e0e75c0df2fe966
name=2020-09-07 commit
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&port=666&
; commit=dc5ab412fe599ce6d558c2f55fe53d2c21956c08
name=10.6.4~ynh1
; commit=2aab8003d64ffabe65bd11ebe5933cfef519b061
name=10.6.4~ynh2
; commit=5478712c0ca7683503bc1b50cfafe81ea508065e
name=10.6.4~ynh3
; commit=63ab03ab79cc088a52b8a36fb4fdf5918bf0e14b
name=10.7.0~ynh1

View file

@ -6,7 +6,7 @@
"en": "Media System that manage and stream your media.",
"fr": "Système multimédia qui gère et diffuse vos médias."
},
"version": "10.7.0~ynh1",
"version": "10.7.0~ynh2",
"url": "https://github.com/jellyfin/jellyfin",
"license": "GPL-2.0-only",
"maintainer": {
@ -14,48 +14,33 @@
"email": "liberodark@gmail.com"
},
"requirements": {
"yunohost": ">= 3.8.1"
"yunohost": ">= 4.1.3"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [{
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for Jellyfin",
"fr": "Choisissez un nom de domaine pour Jellyfin"
},
"example": "example.com"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Jellyfin",
"fr": "Choisissez un chemin pour Jellyfin"
},
"example": "/jellyfin",
"default": "/jellyfin"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez l'administrateur"
},
"example": "johndoe"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true,
"help": {
"en": "Jellyfin has its own login system, you should make it public to let external clients access it (mobile app, etc.).",

View file

@ -15,8 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -28,8 +27,9 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
domain=$(ynh_app_setting_get --app="$app" --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -41,7 +41,6 @@ ynh_print_info --message="Declaring files to be backed up..."
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="/var/lib/jellyfin"
#=================================================
# BACKUP THE NGINX CONFIGURATION
@ -52,17 +51,10 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/lib/systemd/system/jellyfin.service"
ynh_backup --src_path="/etc/systemd/system/jellyfin.service.d"
ynh_backup --src_path="$config_path"
#=================================================
# END OF SCRIPT

View file

@ -22,6 +22,7 @@ new_path=$YNH_APP_NEW_PATH
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
@ -42,7 +43,7 @@ ynh_clean_setup () {
# 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"
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -71,7 +72,7 @@ fi
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server"
#=================================================
# MODIFY URL IN NGINX CONF
@ -112,10 +113,10 @@ fi
if [ $change_path -eq 1 ]
then
# If somehow <BaseUrl /> was not replaced during install
if grep -q "<BaseUrl />" "/etc/jellyfin/network.xml"; then
ynh_replace_string --match_string="<BaseUrl />" --replace_string="<BaseUrl>$new_path</BaseUrl>" --target_file="/etc/jellyfin/network.xml"
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"
else
ynh_replace_string --match_string="<BaseUrl>$old_path</BaseUrl>" --replace_string="<BaseUrl>$new_path</BaseUrl>" --target_file="/etc/jellyfin/network.xml"
ynh_replace_string --match_string="<BaseUrl>$old_path</BaseUrl>" --replace_string="<BaseUrl>$new_path</BaseUrl>" --target_file="$config_path/network.xml"
fi
fi

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
@ -36,9 +35,10 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/etc/jellyfin
final_path=/var/lib/jellyfin
config_path=/etc/jellyfin
test ! -e "$final_path" || ynh_die --message="There is already a directory: $final_path "
test ! -e "/var/lib/jellyfin" || ynh_die --message="There is already a directory: /var/lib/jellyfin "
test ! -e "$config_path" || ynh_die --message="There is already a directory: $config_path "
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -52,6 +52,7 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=config_path --value=$config_path
#=================================================
# STANDARD MODIFICATIONS
@ -93,20 +94,21 @@ ynh_system_user_create --username=$app
ynh_script_progression --message="Configuring the settings..." --weight=1
# Load services once to generate system.xml
systemctl enable jellyfin --quiet
systemctl start jellyfin
sleep 5
systemctl stop jellyfin
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Startup complete"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server"
# Port config
ynh_replace_string --match_string="<PublicPort>8096</PublicPort>" --replace_string="<PublicPort>$port</PublicPort>" --target_file="/etc/jellyfin/network.xml"
ynh_replace_string --match_string="<HttpServerPortNumber>8096</HttpServerPortNumber>" --replace_string="<HttpServerPortNumber>$port</HttpServerPortNumber>" --target_file="/etc/jellyfin/network.xml"
ynh_replace_string --match_string="<PublicPort>8096</PublicPort>" --replace_string="<PublicPort>$port</PublicPort>" --target_file="$config_path/network.xml"
ynh_replace_string --match_string="<HttpServerPortNumber>8096</HttpServerPortNumber>" --replace_string="<HttpServerPortNumber>$port</HttpServerPortNumber>" --target_file="$config_path/network.xml"
# BaseUrl config
ynh_replace_string --match_string="<BaseUrl />" --replace_string="<BaseUrl>$path_url</BaseUrl>" --target_file="/etc/jellyfin/network.xml"
ynh_replace_string --match_string="<BaseUrl />" --replace_string="<BaseUrl>$path_url</BaseUrl>" --target_file="$config_path/network.xml"
# Disable Setup Wizard
ynh_replace_string --match_string="<IsStartupWizardCompleted>false</IsStartupWizardCompleted>" --replace_string="<IsStartupWizardCompleted>true</IsStartupWizardCompleted>" --target_file="/etc/jellyfin/system.xml"
ynh_replace_string --match_string="<IsStartupWizardCompleted>false</IsStartupWizardCompleted>" --replace_string="<IsStartupWizardCompleted>true</IsStartupWizardCompleted>" --target_file="$config_path/system.xml"
ynh_store_file_checksum --file="$config_path/network.xml"
ynh_store_file_checksum --file="$config_path/system.xml"
#=================================================
# INSTALL LDAP PLUGIN
@ -115,32 +117,24 @@ ynh_script_progression --message="Installing LDAP plugin..." --weight=2
ynh_setup_source --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=ldap
mkdir -p /var/lib/jellyfin/plugins/configurations/
cp ../conf/LDAP-Auth.xml /var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml
ynh_add_config --template="../conf/LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R $app: $final_path
chown -R $app: /var/lib/jellyfin
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=2
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Jellyfin media center" --log_type="systemd"
#=================================================
# START SYSTEMD SERVICE

View file

@ -17,8 +17,6 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
@ -33,14 +31,6 @@ then
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
@ -49,22 +39,12 @@ ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=12
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="/etc/jellyfin"
ynh_secure_remove --file="/var/lib/jellyfin"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated nginx config
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
@ -28,27 +27,29 @@ ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app="$app" --key=domain)
path_url=$(ynh_app_setting_get --app="$app" --key=path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
ynh_webpath_available --domain="$domain" --path_url="$path_url" \
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d "$final_path" \
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
test ! -d "/var/lib/jellyfin" \
|| ynh_die --message="There is already a directory: /var/lib/jellyfin "
test ! -d $config_path \
|| ynh_die --message="There is already a directory: $config_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# 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"
@ -58,7 +59,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="/var/lib/jellyfin"
ynh_restore_file --origin_path="$config_path"
#=================================================
# RECREATE THE DEDICATED USER
@ -66,15 +67,15 @@ ynh_restore_file --origin_path="/var/lib/jellyfin"
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username="$app"
ynh_system_user_create --username=$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app: $final_path
chown -R $app: /var/lib/jellyfin
#=================================================
# SPECIFIC RESTORATION
@ -86,21 +87,12 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=7
# Define and install dependencies
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"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=2
ynh_restore_file --origin_path="/lib/systemd/system/jellyfin.service" 2>/dev/null
ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" 2>/dev/null
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Jellyfin media center" --log_type="systemd"
#=================================================
# START SYSTEMD SERVICE
@ -109,12 +101,6 @@ 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"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -19,11 +19,13 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -32,6 +34,14 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If db_name doesn't exist, create it
if [ -z "$config_path" ]; then
config_path=/var/lib/jellyfin
ynh_app_setting_set --app=$app --key=config_path --value=$config_path
final_path=/etc/jellyfin
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
@ -52,7 +62,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -65,7 +75,7 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server"
#=================================================
# NGINX CONFIGURATION
@ -98,18 +108,22 @@ ynh_system_user_create --username=$app
if [ -z "/etc/jellyfin/network.xml" ]; then
ynh_script_progression --message="Configuring the settings..." --weight=1
ynh_backup_if_checksum_is_different --file="$config_path/network.xml"
ynh_backup_if_checksum_is_different --file="$config_path/system.xml"
# Load services once to generate network.xml
systemctl enable jellyfin --quiet
systemctl start jellyfin
sleep 5
systemctl stop jellyfin
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Startup complete"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server"
# Port config
ynh_replace_string --match_string="<PublicPort>8096</PublicPort>" --replace_string="<PublicPort>$port</PublicPort>" --target_file="/etc/jellyfin/network.xml"
ynh_replace_string --match_string="<HttpServerPortNumber>8096</HttpServerPortNumber>" --replace_string="<HttpServerPortNumber>$port</HttpServerPortNumber>" --target_file="/etc/jellyfin/network.xml"
ynh_replace_string --match_string="<PublicPort>8096</PublicPort>" --replace_string="<PublicPort>$port</PublicPort>" --target_file="$config_path/network.xml"
ynh_replace_string --match_string="<HttpServerPortNumber>8096</HttpServerPortNumber>" --replace_string="<HttpServerPortNumber>$port</HttpServerPortNumber>" --target_file="$config_path/network.xml"
# BaseUrl config
ynh_replace_string --match_string="<BaseUrl />" --replace_string="<BaseUrl>$path_url</BaseUrl>" --target_file="/etc/jellyfin/network.xml"
ynh_replace_string --match_string="<BaseUrl />" --replace_string="<BaseUrl>$path_url</BaseUrl>" --target_file="$config_path/network.xml"
ynh_store_file_checksum --file="$config_path/network.xml"
ynh_store_file_checksum --file="$config_path/system.xml"
fi
#=================================================
@ -122,7 +136,7 @@ if [ ! -e "/var/lib/jellyfin/plugins/LDAP Authentication" ]; then
ynh_setup_source --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=ldap
mkdir -p /var/lib/jellyfin/plugins/configurations/
cp ../conf/LDAP-Auth.xml /var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml
ynh_add_config --template="../conf/LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml"
fi
#=================================================
@ -133,22 +147,13 @@ fi
# Set permissions on app files
chown -R $app: $final_path
chown -R $app: /var/lib/jellyfin
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Jellyfin media center" --log_type="systemd"
#=================================================
# START SYSTEMD SERVICE