1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minidlna_ynh.git synced 2024-09-03 19:36:34 +02:00
This commit is contained in:
Éric Gaspar 2024-01-09 19:36:17 +01:00
parent 67da09d548
commit 746b053171
12 changed files with 16 additions and 351 deletions

View file

@ -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&

View file

@ -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"

3
doc/POST_INSTALL.md Normal file
View file

@ -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

View file

@ -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" : []
}
}

View file

@ -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 "$" "<br>" mail_to_send
# Insert starting HTML tags
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
# Keep tabulations
ynh_replace_string " " "\&#160;\&#160;" mail_to_send
ynh_replace_string "\t" "\&#160;\&#160;" mail_to_send
# Insert url links tags
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
# Insert pre tags
ynh_replace_string "__PRE_TAG1__" "<pre>" mail_to_send
ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
# Insert finishing HTML tags
echo -e "\n</body>\n</html>" >> 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"
}

View file

@ -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
#=================================================

View file

@ -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
#=================================================

View file

@ -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
#=================================================

View file

@ -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
#=================================================

11
tests.toml Normal file
View file

@ -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...