From 746b053171a59f449916b6f24bcdabe5e5542d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 9 Jan 2024 19:36:17 +0100 Subject: [PATCH] v2 --- check_process | 21 ---- config_panel.toml.old | 19 ---- doc/{DISCLAIMER.md => ADMIN.md} | 0 doc/{DISCLAIMER_fr.md => ADMIN_fr.md} | 0 doc/POST_INSTALL.md | 3 + manifest.json | 32 ------ scripts/_common.sh | 142 -------------------------- scripts/install | 20 +--- scripts/remove | 23 ----- scripts/restore | 44 -------- scripts/upgrade | 52 ---------- tests.toml | 11 ++ 12 files changed, 16 insertions(+), 351 deletions(-) delete mode 100644 check_process delete mode 100644 config_panel.toml.old rename doc/{DISCLAIMER.md => ADMIN.md} (100%) rename doc/{DISCLAIMER_fr.md => ADMIN_fr.md} (100%) create mode 100644 doc/POST_INSTALL.md delete mode 100644 manifest.json create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 817b6b6..0000000 --- a/check_process +++ /dev/null @@ -1,21 +0,0 @@ -;; Test paquet stable - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - #upgrade=1 from_commit=2c107b09144c9829be5cc94b202d0f766b2a0db4 - #upgrade=1 from_commit=7fa6b0a84e0cb24cd5a26d2f5d64f68875862f42 - backup_restore=1 - multi_instance=0 - change_url=0 -;;; Upgrade options - ; commit=2c107b09144c9829be5cc94b202d0f766b2a0db4 - name=01 May 2017 2c107b09144c9829be5cc94b202d0f766b2a0db4 - manifest_arg=version=A. Version of the Debian repositories - recommended& - ; commit=7fa6b0a84e0cb24cd5a26d2f5d64f68875862f42 - name=20 Jun 2019 7fa6b0a84e0cb24cd5a26d2f5d64f68875862f42 - manifest_arg=version=B. Latest version available for Debian& diff --git a/config_panel.toml.old b/config_panel.toml.old deleted file mode 100644 index b771f08..0000000 --- a/config_panel.toml.old +++ /dev/null @@ -1,19 +0,0 @@ -version = "0.1" -name = "Minidlna configuration panel" - - -[main] -name = "Minidlna configuration" - - [main.minidlna_configuration] - name = "Minidlna configuration" - - [main.minidlna_configuration.root_container] - ask = "Type of directory shown to the clients ?" - choices = ["Standard container", "Browse Directory", "Music", "Pictures", "Video"] - default = "Browse Directory" - - [main.minidlna_configuration.friendly_name] - ask = "Name of DLNA server shown to clients ?" - type = "text" - default = "Yunohost DLNA" diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..85da5f7 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,3 @@ +You can find a config file at /etc/minidlna.conf + +MiniDLNA is going to serve the files present in the directory /home/yunohost.multimedia/share diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 928aba4..0000000 --- a/manifest.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "MiniDLNA", - "id": "minidlna", - "packaging_format": 1, - "description": { - "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~ynh9", - "url": "http://minidlna.sourceforge.net/", - "upstream": { - "license": "GPL-2.0", - "website": "http://minidlna.sourceforge.net" - }, - "license": "GPL-2.0", - "maintainer": { - "name": "", - "email": "" - }, - "previous_maintainers": [{ - "name": "Maniack Crudelis", - "email": "maniackc_dev@crudelis.fr" - }], - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": false, - "services": [], - "arguments": { - "install" : [] - } -} diff --git a/scripts/_common.sh b/scripts/_common.sh index f212503..b02fb07 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -#REMOVEME? pkg_dependencies="minidlna" - #================================================= # PACKAGE CHECK BYPASSING... #================================================= @@ -28,142 +25,3 @@ IS_PACKAGE_CHECK () { #================================================= # EXPERIMENTAL HELPERS #================================================= - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] -# | arg: -m --app_message= - The file with the content to send to the administrator. -# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' -ynh_send_readme_to_admin() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) - local app_message - local recipients - local type - # Manage arguments with getopts - - ynh_handle_getopts_args "$@" - app_message="${app_message:-}" - recipients="${recipients:-root}" - type="${type:-install}" - - # Get the value of admin_mail_html -#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) - admin_mail_html="${admin_mail_html:-0}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - # Subject base - local mail_subject="☁️🆈🅽🅷☁️: \`$app\`" - - # Adapt the subject according to the type of mail required. - if [ "$type" = "backup" ]; then - mail_subject="$mail_subject has just been backup." - elif [ "$type" = "change_url" ]; then - mail_subject="$mail_subject has just been moved to a new URL!" - elif [ "$type" = "remove" ]; then - mail_subject="$mail_subject has just been removed!" - elif [ "$type" = "restore" ]; then - mail_subject="$mail_subject has just been restored!" - elif [ "$type" = "upgrade" ]; then - mail_subject="$mail_subject has just been upgraded!" - else # install - mail_subject="$mail_subject has just been installed!" - fi - - local mail_message="This is an automated message from your beloved YunoHost server. - -Specific information for the application $app. - -$(if [ -n "$app_message" ] -then - cat "$app_message" -else - echo "...No specific information..." -fi) - ---- -Automatic diagnosis data from YunoHost - -__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__" - - # Store the message into a file for further modifications. - echo "$mail_message" > mail_to_send - - # If a html email is required. Apply html tags to the message. - if [ "$admin_mail_html" -eq 1 ] - then - # Insert 'br' tags at each ending of lines. - ynh_replace_string "$" "
" mail_to_send - - # Insert starting HTML tags - sed --in-place '1s@^@\n\n\n\n@' mail_to_send - - # Keep tabulations - ynh_replace_string " " "\ \ " mail_to_send - ynh_replace_string "\t" "\ \ " mail_to_send - - # Insert url links tags - ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send - - # Insert pre tags - ynh_replace_string "__PRE_TAG1__" "
" mail_to_send
-		ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
-
-		# Insert finishing HTML tags
-		echo -e "\n\n" >> mail_to_send
-
-	# Otherwise, remove tags to keep a plain text.
-	else
-		# Remove URL tags
-		ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
-		ynh_replace_string "__URL_TAG2__" ": " mail_to_send
-
-		# Remove PRE tags
-		ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
-	fi
-
-	# Define binary to use for mail command
-	if [ -e /usr/bin/bsd-mailx ]
-	then
-		local mail_bin=/usr/bin/bsd-mailx
-	else
-		local mail_bin=/usr/bin/mail.mailutils
-	fi
-
-	if [ "$admin_mail_html" -eq 1 ]
-	then
-		content_type="text/html"
-	else
-		content_type="text/plain"
-	fi
-
-	# Send the email to the recipients
-	cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
-}
diff --git a/scripts/install b/scripts/install
index 6598c1b..3e402a1 100644
--- a/scripts/install
+++ b/scripts/install
@@ -12,10 +12,10 @@ source /usr/share/yunohost/helpers
 #=================================================
 # STORE SETTINGS FROM MANIFEST
 #=================================================
-#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=2
+ynh_script_progression --message="Storing installation settings..." --weight=2
 
 ynh_app_setting_set --app=$app --key=overwrite_settings --value=1
-#REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
+ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
 
 #=================================================
 # STANDARD MODIFICATIONS
@@ -82,22 +82,6 @@ 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
-#=================================================
-
-# Get main domain and buid the url of the admin panel of the app.
-admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
-
-echo "You can find a config file at /etc/minidlna.conf
-
-MiniDLNA is going to serve the files present in the directory /home/yunohost.multimedia/share
-
-Please have a look to the documentation to learn more how to use MiniDLNA, https://yunohost.org/#/app_minidlna
-" > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=install
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/scripts/remove b/scripts/remove
index a415f6e..3818552 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -9,15 +9,6 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# LOAD SETTINGS
-#=================================================
-#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
-
-#REMOVEME? app=$YNH_APP_INSTANCE_NAME
-
-#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
-
 #=================================================
 # STANDARD REMOVE
 #=================================================
@@ -31,24 +22,10 @@ then
 	yunohost service remove $app
 fi
 
-#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-#REMOVEME? ynh_script_progression --message="Removing dependencies..."
-
-# Remove metapackage and its dependencies
-#REMOVEME? 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 UDP 1900
 
 #=================================================
diff --git a/scripts/restore b/scripts/restore
index 11b7404..3d202bf 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -10,25 +10,6 @@
 source ../settings/scripts/_common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-#REMOVEME? ynh_clean_setup () {
-	ynh_clean_check_starting
-}
-# Exit if an error occurs during the execution of the script
-#REMOVEME? ynh_abort_if_errors
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-#REMOVEME? ynh_script_progression --message="Loading installation settings..."
-
-#REMOVEME? app=$YNH_APP_INSTANCE_NAME
-
-#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
-
 #=================================================
 # SPECIFIC RESTORE
 #=================================================
@@ -36,7 +17,6 @@ source /usr/share/yunohost/helpers
 #=================================================
 ynh_script_progression --message="Configuring firewall..." --weight=15
 
-ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port
 # Discovery Protocol SSDP for UPNP.
 ynh_exec_fully_quiet yunohost firewall allow --no-upnp UDP 1900
 
@@ -47,14 +27,6 @@ ynh_script_progression --message="Creating yunohost.multimedia directory..." --w
 
 ynh_multimedia_build_main_dir
 
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=45
-
-# Define and install dependencies
-#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
-
 #=================================================
 # RESTORE VARIOUS FILES
 #=================================================
@@ -82,22 +54,6 @@ ynh_script_progression --message="Starting a systemd service..."
 
 ynh_systemd_action --service_name=$app --action=restart --log_path="/var/log/$app.log"
 
-#=================================================
-# SEND A README FOR THE ADMIN
-#=================================================
-
-# Get main domain and buid the url of the admin panel of the app.
-admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
-
-echo "You can find a config file at /etc/minidlna.conf
-
-MiniDLNA is going to serve the files present in the directory /home/yunohost.multimedia/share
-
-Please have a look to the documentation to learn more how to use MiniDLNA, https://yunohost.org/#/app_minidlna
-" > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index d9dc53f..7126dd7 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -9,41 +9,12 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# LOAD SETTINGS
-#=================================================
-#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
-
-#REMOVEME? app=$YNH_APP_INSTANCE_NAME
-
-#REMOVEME? version=$(ynh_app_setting_get --app=$app --key=version)
-#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
-#REMOVEME? overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings)
-#REMOVEME? root_container=$(ynh_app_setting_get --app=$app --key=root_container)
-#REMOVEME? 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
-#=================================================
-#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
-
-# Backup the current version of the app
-#REMOVEME? ynh_backup_before_upgrade
-#REMOVEME? ynh_clean_setup () {
-	ynh_clean_check_starting
-	# Restore it if the upgrade fails
-#REMOVEME? 	ynh_restore_upgradebackup
-}
-# Exit if an error occurs during the execution of the script
-#REMOVEME? ynh_abort_if_errors
-
 #=================================================
 # ENSURE DOWNWARD COMPATIBILITY
 #=================================================
@@ -73,13 +44,6 @@ if [ -n "$version" ]; then
 	ynh_app_setting_delete --app=$app --key=version
 fi
 
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=3
-
-#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
-
 #=================================================
 # SPECIFIC UPGRADE
 #=================================================
@@ -137,22 +101,6 @@ 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
-#=================================================
-
-# Get main domain and buid the url of the admin panel of the app.
-admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
-
-echo "You can find a config file at /etc/minidlna.conf
-
-MiniDLNA is going to serve the files present in the directory /home/yunohost.multimedia/share
-
-Please have a look to the documentation to learn more how to use MiniDLNA, https://yunohost.org/#/app_minidlna
-" > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=upgrade
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/tests.toml b/tests.toml
new file mode 100644
index 0000000..1774c62
--- /dev/null
+++ b/tests.toml
@@ -0,0 +1,11 @@
+test_format = 1.0
+
+[default]
+
+    # ------------
+    # Tests to run
+    # ------------
+
+     exclude = ["install.subdir", "install.private", "install.multi", "change_url"]  # The test IDs to be used in only/exclude statements are: install.root, install.subdir, install.nourl, install.multi, backup_restore, upgrade, upgrade.someCommitId change_url
+    # NB: you should NOT need this except if you really have a good reason...
+