diff --git a/check_process b/check_process index fcdf735..e0d7b4c 100644 --- a/check_process +++ b/check_process @@ -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 diff --git a/manifest.json b/manifest.json index bb49b67..0989818 100644 --- a/manifest.json +++ b/manifest.json @@ -14,14 +14,15 @@ "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 4.1.0" + "yunohost": ">= 4.1.3" }, "multi_instance": false, "services": [ "nginx" ], "arguments": { - "install": [{ + "install" : [ + { "name": "domain", "type": "domain", "example": "example.com" diff --git a/scripts/backup b/scripts/backup index 59d6081..a1138ab 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -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,18 +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" --not_mandatory -ynh_backup --src_path="/usr/lib/systemd/system/jellyfin.service" --not_mandatory -ynh_backup --src_path="/etc/systemd/system/jellyfin.service.d" +ynh_backup --src_path="$config_path" #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index e660a15..6012a83 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -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 was not replaced during install - if grep -q "" "/etc/jellyfin/network.xml"; then - ynh_replace_string --match_string="" --replace_string="$new_path" --target_file="/etc/jellyfin/network.xml" + if grep -q "" "$config_path/network.xml"; then + ynh_replace_string --match_string="" --replace_string="$new_path" --target_file="$config_path/network.xml" else - ynh_replace_string --match_string="$old_path" --replace_string="$new_path" --target_file="/etc/jellyfin/network.xml" + ynh_replace_string --match_string="$old_path" --replace_string="$new_path" --target_file="$config_path/network.xml" fi fi diff --git a/scripts/install b/scripts/install index 604bb64..a7ae60c 100644 --- a/scripts/install +++ b/scripts/install @@ -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 " architecture=$(dpkg --print-architecture) if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then @@ -57,6 +57,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 @@ -114,20 +115,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="8096" --replace_string="$port" --target_file="/etc/jellyfin/network.xml" -ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="/etc/jellyfin/network.xml" +ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="$config_path/network.xml" +ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="$config_path/network.xml" # BaseUrl config -ynh_replace_string --match_string="" --replace_string="$path_url" --target_file="/etc/jellyfin/network.xml" +ynh_replace_string --match_string="" --replace_string="$path_url" --target_file="$config_path/network.xml" # Disable Setup Wizard -ynh_replace_string --match_string="false" --replace_string="true" --target_file="/etc/jellyfin/system.xml" +ynh_replace_string --match_string="false" --replace_string="true" --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 @@ -136,32 +138,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 diff --git a/scripts/remove b/scripts/remove index 184168a..4345a2e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -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 #================================================= @@ -53,22 +43,12 @@ apt remove jellyfin-ffmpeg # 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 #================================================= diff --git a/scripts/restore b/scripts/restore index 79d1605..f32a7ad 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -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,21 +27,22 @@ 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 " architecture=$(dpkg --print-architecture) if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then @@ -54,6 +54,7 @@ fi #================================================= # 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" @@ -63,7 +64,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 @@ -71,15 +72,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 @@ -106,22 +107,12 @@ ynh_exec_warn_less apt install $tempdir/jellyfin-ffmpeg.deb ynh_exec_warn_less apt install $tempdir/jellyfin-server.deb ynh_exec_warn_less apt install $tempdir/jellyfin-web.deb -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=2 - -ynh_restore_file --origin_path="/lib/systemd/system/jellyfin.service" --not_mandatory -ynh_restore_file --origin_path="/usr/lib/systemd/system/jellyfin.service" --not_mandatory -ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" -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 @@ -130,12 +121,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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6b2c2ab..00c7928 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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) @@ -37,6 +39,14 @@ if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1 fi +# If 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 @@ -57,7 +67,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 @@ -70,7 +80,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 @@ -119,18 +129,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="8096" --replace_string="$port" --target_file="/etc/jellyfin/network.xml" - ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="/etc/jellyfin/network.xml" + ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="$config_path/network.xml" + ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="$config_path/network.xml" # BaseUrl config - ynh_replace_string --match_string="" --replace_string="$path_url" --target_file="/etc/jellyfin/network.xml" + ynh_replace_string --match_string="" --replace_string="$path_url" --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 #================================================= @@ -143,7 +157,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 #================================================= @@ -154,22 +168,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