Minidlna temporiser son démarrage

Salut,
J’utilise minidlna comme serveur UpnP pour ma SFR Box.
Je souhaite temporiser son démarrage de façon à ce que le disque sur usb qui contient les médias à lire soit bien totalement accessible.

Le service minidlna démarre par /etc/init.d/minidlna et se configure dans /etc/default/minidlna

Mais je ne trouve pas de paramètre de temporisation.
Suffit-il de mettre au debut de /etc/init.d/minidlna un

J’essai:

root@[code]desktop:/etc# cat /etc/init.d/minidlna
#!/bin/sh

MiniDLNA initscript

Based on the mediatomb debian package.

Original authors: Tor Krill tor@excito.com

Leonhard Wimmer leo@mediatomb.cc

Andres Mejia mcitadel@gmail.com

Modified by: Benoît Knecht benoit.knecht@fsfe.org

BEGIN INIT INFO

Provides: minidlna

Required-Start: $network $local_fs $remote_fs

Required-Stop:: $network $local_fs $remote_fs

Should-Start: $all

Should-Stop: $all

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Start minidlna at boot time

Description: Manage the minidlna daemon, a DLNA/UPnP-AV media server.

END INIT INFO

unset USER

PATH should only include /usr/* if it runs after the mountnfs.sh script

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="DLNA/UPnP-AV media server"
NAME=minidlna
DAEMON=/usr/bin/minidlnad
PIDDIR=/run/$NAME
PIDFILE=$PIDDIR/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DEFAULT=/etc/default/$NAME

Exit if the package is not installed

[ -x $DAEMON ] || exit 0

Read configuration variable file if it is present

[ -r $DEFAULT ] && . $DEFAULT

Define LSB log_* functions.

Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

. /lib/lsb/init-functions

Tempo pour attendre le disque usb

sleep 60

Do not start the daemon if NO_START is enabled in DEFAULT

if [ “$START_DAEMON” != “yes” ] && [ “$1” != “stop” ]; then
log_warning_msg "$NAME: Not starting $DESC."
log_warning_msg "$NAME: Disabled in $DEFAULT."
exit 0
fi
[/code]

j’ai mis la tempo un peu avant et rallongé la durée

[code]root@desktop:# cat /etc/init.d/minidlna
#!/bin/sh

MiniDLNA initscript

Based on the mediatomb debian package.

Original authors: Tor Krill tor@excito.com

Leonhard Wimmer leo@mediatomb.cc

Andres Mejia mcitadel@gmail.com

Modified by: Benoît Knecht benoit.knecht@fsfe.org

BEGIN INIT INFO

Provides: minidlna

Required-Start: $network $local_fs $remote_fs

Required-Stop:: $network $local_fs $remote_fs

Should-Start: $all

Should-Stop: $all

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Start minidlna at boot time

Description: Manage the minidlna daemon, a DLNA/UPnP-AV media server.

END INIT INFO

unset USER

PATH should only include /usr/* if it runs after the mountnfs.sh script

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="DLNA/UPnP-AV media server"
NAME=minidlna
DAEMON=/usr/bin/minidlnad
PIDDIR=/run/$NAME
PIDFILE=$PIDDIR/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DEFAULT=/etc/default/$NAME

Exit if the package is not installed

[ -x $DAEMON ] || exit 0

Read configuration variable file if it is present

[ -r $DEFAULT ] && . $DEFAULT

Tempo pour attendre le disque usb

sleep 180

Define LSB log_* functions.

Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

. /lib/lsb/init-functions[/code]
Et si je considère que c’est udev qui gère les équipements usb ça à l’air bon puisque minidlna démarre après

root@desktop:/etc/udev/rules.d# service udev status ● systemd-udevd.service - udev Kernel Device Manager Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static) Active: active (running) since jeu. 2015-04-02 20:46:12 CEST; 30min ago Docs: man:systemd-udevd.service(8) man:udev(7) Main PID: 229 (systemd-udevd) CGroup: /system.slice/systemd-udevd.service └─229 /lib/systemd/systemd-udevd

root@ubuntu-desktop:/etc/udev/rules.d# service minidlna status ● minidlna.service - LSB: Start minidlna at boot time Loaded: loaded (/etc/init.d/minidlna) Active: active (running) since jeu. 2015-04-02 20:47:23 CEST; 29min ago Process: 612 ExecStart=/etc/init.d/minidlna start (code=exited, status=0/SUCCESS) CGroup: /system.slice/minidlna.service └─1502 /usr/bin/minidlnad -f /etc/minidlna.conf -P /run/minidlna/minidlna.pid

ça marche pas

En fait je veux conditionner minidlna au montage du disque usb qui s’appelle Elements, c’est le service media-user-Elements.mount

root@ubuntu-desktop:~# systemctl status media-user-Elements.mount ● media-user-Elements.mount - /media/user/Elements Loaded: loaded (/proc/self/mountinfo) Active: active (mounted) since ven. 2015-04-03 12:51:44 CEST; 3h 58min ago Where: /media/user/Elements What: /dev/sdb1
mais je ne sais pas écrire la ligne de test du genre

Salut Grantoubab

Dans mon cas je démarre minidlna avec cron

Dans mon crontab:
@reboot sleep 300; usr/sbin/minidlnad -f /etc/minidlna.conf

Après pour le conditionner vis à vis d’un montage, voici un exemple à adapter :

#!/bin/sh
mount | grep /mnt/HDD-USB
if [ “$?” -eq 0 ] ; then
usr/sbin/minidlnad -f /etc/minidlna.conf
fi

[quote=“nonobecane”]Salut Grantoubab

Dans mon cas je démarre minidlna avec cron

Dans mon crontab:
@reboot sleep 300; usr/sbin/minidlnad -f /etc/minidlna.conf

Après pour le conditionner vis à vis d’un montage, voici un exemple à adapter :

#!/bin/sh
mount | grep /mnt/HDD-USB
if [ “$?” -eq 0 ] ; then
usr/sbin/minidlnad -f /etc/minidlna.conf
fi[/quote]
salut et merci
j’ai réussi en utilisant les commandes de systemd, systemctl avec l’aide d’un membre du forum ubuntu
Minidlna démarre bien après que mon disque usb soit monté.

[code]root@ubuntu-desktop:~# cat /etc/init.d/minidlna
#!/bin/sh

MiniDLNA initscript

Based on the mediatomb debian package.

Original authors: Tor Krill tor@excito.com

Leonhard Wimmer leo@mediatomb.cc

Andres Mejia mcitadel@gmail.com

Modified by: Benoît Knecht benoit.knecht@fsfe.org

BEGIN INIT INFO

Provides: minidlna

Required-Start: $network $local_fs $remote_fs

Required-Stop:: $network $local_fs $remote_fs

Should-Start: $all

Should-Stop: $all

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Start minidlna at boot time

Description: Manage the minidlna daemon, a DLNA/UPnP-AV media server.

END INIT INFO

unset USER

PATH should only include /usr/* if it runs after the mountnfs.sh script

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=“DLNA/UPnP-AV media server”
NAME=minidlna
DAEMON=/usr/bin/minidlnad
PIDDIR=/run/$NAME
PIDFILE=$PIDDIR/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DEFAULT=/etc/default/$NAME

Exit if the package is not installed

[ -x $DAEMON ] || exit 0

Read configuration variable file if it is present

[ -r $DEFAULT ] && . $DEFAULT

Tempo pour attendre le disque usb

result=‘debut’
while [ “$result” != ‘SubState=mounted’ ];
do
sleep 2;
result=$(systemctl show media-guy-Elements.mount -p SubState);
done

Define LSB log_* functions.

Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

. /lib/lsb/init-functions
[/code]

forum.ubuntu-fr.org/viewtopic.ph … #p19556541

Vraiment super systemd/systemctl :038

Pour eviter de bloquer systemd lors du reboot (en effet le disque usb est démonté avant l’arret de minidlna et la tempo est alors infinie! Heureusement que systemd dégage tout au bout de 5mn) il vaut mieux mettre la boucle d’attente dans la fonction start

[code]#

Function that starts the daemon/service

do_start()
{

Tempo pour attendre le disque usb

result='debut’
while [ “$result” != ‘SubState=mounted’ ];
do
sleep 2;
result=$(systemctl show media-guy-Elements.mount -p SubState);
done
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
touch $LOGFILE && chown $USER:$GROUP $LOGFILE || return 2
if [ ! -d $PIDDIR ]; then
mkdir $PIDDIR || return 2
fi
chown $USER:$GROUP $PIDDIR || return 2

start-stop-daemon --start --quiet --pidfile $PIDFILE \
	--chuid $USER:$GROUP --exec $DAEMON --test > /dev/null \
	|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE \
	--chuid $USER:$GROUP --exec $DAEMON -- \
	$DAEMON_ARGS \
	|| return 2

}
[/code]
Testé sur Debian Jessie XFCE

Erreur de post, ne pas tenir compte merci.

A+