1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minidlna_ynh.git synced 2024-09-03 19:36:34 +02:00

Merge pull request #18 from YunoHost-Apps/testing

Testing
This commit is contained in:
Kayou 2020-12-02 16:37:51 +01:00 committed by GitHub
commit 21e4d8475a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 373 additions and 1009 deletions

29
CHANGELOG.md Normal file
View file

@ -0,0 +1,29 @@
Changelog
=========
## Unreleased
- Nothing for now...
## [1.0~ynh5](https://github.com/YunoHost-Apps/minidlna_ynh/pull/14) - 2019-02-03
#### Added
- [Add progression bar](https://github.com/YunoHost-Apps/minidlna_ynh/pull/14/commits/be7ea84d8ffd37175b424d040918c458047fecf9)
* [Changelog & html email](https://github.com/YunoHost-Apps/minidlna_ynh/pull/14/commits/ad18af04b853609f0d5c6089a035671ce2e0d96f)
## [1.0~ynh4](https://github.com/YunoHost-Apps/minidlna_ynh/pull/13) - 2019-01-21
#### Changed
- [Update to last standart](https://github.com/YunoHost-Apps/minidlna_ynh/pull/13/commits/c51297661c89a304f585d973fa5caa24c275036b)
## [1.0~ynh3](https://github.com/YunoHost-Apps/minidlna_ynh/pull/12) - 2018-09-30
#### Added
- [Panel-config + actions fully tested](https://github.com/YunoHost-Apps/minidlna_ynh/pull/12/commits/945664af7e4215c099d7b623d74a57207bdf7dae)
## [1.0~ynh3](https://github.com/YunoHost-Apps/minidlna_ynh/pull/01) - 2018-07-16
#### Changed
- [Upgrade helpers](https://github.com/YunoHost-Apps/minidlna_ynh/pull/11/commits/e344e99aef40915c63f97d6f82fe50c5ff07af0d)

View file

@ -1,6 +1,6 @@
# MiniDLNA for YunoHost
[![Integration level](https://dash.yunohost.org/integration/minidlna.svg)](https://dash.yunohost.org/appci/app/minidlna)
[![Integration level](https://dash.yunohost.org/integration/minidlna.svg)](https://dash.yunohost.org/appci/app/minidlna) ![](https://ci-apps.yunohost.org/ci/badges/minidlna.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/minidlna.maintain.svg)
[![Install MiniDLNA with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=minidlna)
*[Lire ce readme en français.](./README_fr.md)*
@ -12,7 +12,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
MiniDLNA is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients.
**Shipped version:** Debian repositories versions. Currently 1.1.2 and 1.1.6
**Shipped version:** Debian repositories versions. Currently 1.2.1
## Screenshots
@ -31,7 +31,7 @@ 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.
* Linked to transmission, Nextcloud and all other app which use Multimedia Directories.
#### Multi-users support
@ -39,9 +39,8 @@ Not relevant.
#### Supported architectures
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/)
* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/)
## Limitations
@ -55,8 +54,7 @@ Not relevant.
---
Developers infos
----------------
## Developers infos
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/minidlna_ynh/tree/testing).

View file

@ -1,6 +1,6 @@
# MiniDLNA pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/minidlna.svg)](https://dash.yunohost.org/appci/app/minidlna)
[![Niveau d'intégration](https://dash.yunohost.org/integration/minidlna.svg)](https://dash.yunohost.org/appci/app/minidlna) ![](https://ci-apps.yunohost.org/ci/badges/minidlna.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/minidlna.maintain.svg)
[![Installer MiniDLNA avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=minidlna)
*[Read this readme in english.](./README.md)*
@ -12,7 +12,7 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst
MiniDLNA est un simple serveur multimédia, dont le but est d'être entièrement compatible avec les clients DLNA/UPnP-AV.
**Version embarquée:** Versions des dépôts Debian. Actuellement 1.1.2 et 1.1.6
**Version embarquée :** Versions des dépôts Debian. Actuellement 1.2.1
## Captures d'écran
@ -22,7 +22,7 @@ Aucune démo pour cette application.
## Configuration
Editez le fichier `/etc/minidlna.conf` pour ajuster la configuration de MiniDLNA.
Éditez le fichier `/etc/minidlna.conf` pour ajuster la configuration de MiniDLNA.
## Documentation
@ -31,7 +31,7 @@ Editez 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.
* Lié à transmission, Nextcloud et toute autre application qui utilise les répertoires multimédia.
#### Support multi-utilisateurs
@ -39,9 +39,8 @@ Non applicable.
#### Architectures supportées.
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/)
* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/)
## Limitations
@ -55,8 +54,7 @@ Non applicable.
---
Informations à l'intention des développeurs
----------------
## Informations à l'intention des développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/minidlna_ynh/tree/testing).

View file

@ -1,25 +0,0 @@
[{
"id": "install_standard",
"name": "Install the version from stable repository",
"command": "/bin/bash scripts/actions/install_standard",
"user": "root",
"accepted_return_codes": [0]
},
{
"id": "install_backports",
"name": "Install the version from backports repository",
"command": "/bin/bash scripts/actions/install_backports",
"user": "root",
"accepted_return_codes": [0]
},
{
"id": "reset_db",
"name": "Reinitialise the database",
"command": "/bin/bash scripts/actions/reset_db",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Remove the database and force Minidlna to create a new one.",
"fr": "Supprime la base de donnée et force Minidlna a en recréer une nouvelle."
}
}]

4
actions.toml Normal file
View file

@ -0,0 +1,4 @@
[reset_db]
name = "Reinitialise the database"
command = "/bin/bash scripts/actions/reset_db"
description = "Remove the database and force Minidlna to create a new one."

View file

@ -1,25 +1,26 @@
# Minidlna
# MiniDLNA
Minidlna is a lightweight [dlna](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) server.
MiniDLNA is a lightweight [DLNA](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) server.
It allows to easily share multimedia files with any compatible devices present on the LAN.
Minidlna does not have a graphical interface, but does not require any special configuration.
MiniDLNA does not have a graphical interface, but does not require any special configuration.
### What multimedia files are shared?
Minidlna sharing the folder /home/yunohost.multimedia/share, which is common to each user in /home/$USER/Multimedia/Share.
[More information about multimedia files here.](Https://github.com/maniackcrudelis/yunohost.multimedia)
MiniDLNA is sharing the folder `/home/yunohost.multimedia/share`, which is common to each user in `/home/$USER/Multimedia/Share`.
[More information about multimedia files here.](https://github.com/YunoHost-Apps/yunohost.multimedia)
If [transmission](https://github.com/Kloadut/transmission_ynh) is installed, the downloaded media will be available in dlna.
If [Transmission](https://github.com/YunoHost-Apps/transmission_ynh) is installed, the downloaded media will be available in DLNA.
### How to view and play media files shared by miniDLNA?
### How to view and play media files shared by minidlna?
To view and play media files, all you need is a compatible client DLNA/UPNP.
The majority of set-top boxes provided by ISPs are DLNA compatible, simply look for sources of external media.
This is also true for the latest generation game consoles connected to internet.
Some TV and blu-ray player is also DLNA compatible.
Some TV and Blu-ray player are also DLNA compatible.
In any case, it is generally sufficient to seek external sources, USB etc, to find the DLNA server, displayed under the name **Yunohost DLNA**.
In any case, it is generally sufficient to seek external sources, USB etc., to find the DLNA server, displayed under the name **YunoHost DLNA**.
There are a multitude of DLNA client for all platforms, including the following [not exhaustive list](https://en.wikipedia.org/wiki/List_of_UPnP_AV_media_servers_and_clients#UPnP_AV_clients).
In general, a DLNA client does not require any special configuration to access the media sharing.

View file

@ -1,25 +1,28 @@
# Minidlna
# MiniDLNA
Minidlna est un serveur [dlna](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) ultra léger.
MiniDLNA est un serveur [DLNA](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) ultra léger.
Il permet de partager très simplement les fichiers multimédias avec tout les appareils compatibles présent sur le réseau local.
Minidlna ne dispose pas d'une interface graphique, mais ne nécessite pas de configuration particulière.
### Quels fichiers multimédias sont partagés?
Minidlna partage le dossier /home/yunohost.multimedia/share, qui est commun à chaque utilisateur dans le dossier /home/$USER/Multimedia/Share.
[Plus d'informations sur les dossiers multimedia ici.](https://github.com/maniackcrudelis/yunohost.multimedia)
Si [transmission](https://github.com/Kloadut/transmission_ynh) est installé, les médias téléchargés seront disponible en dlna.
Minidlna partage le dossier `/home/yunohost.multimedia/share`, qui est commun à chaque utilisateur dans le dossier `/home/$USER/Multimedia/Share`.
[Plus d'informations sur les dossiers multimedia ici.](https://github.com/YunoHost-Apps/yunohost.multimedia)
Si [Transmission](https://github.com/YunoHost-Apps/transmission_ynh) est installé, les médias téléchargés seront disponible en DLNA.
### Comment consulter et lire les fichiers multimédias partagés par miniDLNA?
### Comment consulter et lire les fichiers multimédias partagés par minidlna?
Pour voir et lire les fichiers multimédias, il suffit de disposer d'un client compatible DLNA/UPNP.
La majorité des décodeurs TV fourni par les FAI sont compatible DLNA, il suffit de chercher les sources de médias externe.
C'est le cas également pour les consoles de jeux dernière génération connectée à internet.
Certaines TV et lecteur blu-ray sont également compatibles DLNA.
Certaines TV et lecteur Blu-ray sont également compatibles DLNA.
Dans tout les cas, il suffit en général d'aller chercher les sources externes, USB etc, pour trouver le serveur DLNA, affiché sous le nom **Yunohost DLNA**.
Dans tout les cas, il suffit en général d'aller chercher les sources externes, USB etc., pour trouver le serveur DLNA, affiché sous le nom **Yunohost DLNA**.
Il existe une multitude de client DLNA pour toutes les plateformes, dont voici une [liste non exhaustive](https://en.wikipedia.org/wiki/List_of_UPnP_AV_media_servers_and_clients#UPnP_AV_clients).
De manière générale, un client DLNA ne nécessite pas de configuration particulière pour accéder au partage de fichiers multimédias.

View file

@ -1,6 +1,4 @@
;; Test paquet stable
; Manifest
version="A. Version of the Debian repositories - recommended"
; Checks
pkg_linter=1
setup_sub_dir=0
@ -10,38 +8,13 @@
setup_public=0
upgrade=1
upgrade=1 from_commit=2c107b09144c9829be5cc94b202d0f766b2a0db4
upgrade=1 from_commit=7fa6b0a84e0cb24cd5a26d2f5d64f68875862f42
backup_restore=1
multi_instance=0
incorrect_path=0
port_already_use=1 (48200)
change_url=0
;; Test paquet backports
; Manifest
version="B. Latest version available for Debian"
; Checks
setup_sub_dir=0
setup_root=0
setup_nourl=1
setup_private=0
setup_public=0
upgrade=1
backup_restore=0
multi_instance=0
incorrect_path=0
port_already_use=0
change_url=0
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# Level 4: Pas de gestion des utilisateurs
Level 4=na
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options
Email=
Notification=down
@ -49,3 +22,6 @@ Notification=down
; 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 +0,0 @@
deb http://http.debian.net/debian __CODENAME__-backports main

View file

@ -1,49 +0,0 @@
{
"name": "Minidlna configuration panel",
"version": "0.1",
"panel": [{
"name": "Minidlna configuration",
"id": "main",
"sections": [{
"name": "Minidlna configuration",
"id": "minidlna_configuration",
"options": [{
"name": "Type of directory shown to the clients ?",
"help": "We can't use a choices field for now. In the meantime please choose between one of this values:<br>Standard container, Browse Directory, Music, Pictures or Video.",
"id": "root_container",
"type": "text",
"//": "\"choices\" : [\"Standard container\", \"Browse Directory\", \"Music\", \"Pictures\", \"Video\"]",
"default" : "Browse Directory"
},
{
"name": "Name of DLNA server shown to clients ?",
"id": "friendly_name",
"type": "text",
"default": "Yunohost DLNA"
}]
},
{
"name": "Overwriting config files",
"id": "overwrite_files",
"options": [{
"name": "Overwrite the config file minidlna.conf ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_settings",
"type": "bool",
"default": true
}]
},
{
"name": "Global configuration",
"id": "global_config",
"options": [{
"name": "Send HTML email to admin ?",
"help": "Allow app scripts to send HTML mails instead of plain text.",
"id": "email_type",
"type": "bool",
"default": true
}]
}]
}
]
}

39
config_panel.toml Normal file
View file

@ -0,0 +1,39 @@
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"
[main.overwrite_files]
name = "Overwriting config files"
[main.overwrite_files.overwrite_settings]
ask = "Overwrite the config file minidlna.conf ?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.global_config]
name = "Global configuration"
[main.global_config.email_type]
ask = "Send HTML email to admin ?"
type = "boolean"
default = true
help = "Allow app scripts to send HTML mails instead of plain text."

View file

@ -6,7 +6,7 @@
"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~ynh5",
"version": "1.0~ynh6",
"url": "http://minidlna.sourceforge.net/",
"license": "GPL-2.0",
"maintainer": {
@ -18,21 +18,11 @@
"email": "maniackc_dev@crudelis.fr"
}],
"requirements": {
"yunohost": ">= 3.4"
"yunohost": ">= 3.6"
},
"multi_instance": false,
"services": [],
"arguments": {
"install" : [
{
"name": "version",
"ask": {
"en": "Select the minidlna version to install",
"fr": "Choix de la version de minidlna à installer"
},
"choices": ["A. Version of the Debian repositories - recommended", "B. Latest version available for Debian"],
"default": "A. Version of the Debian repositories - recommended"
}
]
"install" : []
}
}

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# BACKUP
#=================================================
@ -27,25 +31,12 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
#=================================================
IS_PACKAGE_CHECK () {
return $(env | grep -c container=lxc)
}
#=================================================
# BOOLEAN CONVERTER
#=================================================
bool_to_01 () {
local var="$1"
[ "$var" = "true" ] && var=1
[ "$var" = "false" ] && var=0
echo "$var"
}
bool_to_true_false () {
local var="$1"
[ "$var" = "1" ] && var=true
[ "$var" = "0" ] && var=false
echo "$var"
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]
then
return 0
else
return 1
fi
}
#=================================================
@ -129,359 +120,6 @@ ynh_multimedia_addaccess () {
usermod -a -G multimedia $user_name
}
#=================================================
# Create a dedicated fail2ban config (jail and filter conf files)
#
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
# | arg: -l, --logpath= - Log file to be checked by fail2ban
# | arg: -r, --failregex= - Failregex to be looked for by fail2ban
# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3
# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https
ynh_add_fail2ban_config () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= )
local logpath
local failregex
local max_retry
local ports
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
max_retry=${max_retry:-3}
ports=${ports:-http,https}
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
tee $finalfail2banjailconf <<EOF
[$app]
enabled = true
port = $ports
filter = $app
logpath = $logpath
maxretry = $max_retry
EOF
tee $finalfail2banfilterconf <<EOF
[INCLUDES]
before = common.conf
[Definition]
failregex = $failregex
ignoreregex =
EOF
ynh_store_file_checksum "$finalfail2banjailconf"
ynh_store_file_checksum "$finalfail2banfilterconf"
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
systemctl reload fail2ban
else
systemctl restart fail2ban
fi
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
if [ -n "$fail2ban_error" ]
then
echo "[ERR] Fail2ban failed to load the jail for $app" >&2
echo "WARNING${fail2ban_error#*WARNING}" >&2
fi
}
# Remove the dedicated fail2ban config (jail and filter conf files)
#
# usage: ynh_remove_fail2ban_config
ynh_remove_fail2ban_config () {
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
systemctl reload fail2ban
else
systemctl restart fail2ban
fi
}
#=================================================
# Read the value of a key in a ynh manifest file
#
# usage: ynh_read_manifest manifest key
# | arg: -m, --manifest= - Path of the manifest to read
# | arg: -k, --key= - Name of the key to find
ynh_read_manifest () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [m]=manifest= [k]=manifest_key= )
local manifest
local manifest_key
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$manifest_key'])"
}
# Read the upstream version from the manifest
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
# For example : 4.3-2~ynh3
# This include the number before ~ynh
# In the last example it return 4.3-2
#
# usage: ynh_app_upstream_version [-m manifest]
# | arg: -m, --manifest= - Path of the manifest to read
ynh_app_upstream_version () {
declare -Ar args_array=( [m]=manifest= )
local manifest
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
manifest="${manifest:-../manifest.json}"
if [ ! -e "$manifest" ]; then
manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
echo "${version_key/~ynh*/}"
}
# Read package version from the manifest
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
# For example : 4.3-2~ynh3
# This include the number after ~ynh
# In the last example it return 3
#
# usage: ynh_app_package_version [-m manifest]
# | arg: -m, --manifest= - Path of the manifest to read
ynh_app_package_version () {
declare -Ar args_array=( [m]=manifest= )
local manifest
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
manifest="${manifest:-../manifest.json}"
if [ ! -e "$manifest" ]; then
manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
echo "${version_key/*~ynh/}"
}
# Checks the app version to upgrade with the existing app version and returns:
# - UPGRADE_APP if the upstream app version has changed
# - UPGRADE_PACKAGE if only the YunoHost package has changed
#
## It stops the current script without error if the package is up-to-date
#
# This helper should be used to avoid an upgrade of an app, or the upstream part
# of it, when it's not needed
#
# To force an upgrade, even if the package is up to date,
# you have to set the variable YNH_FORCE_UPGRADE before.
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
#
# usage: ynh_check_app_version_changed
ynh_check_app_version_changed () {
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
local package_check=${PACKAGE_CHECK_EXEC:-0}
# By default, upstream app version has changed
local return_value="UPGRADE_APP"
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0)
local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")"
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0)
local update_upstream_version="$(ynh_app_upstream_version)"
if [ "$current_version" == "$update_version" ] ; then
# Complete versions are the same
if [ "$force_upgrade" != "0" ]
then
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
unset YNH_FORCE_UPGRADE
elif [ "$package_check" != "0" ]
then
echo "Upgrade forced for package check." >&2
else
ynh_die "Up-to-date, nothing to do" 0
fi
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
# Upstream versions are the same, only YunoHost package versions differ
return_value="UPGRADE_PACKAGE"
fi
echo $return_value
}
#=================================================
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
#
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
# | arg: -n, --service_name= - Name of the service to reload. Default : $app
# | arg: -a, --action= - Action to perform with systemctl. Default: start
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot.
# If not defined it don't wait until the service is completely started.
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
# | arg: -e, --length= - Length of the error log : Default : 20
ynh_systemd_action() {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
local service_name
local action
local line_match
local length
local log_path
local timeout
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local service_name="${service_name:-$app}"
local action=${action:-start}
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
local length=${length:-20}
local timeout=${timeout:-300}
# Start to read the log
if [[ -n "${line_match:-}" ]]
then
local templog="$(mktemp)"
# Following the starting of the app in its log
if [ "$log_path" == "systemd" ] ; then
# Read the systemd journal
journalctl -u $service_name -f --since=-45 > "$templog" &
else
# Read the specified log file
tail -F -n0 "$log_path" > "$templog" &
fi
# Get the PID of the tail command
local pid_tail=$!
fi
echo "${action^} the service $service_name" >&2
systemctl $action $service_name \
|| ( journalctl --lines=$length -u $service_name >&2 \
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
; false )
# Start the timeout and try to find line_match
if [[ -n "${line_match:-}" ]]
then
local i=0
for i in $(seq 1 $timeout)
do
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
if grep --quiet "$line_match" "$templog"
then
echo "The service $service_name has correctly started." >&2
break
fi
echo -n "." >&2
sleep 1
done
if [ $i -eq $timeout ]
then
echo "The service $service_name didn't fully started before the timeout." >&2
echo "Please find here an extract of the end of the log of the service $service_name:"
journalctl --lines=$length -u $service_name >&2
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
fi
echo ""
ynh_clean_check_starting
fi
}
# Clean temporary process and file used by ynh_check_starting
# (usually used in ynh_clean_setup scripts)
#
# usage: ynh_clean_check_starting
ynh_clean_check_starting () {
# Stop the execution of tail.
kill -s 15 $pid_tail 2>&1
ynh_secure_remove "$templog" 2>&1
}
#=================================================
# Print a message as INFO and show progression during an app script
#
# usage: ynh_script_progression --message=message [--weight=weight] [--time]
# | arg: -m, --message= - The text to print
# | arg: -w, --weight= - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script.
# | arg: -t, --time= - Print the execution time since the last call to this helper. Especially usefull to define weights.
# | arg: -l, --last= - Use for the last call of the helper, to fill te progression bar.
increment_progression=0
previous_weight=0
# Define base_time when the file is sourced
base_time=$(date +%s)
ynh_script_progression () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last )
local message
local weight
local time
local last
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
weight=${weight:-1}
time=${time:-0}
last=${last:-0}
# Get execution time since the last $base_time
local exec_time=$(( $(date +%s) - $base_time ))
base_time=$(date +%s)
# Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented.
local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)"
# Get the number of call with a weight value
local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0)
# Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight
local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')"
# Get the weight of each occurrences of 'ynh_script_progression' in the script using -w
local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')"
# Each value will be on a different line.
# Remove each 'end of line' and replace it by a '+' to sum the values.
local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 ))
# max_progression is a total number of calls to this helper.
# Less the number of calls with a weight value.
# Plus the total of weight values
local max_progression=$(( $helper_calls - $weight_calls + $weight_values ))
# Increment each execution of ynh_script_progression in this script by the weight of the previous call.
increment_progression=$(( $increment_progression + $previous_weight ))
# Store the weight of the current call in $previous_weight for next call
previous_weight=$weight
# Set the scale of the progression bar
local scale=20
# progress_string(1,2) should have the size of the scale.
local progress_string1="####################"
local progress_string0="...................."
# Reduce $increment_progression to the size of the scale
if [ $last -eq 0 ]
then
local effective_progression=$(( $increment_progression * $scale / $max_progression ))
# If last is specified, fill immediately the progression_bar
else
local effective_progression=$scale
fi
# Build $progression_bar from progress_string(1,2) according to $effective_progression
local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}"
local print_exec_time=""
if [ $time -eq 1 ]
then
print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]"
fi
ynh_print_info "[$progression_bar] > ${message}${print_exec_time}"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
@ -627,231 +265,153 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
#=================================================
ynh_debian_release () {
lsb_release --codename --short
}
is_stretch () {
if [ "$(ynh_debian_release)" == "stretch" ]
then
return 0
else
return 1
fi
}
is_jessie () {
if [ "$(ynh_debian_release)" == "jessie" ]
then
return 0
else
return 1
fi
}
#=================================================
ynh_maintenance_mode_ON () {
# Load value of $path_url and $domain from the config if their not set
if [ -z $path_url ]; then
path_url=$(ynh_app_setting_get $app path)
fi
if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain)
fi
# Create an html to serve as maintenance notice
echo "<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="3">
<title>Your app $app is currently under maintenance!</title>
<style>
body {
width: 70em;
margin: 0 auto;
}
</style>
</head>
<body>
<h1>Your app $app is currently under maintenance!</h1>
<p>This app has been put under maintenance by your administrator at $(date)</p>
<p>Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.</p>
</body>
</html>" > "/var/www/html/maintenance.$app.html"
# Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect;
# Use another location, to not be in conflict with the original config file
location ${path_url}_maintenance/ {
alias /var/www/html/ ;
try_files maintenance.$app.html =503;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
# The current config file will redirect all requests to the root of the app.
# To keep the full path, we can use the following rewrite rule:
# rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
# The difference will be in the $1 at the end, which keep the following queries.
# But, if it works perfectly for a html request, there's an issue with any php files.
# This files are treated as simple files, and will be downloaded by the browser.
# Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was.
systemctl reload nginx
}
ynh_maintenance_mode_OFF () {
# Load value of $path_url and $domain from the config if their not set
if [ -z $path_url ]; then
path_url=$(ynh_app_setting_get $app path)
fi
if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain)
fi
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
sleep 4
# Then remove the temporary files used for the maintenance.
rm "/var/www/html/maintenance.$app.html"
rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx
}
#=================================================
# Download and check integrity of a file from app.src_file
# Create a changelog for an app after an upgrade from the file CHANGELOG.md.
#
# The file conf/app.src_file need to contains:
# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source]
# | arg: -f --format= - Format in which the changelog will be printed
# markdown: Default format.
# html: Turn urls into html format.
# plain: Plain text changelog
# | arg: -o --output= - Output file for the changelog file (Default ./changelog)
# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md)
#
# FILE_URL=Address to download the file
# FILE_SUM=Control sum
# # (Optional) Program to check the integrity (sha256sum, md5sum...)
# # default: sha256
# FILE_SUM_PRG=sha256
# # (Optionnal) Name of the local archive (offline setup support)
# # default: Name of the downloaded file.
# FILENAME=example.deb
#
# usage: ynh_download_file --dest_dir="/destination/directory" [--source_id=myfile]
# | arg: -d, --dest_dir= - Directory where to download the file
# | arg: -s, --source_id= - Name of the source file 'app.src_file' if it isn't '$app'
ynh_download_file () {
# The changelog is printed into the file ./changelog and ./changelog_lite
ynh_app_changelog () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [d]=dest_dir= [s]=source_id= )
local dest_dir
local source_id
local legacy_args=foc
declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
local format
local output
local changelog
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
format=${format:-markdown}
output=${output:-changelog}
changelog=${changelog:-../CHANGELOG.md}
source_id=${source_id:-app} # If the argument is not given, source_id equals "$app"
local original_changelog="$changelog"
local temp_changelog="changelog_temp"
local final_changelog="$output"
# Load value from configuration file (see above for a small doc about this file
# format)
local src_file="$YNH_CWD/../conf/${source_id}.src_file"
# If the src_file doesn't exist, use the backup path instead, with a "settings" directory
if [ ! -e "$src_file" ]
if [ ! -n "$original_changelog" ]
then
src_file="$YNH_CWD/../settings/conf/${source_id}.src_file"
fi
local file_url=$(grep 'FILE_URL=' "$src_file" | cut -d= -f2-)
local file_sum=$(grep 'FILE_SUM=' "$src_file" | cut -d= -f2-)
local file_sumprg=$(grep 'FILE_SUM_PRG=' "$src_file" | cut -d= -f2-)
local filename=$(grep 'FILENAME=' "$src_file" | cut -d= -f2-)
# Default value
file_sumprg=${file_sumprg:-sha256sum}
if [ "$filename" = "" ] ; then
filename="$(basename "$file_url")"
fi
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${filename}"
if test -e "$local_src"
then # Use the local source file if it is present
cp $local_src $filename
else # If not, download the source
local out=`wget -nv -O $filename $file_url 2>&1` || ynh_print_err $out
echo "No changelog available..." > "$final_changelog"
echo "No changelog available..." > "${final_changelog}_lite"
return 0
fi
# Check the control sum
echo "${file_sum} ${filename}" | ${file_sumprg} -c --status \
|| ynh_die "Corrupt file"
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
# Create the destination directory, if it's not already.
mkdir -p "$dest_dir"
# Get the line of the version to update to into the changelog
local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
# If there's no entry for this version yet into the changelog
# Get the first available version
if [ -z "$update_version_line" ]
then
update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
fi
# Move the file to its destination
mv $filename $dest_dir
# Get the length of the complete changelog.
local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
# Cut the file before the version to update to.
tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
# Get the length of the troncated changelog.
changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
# Get the line of the current version into the changelog
# Keep only the last line found
local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
# If there's no entry for this version into the changelog
# Get the last available version
if [ -z "$current_version_line" ]
then
current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
fi
# Cut the file before the current version.
# Then grep the previous version into the changelog to get the line number of the previous version
local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
"$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
# If there's no previous version into the changelog
# Go until the end of the changelog
if [ -z "$previous_version_line" ]
then
previous_version_line=$changelog_length
fi
# Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
if [ "$format" = "html" ]
then
# Replace markdown links by html links
ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --target_file="$final_changelog"
elif [ "$format" = "plain" ]
then
# Change title format.
ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
# Change modifications lines format.
ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
fi
# else markdown. As the file is already in markdown, nothing to do.
# Keep only important changes into the changelog
# Remove all minor changes
sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
# Remove all blank lines (to keep a clear workspace)
sed --in-place '/^$/d' "${final_changelog}_lite"
# Add a blank line at the end
echo "" >> "${final_changelog}_lite"
# Clean titles if there's no significative changes
local line
local previous_line=""
while read line <&3
do
if [ -n "$previous_line" ]
then
# Remove the line if it's a title or a blank line, and the previous one was a title as well.
if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
then
ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
fi
fi
previous_line="$line"
done 3< "${final_changelog}_lite"
# Remove all blank lines again
sed --in-place '/^$/d' "${final_changelog}_lite"
# Restore changelog format with blank lines
ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
# Remove the 2 first blank lines
sed --in-place '1,2d' "${final_changelog}_lite"
# Add a blank line at the end
echo "" >> "${final_changelog}_lite"
# If changelog are empty, add an info
if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
then
echo "No changes from the changelog..." > "$final_changelog"
fi
if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
then
echo "No significative changes from the changelog..." > "${final_changelog}_lite"
fi
}
#=================================================
# Create a changelog for an app after an upgrade.
#
# The changelog is printed into the file ./changelog for the time of the upgrade.
#
# In order to create a changelog, ynh_app_changelog will get info from /etc/yunohost/apps/$app/status.json
# In order to find the current commit use by the app.
# The remote repository, and the branch.
# The changelog will be only the commits since the current revision.
#
# Because of the need of those info, ynh_app_changelog works only
# with apps that have been installed from a list.
#
# usage: ynh_app_changelog
ynh_app_changelog () {
get_value_from_settings ()
{
local value="$1"
# Extract a value from the status.json file of an installed app.
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local USER=$1
shift 1
grep "$value\": \"" /etc/yunohost/apps/$app/status.json | sed "s/.*$value\": \"\([^\"]*\).*/\1/"
}
local current_revision="$(get_value_from_settings revision)"
local repo="$(get_value_from_settings url)"
local branch="$(get_value_from_settings branch)"
# ynh_app_changelog works only with an app installed from a list.
if [ -z "$current_revision" ] || [ -z "$repo" ] || [ -z "$branch" ]
then
ynh_print_warn "Unable to build the changelog..."
touch changelog
return 0
fi
# Fetch the history of the repository, without cloning it
mkdir git_history
(cd git_history
ynh_exec_warn_less git init
ynh_exec_warn_less git remote add -f origin $repo
# Get the line of the current commit of the installed app in the history.
local line_to_head=$(git log origin/$branch --pretty=oneline | grep --line-number "$current_revision" | cut -d':' -f1)
# Cut the history before the current commit, to keep only newer commits.
# Then use sed to reorganise each lines and have a nice list of commits since the last upgrade.
# This list is redirected into the file changelog
git log origin/$branch --pretty=oneline | head --lines=$(($line_to_head-1)) | sed 's/^\([[:alnum:]]*\)\(.*\)/*(\1) -> \2/g' > ../changelog)
# Remove 'Merge pull request' commits
sed -i '/Merge pull request #[[:digit:]]* from/d' changelog
# As well as conflict resolving commits
sed -i '/Merge branch .* into/d' changelog
# Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# If a html email is required. Apply html to the changelog.
if [ "$admin_mail_html" -eq 1 ]
then
sed -in-place "s@\*(\([[:alnum:]]*\)) -> \(.*\)@* __URL_TAG1__\2__URL_TAG2__${repo}/commit/\1__URL_TAG3__@g" changelog
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}

View file

@ -1,55 +0,0 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
if [ -e /etc/apt/sources.list.d/minidlna.list ]
then
ynh_die "You are already using the version from backports repository." 0
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# RE-INSTALL MINIDLNA FROM BACKPORTS
#=================================================
ynh_script_progression --message="Re-install minidlna from backports" --weight=9
# Remove the current version of minidlna
ynh_package_remove minidlna
# Then install the version from backports
codename=$(ynh_debian_release)
test -z "$codename" && (ynh_die "codename empty")
ynh_replace_string "__CODENAME__" "$codename" /etc/yunohost/apps/$app/conf/minidlna.list
cp -a /etc/yunohost/apps/$app/conf/minidlna.list /etc/apt/sources.list.d/
ynh_apt update
ynh_package_install -t $codename-backports minidlna
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Execution completed" --last

View file

@ -1,47 +0,0 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
if [ ! -e /etc/apt/sources.list.d/minidlna.list ]
then
ynh_die "You are already using the version from the stable repository." 0
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# RE-INSTALL MINIDLNA FROM STABLE
#=================================================
ynh_script_progression --message="Re-install minidlna from stable" --weight=9
# Remove the current version of minidlna
ynh_package_remove minidlna
ynh_secure_remove "/etc/apt/sources.list.d/minidlna.list"
ynh_apt update
ynh_package_install minidlna
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Execution completed" --last

View file

@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
@ -29,13 +28,13 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
#=================================================
# RESET THE DATABASE
#=================================================
ynh_script_progression --message="Reset the database" --weight=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_secure_remove "$db_directory/files.db"
ynh_secure_remove --file="$db_directory/files.db"
ynh_systemd_action --action=start --service_name=minidlna
#=================================================

View file

@ -19,40 +19,29 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Load settings"
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
version=$(ynh_app_setting_get $app version)
#=================================================
# SPECIFIC BACKUP
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
# BACKUP OF THE APT SOURCE
#=================================================
if [ $version = "B" ]
then
ynh_script_progression --message="Backup of the APT source"
ynh_backup "/etc/apt/sources.list.d/minidlna.list"
fi
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP OF INOTIFY'S CONFIG
#=================================================
ynh_script_progression --message="Backup of inotify's config"
ynh_backup "/etc/sysctl.d/90-inotify_minidlna.conf"
ynh_backup --src_path="/etc/sysctl.d/90-inotify_minidlna.conf"
#=================================================
# BACKUP OF MINIDLNA CONFIGURATION
#=================================================
ynh_script_progression --message="Backup of minidlna configuration"
ynh_backup "/etc/minidlna.conf"
ynh_backup --src_path="/etc/minidlna.conf"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup completed" --last
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -47,13 +47,11 @@ old_friendly_name="$(get_config_value friendly_name)"
friendly_name="${YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_FRIENDLY_NAME:-$old_friendly_name}"
# Overwrite settings.json file
old_overwrite_settings="$(ynh_app_setting_get $app overwrite_settings)"
old_overwrite_settings=$(bool_to_true_false $old_overwrite_settings)
old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)"
overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}"
# Type of admin mail configuration
old_admin_mail_html="$(ynh_app_setting_get $app admin_mail_html)"
old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html)
old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)"
admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
#=================================================
@ -75,12 +73,12 @@ show_config() {
elif [ "$root_container" = "V" ]; then
root_container="Video"
fi
echo "YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_ROOT_CONTAINER=$root_container"
echo "YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_FRIENDLY_NAME=$friendly_name"
ynh_return "YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_ROOT_CONTAINER=$root_container"
ynh_return "YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_FRIENDLY_NAME=$friendly_name"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
echo "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
}
#=================================================
@ -105,16 +103,16 @@ apply_config() {
fi
if [ "$root_container" != "$old_root_container" ]
then
ynh_replace_string "root_container=.*" "root_container=$root_container" "$config_file"
ynh_app_setting_set $app root_container "$root_container"
ynh_replace_string --match_string="root_container=.*" --replace_string="root_container=$root_container" --target_file="$config_file"
ynh_app_setting_set --app=$app --key=root_container --value="$root_container"
restart_minidlna=1
fi
# friendly_name
if [ "$friendly_name" != "$old_friendly_name" ]
then
ynh_replace_string "friendly_name=.*" "friendly_name=$friendly_name" "$config_file"
ynh_app_setting_set $app friendly_name "$friendly_name"
ynh_replace_string --match_string="friendly_name=.*" --replace_string="friendly_name=$friendly_name" --target_file="$config_file"
ynh_app_setting_set --app=$app --key=friendly_name --value="$friendly_name"
restart_minidlna=1
fi
@ -124,12 +122,10 @@ apply_config() {
fi
# Set overwrite_settings
overwrite_settings=$(bool_to_01 $overwrite_settings)
ynh_app_setting_set $app overwrite_settings "$overwrite_settings"
ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings"
# Set admin_mail_html
admin_mail_html=$(bool_to_01 $admin_mail_html)
ynh_app_setting_set $app admin_mail_html "$admin_mail_html"
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
}
#=================================================

View file

@ -19,49 +19,37 @@ ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
version="$YNH_APP_ARG_VERSION"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Store settings from manifest" --weight=2
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set $app version ${version:0:1}
ynh_app_setting_set $app overwrite_settings "1"
ynh_app_setting_set $app admin_mail_html "1"
#=================================================
# CHECK DEBIAN'S CODENAME
#=================================================
ynh_script_progression --message="Check debian's codename"
codename=$(ynh_debian_release)
test -z "$codename" && (ynh_die "codename empty")
ynh_app_setting_set --app=$app --key=overwrite_settings --value=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Find and open a port" --weight=15
ynh_script_progression --message="Configuring firewall..." --weight=15
# Find a free port
port=$(ynh_find_port 48200)
port=$(ynh_find_port --port=48200)
# Open ports
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
ynh_app_setting_set $app port $port
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# CREATE YUNOHOST.MULTIMEDIA DIRECTORY
#=================================================
ynh_script_progression --message="Create yunohost.multimedia directory" --weight=8
ynh_script_progression --message="Creating yunohost.multimedia directory..." --weight=8
ynh_multimedia_build_main_dir
@ -70,31 +58,20 @@ ynh_multimedia_build_main_dir
#=================================================
# INSTALL MINIDLNA
#=================================================
ynh_script_progression --message="Install minidlna" --weight=45
ynh_script_progression --message="Installing MiniDLNA..." --weight=45
if [ ${version:0:1} = "B" ]
then
# Install the backport version. (If you have issues with the standard version from the stable repository)
ynh_replace_string "__CODENAME__" "$codename" ../conf/minidlna.list
cp -a ../conf/minidlna.list /etc/apt/sources.list.d/
ynh_apt update
ynh_package_install -t $codename-backports minidlna
else
# Install the standard version from debian repository
ynh_apt update
ynh_package_install minidlna
fi
ynh_app_setting_set $app version ${version:0:1}
ynh_install_app_dependencies minidlna
#=================================================
# INCREASE INOTIFY'S LIMITS
#=================================================
ynh_script_progression --message="Increase inotify's limits"
ynh_script_progression --message="Increasing inotify's limits..."
# Increase the maximum number of files inotify can monitor.
cp -a ../conf/90-inotify_minidlna.conf /etc/sysctl.d/
# Then, reload the kernel configuration.
if ! IS_PACKAGE_CHECK; then
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
@ -107,25 +84,25 @@ yunohost service add minidlna --log "/var/log/minidlna.log"
#=================================================
# CONFIGURE MINIDLNA
#=================================================
ynh_script_progression --message="Configure MiniDLNA" --weight=2
ynh_script_progression --message="Configuring MiniDLNA..." --weight=2
ynh_replace_string "^#*media_dir=.*" "media_dir=/home/yunohost.multimedia/share" /etc/minidlna.conf
ynh_replace_string "^#*port=.*" "port=$port" /etc/minidlna.conf
ynh_replace_string --match_string="^#*media_dir=.*" --replace_string="media_dir=/home/yunohost.multimedia/share" --target_file=/etc/minidlna.conf
ynh_replace_string --match_string="^#*port=.*" --replace_string="port=$port" --target_file=/etc/minidlna.conf
friendly_name="Yunohost DLNA"
ynh_app_setting_set $app friendly_name "$friendly_name"
ynh_replace_string "^#*friendly_name=.*" "friendly_name=$friendly_name" /etc/minidlna.conf
ynh_app_setting_set --app=$app --key=friendly_name --value="$friendly_name"
ynh_replace_string --match_string="^#*friendly_name=.*" --replace_string="friendly_name=$friendly_name" --target_file=/etc/minidlna.conf
root_container="B"
ynh_replace_string "^#*root_container=.*" "root_container=$root_container" /etc/minidlna.conf
ynh_app_setting_set $app root_container "$root_container"
ynh_replace_string "^#wide_links=.*" "wide_links=yes" /etc/minidlna.conf
ynh_replace_string --match_string="^#*root_container=.*" --replace_string="root_container=$root_container" --target_file=/etc/minidlna.conf
ynh_app_setting_set --app=$app --key=root_container --value="$root_container"
ynh_replace_string --match_string="^#wide_links=.*" --replace_string="wide_links=yes" --target_file=/etc/minidlna.conf
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "/etc/minidlna.conf"
ynh_store_file_checksum --file="/etc/minidlna.conf"
#=================================================
# RESTART MINIDLNA
#=================================================
ynh_script_progression --message="Restart MiniDLNA" --weight=4
ynh_script_progression --message="Restarting MiniDLNA..." --weight=4
ynh_systemd_action --action=restart --service_name=minidlna
@ -147,10 +124,10 @@ You can also find some specific actions for this app by using the experimental _
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/minidlna_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="install"
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=install
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation completed" --last
ynh_script_progression --message="Installation of MiniDLNA completed" --last

View file

@ -12,11 +12,11 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Load settings" --weight=2
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
port=$(ynh_app_setting_get $app port)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# STANDARD REMOVE
@ -25,16 +25,16 @@ port=$(ynh_app_setting_get $app port)
#=================================================
# Check if the service is declared in YunoHost
if yunohost service status | grep -q minidlna
if ynh_exec_fully_quiet yunohost service status minidlna
then
ynh_print_info "Remove minidlna service" >&2
ynh_script_progression --message="Removing MiniDLNA service..."
yunohost service remove minidlna
fi
#=================================================
# CLOSE PORTS
#=================================================
ynh_script_progression --message="Close ports" --weight=15
ynh_script_progression --message="Closing ports $port and 1900..." --weight=15
ynh_exec_fully_quiet yunohost firewall disallow TCP $port
ynh_exec_fully_quiet yunohost firewall disallow UDP 1900
@ -44,21 +44,20 @@ ynh_exec_fully_quiet yunohost firewall disallow UDP 1900
#=================================================
# REMOVE MINIDNLA
#=================================================
ynh_script_progression --message="Remove MiniDLNA" --weight=6
ynh_script_progression --message="Removing MiniDLNA..." --weight=6
ynh_apt purge minidlna
ynh_secure_remove "/etc/apt/sources.list.d/minidlna.list"
ynh_remove_app_dependencies
#=================================================
# REMOVE INOTIFY'S CONFIG
#=================================================
ynh_script_progression --message="Remove inotify's config"
ynh_script_progression --message="Removing inotify's config..."
if [ -e "/etc/sysctl.d/90-inotify_minidlna.conf" ]; then
ynh_print_info "Delete kernel config" >&2
ynh_secure_remove "/etc/sysctl.d/90-inotify_minidlna.conf"
ynh_secure_remove --file="/etc/sysctl.d/90-inotify_minidlna.conf"
# Reload the kernel configuration.
if ! IS_PACKAGE_CHECK; then
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
fi
@ -67,4 +66,4 @@ fi
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Deletion completed" --last
ynh_script_progression --message="Removal of MiniDLNA completed" --last

View file

@ -19,19 +19,18 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Load settings"
ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
version=$(ynh_app_setting_get $app version)
port=$(ynh_app_setting_get $app port)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# SPECIFIC RESTORE
#=================================================
# OPEN PORTS
#=================================================
ynh_script_progression --message="Open ports" --weight=15
ynh_script_progression --message="Configuring firewall..." --weight=15
ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port
# Discovery Protocol SSDP for UPNP.
@ -40,47 +39,36 @@ ynh_exec_fully_quiet yunohost firewall allow --no-upnp UDP 1900
#=================================================
# CREATE YUNOHOST.MULTIMEDIA DIRECTORY
#=================================================
ynh_script_progression --message="Create yunohost.multimedia directory" --weight=6
ynh_script_progression --message="Creating yunohost.multimedia directory..." --weight=6
ynh_multimedia_build_main_dir
#=================================================
# INSTALL MINIDLNA
#=================================================
ynh_script_progression --message="Install minidlna" --weight=45
ynh_script_progression --message="Installing MiniDLNA" --weight=45
if [ ${version:0:1} = "B" ]
then
# Install the backport version. (If you have issues with the standard version from the stable repository)
codename=$(ynh_debian_release)
ynh_restore_file "/etc/apt/sources.list.d/minidlna.list"
ynh_replace_string " [a-z]*-backports" " $codename-backports" /etc/apt/sources.list.d/minidlna.list
ynh_apt update
ynh_package_install -t $codename-backports minidlna
else
# Install the standard version from debian repository
ynh_apt update
ynh_package_install minidlna
fi
ynh_install_app_dependencies minidlna
#=================================================
# RESTORE INOTIFY'S CONFIG
#=================================================
ynh_script_progression --message="Restore inotify's config"
ynh_script_progression --message="Restoring inotify's config..."
ynh_restore_file "/etc/sysctl.d/90-inotify_minidlna.conf"
if ! IS_PACKAGE_CHECK; then
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="Restore MiniDLNA configuration" --weight=7
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 "/etc/minidlna.conf"
ynh_restore_file "/etc/minidlna.conf"
ynh_secure_remove --file="/etc/minidlna.conf"
ynh_restore_file --origin_path="/etc/minidlna.conf"
ynh_systemd_action --action=restart --service_name=minidlna
#=================================================
@ -107,10 +95,10 @@ You can also find some specific actions for this app by using the experimental _
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/minidlna_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="restore"
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed" --last
ynh_script_progression --message="Restoration completed for MiniDLNA" --last

View file

@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Load settings" --weight=2
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
version=$(ynh_app_setting_get $app version)
port=$(ynh_app_setting_get $app port)
overwrite_settings=$(ynh_app_setting_get $app overwrite_settings)
root_container=$(ynh_app_setting_get $app root_container)
friendly_name=$(ynh_app_setting_get $app friendly_name)
version=$(ynh_app_setting_get --app=$app --key=version)
port=$(ynh_app_setting_get --app=$app --key=port)
overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings)
root_container=$(ynh_app_setting_get --app=$app --key=root_container)
friendly_name=$(ynh_app_setting_get --app=$app --key=friendly_name)
#=================================================
# CHECK VERSION
@ -31,30 +31,36 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensure downward compatibility"
ynh_script_progression --message="Ensuring downward compatibility..."
# If overwrite_settings doesn't exist, create it
if [ -z "$overwrite_settings" ]; then
overwrite_settings=1
ynh_app_setting_set $app overwrite_settings $overwrite_settings
ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings
fi
# If root_container doesn't exist, create it
if [ -z "$root_container" ]; then
root_container="B"
ynh_app_setting_set $app root_container $root_container
ynh_app_setting_set --app=$app --key=root_container --value=$root_container
fi
# If friendly_name doesn't exist, create it
if [ -z "$friendly_name" ]; then
friendly_name="Yunohost DLNA"
ynh_app_setting_set $app friendly_name $friendly_name
ynh_app_setting_set --app=$app --key=friendly_name --value=$friendly_name
fi
# If version exists, remove the backport source list, as it's no longer used.
if [ -n "$version" ]; then
ynh_secure_remove --file="/etc/apt/sources.list.d/minidlna.list"
ynh_app_setting_delete --app=$app --key=version
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backup the app before upgrading" --weight=2
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=2
# Backup the current version of the app
ynh_backup_before_upgrade
@ -68,38 +74,27 @@ ynh_abort_if_errors
#=================================================
# UPGRADE THE YUNOHOST.MULTIMEDIA DIRECTORY
#=================================================
ynh_script_progression --message="Upgrade the yunohost.multimedia directory" --weight=3
ynh_script_progression --message="Upgrading the yunohost.multimedia directory..." --weight=3
ynh_multimedia_build_main_dir
#=================================================
# UPGRADE MINIDLNA
#=================================================
ynh_script_progression --message="Upgrade MiniDLNA" --weight=3
ynh_script_progression --message="Upgrading MiniDLNA..." --weight=3
if [ $version = "B" ]
then
# Install the backport version. (If you have issues with the standard version from the stable repository)
codename=$(ynh_debian_release)
ynh_replace_string "__CODENAME__" "$codename" ../conf/minidlna.list
cp -a ../conf/minidlna.list /etc/apt/sources.list.d/
ynh_apt update
ynh_package_install -t $codename-backports minidlna
else
# Install the standard version from debian repository
ynh_apt update
ynh_package_install minidlna
fi
ynh_install_app_dependencies minidlna
#=================================================
# INCREASE INOTIFY'S LIMITS
#=================================================
ynh_script_progression --message="Increase inotify's limits" --weight=2
ynh_script_progression --message="Increasing inotify's limits..." --weight=2
# Increase the maximum number of files inotify can monitor.
cp -a ../conf/90-inotify_minidlna.conf /etc/sysctl.d/
# Then, reload the kernel configuration.
if ! IS_PACKAGE_CHECK; then
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
@ -112,28 +107,28 @@ yunohost service add minidlna --log "/var/log/minidlna.log"
#=================================================
# CONFIGURE MINIDLNA
#=================================================
ynh_script_progression --message="Reconfigure MiniDLNA" --weight=2
ynh_script_progression --message="Reconfiguring MiniDLNA..." --weight=2
# Overwrite the settings config file only if it's allowed
if [ $overwrite_settings -eq 1 ]
then
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different "/etc/minidlna.conf"
ynh_backup_if_checksum_is_different --file="/etc/minidlna.conf"
ynh_replace_string "^#*media_dir=.*" "media_dir=/home/yunohost.multimedia/share" /etc/minidlna.conf
ynh_replace_string "^#*port=.*" "port=$port" /etc/minidlna.conf
ynh_replace_string "^#*friendly_name=.*" "friendly_name=$friendly_name" /etc/minidlna.conf
ynh_replace_string "^#*root_container=.*" "root_container=$root_container" /etc/minidlna.conf
ynh_replace_string "^#wide_links=.*" "wide_links=yes" /etc/minidlna.conf
ynh_replace_string --match_string="^#*media_dir=.*" --replace_string="media_dir=/home/yunohost.multimedia/share" --target_file=/etc/minidlna.conf
ynh_replace_string --match_string="^#*port=.*" --replace_string="port=$port" --target_file=/etc/minidlna.conf
ynh_replace_string --match_string="^#*friendly_name=.*" --replace_string="friendly_name=$friendly_name" --target_file=/etc/minidlna.conf
ynh_replace_string --match_string="^#*root_container=.*" --replace_string="root_container=$root_container" --target_file=/etc/minidlna.conf
ynh_replace_string --match_string="^#wide_links=.*" --replace_string="wide_links=yes" --target_file=/etc/minidlna.conf
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "/etc/minidlna.conf"
ynh_store_file_checksum --file="/etc/minidlna.conf"
fi
#=================================================
# RESTART MINIDLNA'S SERVICE
#=================================================
ynh_script_progression --message="Restart MiniDLNA" --weight=7
ynh_script_progression --message="Restarting MiniDLNA..." --weight=7
ynh_systemd_action --action=restart --service_name=minidlna
@ -163,10 +158,10 @@ If you're facing an issue or want to improve this app, please open a new issue i
Changelog since your last upgrade:
$(cat changelog)" > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="upgrade"
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=upgrade
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade completed" --last
ynh_script_progression --message="Upgrade of MiniDLNA completed" --last