From b9073598181c08727dbb03b1c42d045022fea0eb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 13 Mar 2022 17:21:40 +0100 Subject: [PATCH] Apply last example_ynh --- doc/.gitkeep | 0 doc/DESCRIPTION.md | 1 + doc/DESCRIPTION_fr.md | 1 + doc/DISCLAIMER.md | 8 ++++++ doc/DISCLAIMER_fr.md | 8 ++++++ doc/screenshots/.gitkeep | 0 manifest.json | 8 ++++-- scripts/_common.sh | 25 ++-------------- scripts/actions/reset_db | 4 +-- scripts/backup | 7 ++--- scripts/config | 2 +- scripts/install | 44 +++++++++++++++-------------- scripts/remove | 43 +++++++++++++++------------- scripts/restore | 37 +++++++++++++----------- scripts/upgrade | 61 ++++++++++++++++++++++------------------ 15 files changed, 133 insertions(+), 116 deletions(-) create mode 100644 doc/.gitkeep create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/DESCRIPTION_fr.md create mode 100644 doc/DISCLAIMER.md create mode 100644 doc/DISCLAIMER_fr.md create mode 100644 doc/screenshots/.gitkeep diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..7134d3d --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +MiniDLNA is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..def7b40 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +MiniDLNA est un simple serveur multimédia, dont le but est d'être entièrement compatible avec les clients DLNA/UPnP-AV. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..c283755 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,8 @@ +## Configuration + +Edit the file `/etc/minidlna.conf` to adjust the configuration of MiniDLNA. + +## YunoHost specific features + +* Use shared Multimedia Directories +* Linked to transmission, Nextcloud and all other app which use Multimedia Directories. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..5ae075a --- /dev/null +++ b/doc/DISCLAIMER_fr.md @@ -0,0 +1,8 @@ +## Configuration + +Éditez le fichier `/etc/minidlna.conf` pour ajuster la configuration de MiniDLNA. + +## Fonctionnalités spécifiques à YunoHost + +* Utilise les répertoires multimédia partagés. +* Lié à transmission, Nextcloud et toute autre application qui utilise les répertoires multimédia. diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/manifest.json b/manifest.json index f0e64f8..71936e0 100644 --- a/manifest.json +++ b/manifest.json @@ -6,8 +6,12 @@ "en": "Light DLNA server to share media files over the LAN", "fr": "Serveur DLNA léger pour partager les fichiers multimédia sur le réseau local" }, - "version": "1.0~ynh7", + "version": "1.0~ynh8", "url": "http://minidlna.sourceforge.net/", + "upstream": { + "license": "GPL-2.0", + "website": "http://minidlna.sourceforge.net" + }, "license": "GPL-2.0", "maintainer": { "name": "", @@ -18,7 +22,7 @@ "email": "maniackc_dev@crudelis.fr" }], "requirements": { - "yunohost": ">= 4.2.4" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [], diff --git a/scripts/_common.sh b/scripts/_common.sh index f744fb0..02c5e14 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,30 +1,11 @@ #!/bin/bash #================================================= -# PERSONAL HELPERS +# COMMON VARIABLES #================================================= -#================================================= -# BACKUP -#================================================= - -HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain - human=$(numfmt --to=iec --from-unit=1K $1) - echo $human -} - -CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant - file_to_analyse=$1 - backup_size=$(du --summarize "$file_to_analyse" | cut -f1) - free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d) - - if [ $free_space -le $backup_size ] - then - ynh_print_err "Espace insuffisant pour sauvegarder $file_to_analyse." - ynh_print_err "Espace disponible: $(HUMAN_SIZE $free_space)" - ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)" - fi -} +# dependencies used by the app +pkg_dependencies="minidlna" #================================================= # PACKAGE CHECK BYPASSING... diff --git a/scripts/actions/reset_db b/scripts/actions/reset_db index fb43cd2..0f4c22b 100755 --- a/scripts/actions/reset_db +++ b/scripts/actions/reset_db @@ -33,9 +33,9 @@ ynh_script_progression --message="Resetting the database..." --weight=9 # Get the last value for `db_dir` in the config file of minidlna db_directory=$(tac /etc/minidlna.conf | grep --max-count=1 "db_dir=" | cut -d'=' -f 2) -ynh_systemd_action --action=stop --service_name=minidlna +ynh_systemd_action --action=stop --service_name=$app ynh_secure_remove --file="$db_directory/files.db" -ynh_systemd_action --action=start --service_name=minidlna +ynh_systemd_action --action=start --service_name=$app #================================================= # END OF SCRIPT diff --git a/scripts/backup b/scripts/backup index c13a19f..cb34770 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# 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 @@ -29,15 +30,11 @@ app=$YNH_APP_INSTANCE_NAME ynh_print_info --message="Declaring files to be backed up..." #================================================= -# BACKUP OF INOTIFY'S CONFIG +# BACKUP VARIOUS FILES #================================================= ynh_backup --src_path="/etc/sysctl.d/90-inotify_minidlna.conf" -#================================================= -# BACKUP OF MINIDLNA CONFIGURATION -#================================================= - ynh_backup --src_path="/etc/minidlna.conf" #================================================= diff --git a/scripts/config b/scripts/config index 1056658..f80be5c 100644 --- a/scripts/config +++ b/scripts/config @@ -118,7 +118,7 @@ apply_config() { if [ $restart_minidlna -eq 1 ] then - ynh_systemd_action --action=restart --service_name=minidlna + ynh_systemd_action --service_name=$app --action="restart" fi # Set overwrite_settings diff --git a/scripts/install b/scripts/install index 247aaa1..888e1bc 100644 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,7 +10,7 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE FAILURE OF THE SCRIPT +# MANAGE SCRIPT FAILURE #================================================= # Exit if an error occurs during the execution of the script @@ -46,6 +46,15 @@ ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port ynh_exec_fully_quiet yunohost firewall allow --no-upnp UDP 1900 ynh_app_setting_set --app=$app --key=port --value=$port +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=45 + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# SPECIFIC SETUP #================================================= # CREATE YUNOHOST.MULTIMEDIA DIRECTORY #================================================= @@ -53,15 +62,6 @@ ynh_script_progression --message="Creating yunohost.multimedia directory..." --w ynh_multimedia_build_main_dir -#================================================= -# SPECIFIC SETUP -#================================================= -# INSTALL MINIDLNA -#================================================= -ynh_script_progression --message="Installing MiniDLNA..." --weight=45 - -ynh_install_app_dependencies minidlna - #================================================= # INCREASE INOTIFY'S LIMITS #================================================= @@ -75,12 +75,6 @@ then sysctl -p /etc/sysctl.d/90-inotify_minidlna.conf fi -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add minidlna --log="/var/log/minidlna.log" --needs_exposed_ports="1900" - #================================================= # CONFIGURE MINIDLNA #================================================= @@ -100,11 +94,19 @@ ynh_replace_string --match_string="^#wide_links=.*" --replace_string="wide_links ynh_store_file_checksum --file="/etc/minidlna.conf" #================================================= -# RESTART MINIDLNA +# INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Restarting MiniDLNA..." --weight=4 +ynh_script_progression --message="Integrating service in YunoHost..." -ynh_systemd_action --action=restart --service_name=minidlna +yunohost service add $app --log="/var/log/$app.log" --needs_exposed_ports="1900" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=4 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/$app.log" #================================================= # SEND A README FOR THE ADMIN @@ -130,4 +132,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of MiniDLNA completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 8281d88..6ba4007 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -21,37 +21,42 @@ port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Check if the service is declared in YunoHost -if ynh_exec_fully_quiet yunohost service status minidlna +# 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 - ynh_script_progression --message="Removing MiniDLNA service..." - yunohost service remove minidlna + ynh_script_progression --message="Removing $app service integration..." + yunohost service remove $app fi #================================================= -# CLOSE PORTS +# REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Closing ports $port and 1900..." --weight=15 +ynh_script_progression --message="Removing dependencies..." + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $port$" +then + ynh_script_progression --message="Closing port $port..." + ynh_exec_warn_less yunohost firewall disallow TCP $port +fi -ynh_exec_fully_quiet yunohost firewall disallow TCP $port ynh_exec_fully_quiet yunohost firewall disallow UDP 1900 #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE MINIDNLA +# REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing MiniDLNA..." --weight=6 - -ynh_remove_app_dependencies - -#================================================= -# REMOVE INOTIFY'S CONFIG -#================================================= -ynh_script_progression --message="Removing inotify's config..." +ynh_script_progression --message="Removing various files..." if [ -e "/etc/sysctl.d/90-inotify_minidlna.conf" ]; then ynh_secure_remove --file="/etc/sysctl.d/90-inotify_minidlna.conf" @@ -66,4 +71,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of MiniDLNA completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index dfcb67b..51aedcf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# 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 @@ -13,13 +14,16 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -44,38 +48,39 @@ ynh_script_progression --message="Creating yunohost.multimedia directory..." --w ynh_multimedia_build_main_dir #================================================= -# INSTALL MINIDLNA +# REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing MiniDLNA" --weight=45 +ynh_script_progression --message="Reinstalling dependencies..." --weight=45 -ynh_install_app_dependencies minidlna +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies #================================================= -# RESTORE INOTIFY'S CONFIG +# RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring inotify's config..." +ynh_script_progression --message="Restoring various files..." ynh_restore_file --origin_path="/etc/sysctl.d/90-inotify_minidlna.conf" if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options. then sysctl -p /etc/sysctl.d/90-inotify_minidlna.conf fi - -#================================================= -# RESTORE MINIDLNA CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring MiniDLNA configuration..." --weight=7 - # Delete the current config of minidlna, in order to replace it by the version from the backup ynh_secure_remove --file="/etc/minidlna.conf" ynh_restore_file --origin_path="/etc/minidlna.conf" -ynh_systemd_action --action=restart --service_name=minidlna +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --log="/var/log/$app.log" --needs_exposed_ports="1900" #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# START SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Starting a systemd service..." -yunohost service add minidlna --log="/var/log/minidlna.log" --needs_exposed_ports="1900" +ynh_systemd_action --service_name=$app --action=restart --log_path="/var/log/$app.log" #================================================= # SEND A README FOR THE ADMIN @@ -101,4 +106,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for MiniDLNA" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 42872c7..e6d6cdb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -25,9 +25,25 @@ friendly_name=$(ynh_app_setting_get --app=$app --key=friendly_name) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." 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)..." + +# 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 + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -58,19 +74,14 @@ if [ -n "$version" ]; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=2 +ynh_script_progression --message="Upgrading dependencies..." --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 +ynh_install_app_dependencies $pkg_dependencies +#================================================= +# SPECIFIC UPGRADE #================================================= # UPGRADE THE YUNOHOST.MULTIMEDIA DIRECTORY #================================================= @@ -78,13 +89,6 @@ ynh_script_progression --message="Upgrading the yunohost.multimedia directory... ynh_multimedia_build_main_dir -#================================================= -# UPGRADE MINIDLNA -#================================================= -ynh_script_progression --message="Upgrading MiniDLNA..." --weight=3 - -ynh_install_app_dependencies minidlna - #================================================= # INCREASE INOTIFY'S LIMITS #================================================= @@ -98,12 +102,6 @@ then sysctl -p /etc/sysctl.d/90-inotify_minidlna.conf fi -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add minidlna --log="/var/log/minidlna.log" --needs_exposed_ports="1900" - #================================================= # CONFIGURE MINIDLNA #================================================= @@ -126,11 +124,18 @@ then fi #================================================= -# RESTART MINIDLNA'S SERVICE +# INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Restarting MiniDLNA..." --weight=7 +ynh_script_progression --message="Integrating service in YunoHost..." -ynh_systemd_action --action=restart --service_name=minidlna +yunohost service add $app --log="/var/log/$app.log" --needs_exposed_ports="1900" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=7 + +ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/$app.log" #================================================= # SEND A README FOR THE ADMIN @@ -164,4 +169,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of MiniDLNA completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last