Démarrage automatique de MMDVMHost

Dans cet article, vous découvrez comment faire en sorte que MMDVMHost démarre automatiquement à la mise sous tension de votre Raspberry Pi.

Le démarrage automatique de MMDVMHost

Sur le Raspberry Pi, il existe deux solutions (celles que je connais) pour lancer automatiquement un logiciel à la mise sous tension (ou reboot) du Raspberry Pi, tournant sous Raspbian.

Démarrage simple

Pour démarrer automatiquement MMDVMHost, la solution la plus simple est d’éditer ce fichier de démarrage et d’y ajouter la ligne de commande pour lancer MMDVMHost avant l’instruction exit 0

sudo nano /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

sudo  /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini

exit 0

Démarrage avec déclaration d’un service MMDVMHost

Une autre solution, un peu plus élégante est de créer un service.

Prérequis

Installation de screen

sudo apt-get install screen

Création du fichier service

sudo nano /lib/systemd/system/mmdvmhost.service
[Unit]
Description=MMDVM Host Service
After=syslog.target network.target

[Service]
User=root
WorkingDirectory=/opt/MMDVMHost
ExecStart=/usr/bin/screen -S MMDVMHost -D -m /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
ExecStop=/usr/bin/screen -S MMDVMHost -X quit
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Dans la section [Service], les deux dernières lignes permettent d’assurer le rédémarrage de MMDVMHost en cas de plantage. Il faut noter qu’il est très rare d’être confronté à des arrêts inopinés de MMDVMHost. Nous allons tester le bon fonctionnement du redémarrage plus bas dans l’article.

Les répertoires de lancement de MMDVMHost indiqués ici correspondent à ceux utilisés lors du déroulement du tutorial d’installation de MMDVMHost.

Création du fichier de temporisation du lancement

Le lancement du service est temporisé après 60 secondes après le démarrage

sudo nano /lib/systemd/system/mmdvmhost.timer
[Timer]
OnStartupSec=60

[Install]
WantedBy=multi-user.target


Application des droits et prise en compte du service

sudo chmod 755 /lib/systemd/system/mmdvmhost.service
sudo chmod 755 /lib/systemd/system/mmdvmhost.timer
sudo ln -s /lib/systemd/system/mmdvmhost.service /etc/systemd/system/mmdvmhost.service
sudo ln -s /lib/systemd/system/mmdvmhost.timer /etc/systemd/system/mmdvmhost.timer

Nous pouvons redémarrer le gestionnaire de services

sudo systemctl daemon-reload

A présent le service MMDVMHost est prêt à être démarré. A ce stade, nous pouvons lancer le service sans redémarrer.

sudo systemctl start mmdvmhost.service

Vérification du fonctionnement du service

Vous pouvez vérifier que le service lancement bien MMDVMHost qui doit apparaitre dans les processus (ps) avec l’instruction suivante, et qui doit retourner 3 lignes.

sudo ps aux | grep MMDVMHost
root      9657  1.0  0.6   5192  2684 ?        Ss   16:19   0:00 /usr/bin/SCREEN -S MMDVMHost -D -m /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
root      9662 18.2  1.2  15140  5436 pts/0    Ssl+ 16:19   0:00 /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
pi        9777  0.0  0.4   4268  1956 pts/1    S+   16:19   0:00 grep --color=auto MMDVMHost

Pour vérifier le fonctionnement du service, vous aurez accès au log de MMDVMHost avec la commande suivante

sudo screen -r MMDVMHost

Le statut de fonctionnement du service est retourné avec cette commande

sudo systemctl status mmdvmhost.service
● mmdvmhost.timer
   Loaded: loaded (/lib/systemd/system/mmdvmhost.timer; enabled)
   Active: active (elapsed) since Sat 2017-05-20 16:33:10 CEST; 13min ago

May 20 16:33:10 raspberrypi systemd[1]: Starting mmdvmhost.timer.
May 20 16:33:10 raspberrypi systemd[1]: Started mmdvmhost.timer.

Testons à présent le redémarrage automatique.

Etape 1: Le service est en marche, MMDVMHost est présent dans la liste des processus :

sudo ps aux | grep MMDVMHost
root      9657  1.0  0.6   5192  2684 ?        Ss   16:19   0:00 /usr/bin/SCREEN -S MMDVMHost -D -m /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
root      9662 18.2  1.2  15140  5436 pts/0    Ssl+ 16:19   0:00 /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
pi        9777  0.0  0.4   4268  1956 pts/1    S+   16:19   0:00 grep --color=auto MMDVMHost

Etape 2: Nous allons tuer (“killer”) le processus MMDVMhost avec

sudo killall MMDVMHost

Etape 3: Vérifions immédiatement la liste des processus.

sudo ps aux | grep MMDVMHost
pi 6360 0.0 0.4 4268 1828 pts/0 S+ 16:37 0:00 grep --color=auto MMDVMHost

Il n’y a plus qu’une seule ligne… Mais 10 secondes plus tard, la même commande affiche à nouveau les 3 lignes. MMDVMHost a bien été redémarré !

root      6609  0.0  0.6   5192  2812 ?        Ss   16:37   0:00 /usr/bin/SCREEN -S MMDVMHost -D -m /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
root      6613  6.4  1.3  16712  5920 pts/2    Ssl+ 16:37   0:03 /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
pi        7852  0.0  0.4   4268  1856 pts/0    S+   16:38   0:00 grep --color=auto MMDVMHost

Autre commande

Pour stopper le service

sudo systemctl stop mmdvmhost.service

Conclusion

You will understand that the second solution presented and which consists of starting MMDVMHost as a service is more robust thanks to the function offered by the service to automatically restart MMDVMHost on untimely shutdown.

If necessary the comments are opened below for your remarks, or questions.

 

If you would be interested to participate in a possible future new grouped order (MMDVM board, SvxLink Card), leave your email below to be reported!

14 réflexions au sujet de « Démarrage automatique de MMDVMHost »

  1. Bonjour
    la solution la plus simple faire un fichier dans l’autostart avec un décalage de 30 secondes

    (Translation)
    Hello
    The simplest solution is to make a file in the autostart with a 30 second delay

    sudo su
    cd ./config
    sudo mkdir autostart ('s'il n'existe pas)
    cd autostart
    sudo nano MMDVMHost.desktop:

    [Desktop Entry]
    Name=MMDVMHost
    Exec=sh -c "sleep 30 && cd /opt/MMDVMHost; sudo ./MMDVMHost MMDVM.ini"
    Terminal=false
    Type=Application
    Icon=
    Categories=Hamradio;

    CTRL+x Yes pour sortir

  2. Good Morning,

    Advice please before I do a total rebuild..

    I have followed the build sequence for MMDVM and Adriano on a PI 3
    but something is wrong with one of my settings
    as the Pi boots up it fails for DMR and just keeps running around in a loop
    Is there a way to break that loop, or login via an other virtual screen to stop it please.
    All the best and thank you from Alan

    (Traduction)
    Bonjour,

       Conseils avant de faire une reconstruction totale.

    J’ai suivi la séquence de construction pour MMDVM et Adriano sur un PI 3
    Mais quelque chose ne va pas avec l’un de mes paramètres
    Lorsque le Pi démarre, il échoue pour DMR et continue de tourner en boucle
    Existe-t-il un moyen de briser cette boucle, ou de vous connecter via un autre écran virtuel pour l’arrêter s’il vous plaît.
    Tout le meilleur et merci d’Alan

  3. Advertisements
  4. Hello,

    I think that you may use my service menu here : https://www.f5uii.net/en/mmdvm-management-menu/

    It include the stop command of the service. If you kill simply the MMDVMHost process, yes, the service will start again !

    73 Chris

    (Traduction)
    Bonjour,

    Je pense que vous pouvez utiliser mon menu de gestion ici: https://www.f5uii.net/fr/mmdvm-management-menu/

    Il comprend la commande d’arrêt du service. Si vous tuez simplement le processus MMDVMHost, oui, le service le relancera !

    73 Chris

  5. Good Afternoon Chris, that does look great, BUT I need to get in first
    which I cannot do…

    All the best from Alan

    (Traduction)
    Bon après-midi Chris, ça a l’air génial, MAIS j’ai besoin d’entrer en premier
      Chose que je ne peux pas faire …

    Alan

    1. I do not understand how it is possible to have so a trooble. Is it booting in circle ?
      I believe that you know connect remotely your Raspberry Pi via SSH like explained here
      https://www.raspberrypi.org/documentation/remote-access/ssh/windows.md

      That you can stop your service (sudo systemctl stop mmdvmhost.service) and also kill the process (sudo killall MMDVMHost)

      (Traduction)
      Je ne comprends comment cela est possible d’en arrivé là. Est-ce que cela reboote en cycle ?
      Je suppose que vous savez vous connecter à distance au Raspberry Pi via SSH comme expliqué ici.
      https://www.raspberrypi.org/documentation/remote-access/ssh/windows.md

      Alors, vous pourrez stopper le service (sudo systemctl stop mmdvmhost.service) et aussi tuer la tâche (sudo killall MMDVMHost)

  6. Advertisements
  7. Hi Chris I hope this will explain…

    http://www.highforce.com/pi.jpg

    what you see keeps repeating, i need to stop it to install your program, or goto single user mode
    and cancel the rc.local file

    All the best from Alan

    (Traduction)
    Bonjour Chris J’espère que cela sera plus clair …
    http://www.highforce.com/pi.jpg
    Ce que vous voyez continue de répéter, je dois l’arrêter pour installer votre programme, ou passer en mode utilisateur unique
    Et annuler le fichier rc.local
    Alan

    1. Alan,

      This is no link with the way you start MMDVMHost ! It is just telling that you can not reach the DMR master server via internet.
      You have to check
      1) you have enter the good master ip or host adress, port and password in the MDMVM.ini, section [DMR Network]
      2) Your internet gateway ip address indicated in your Rasperry Pi is corresponding to your internet box, so that the ip routing come out to internet.
      you can have a look if you can ping google.com and our master with ping www.google.com command

      (Traduction)

      Alan,
      Cela na rien à voir avec la façon MMDVMHost démarre ! Cela indique juste que vous n’arrivez pas à atteindre le server Master DMR via internet.
      Vous devez vérifier
      1) que vous avez bien renseigner la bonne adresse ip ou nom de host, port et password dans MMDVM.ini à la section [DMR Network]
      2) que l’adresse ip du gateway internet est bien renseigné dans le Raspberry Pi, qu’il corresponde à l’adresse de votre box internet, de façon à ce que les routages ip aille sur internet.
      Vous pouvez vérifier que le ping vers google et vers votre master fonctionne avec la commande ping www.google.com

  8. I am understanding what you are saying all good advice

    BUT

    I CANNOT get into ROOT

    Control C or Esc will not get me out of this, I cant even remote access in via the ethernet

    I hope you understand, sorry if my English is bad..

    All the best from Alan & Thank you.

  9. Advertisements
  10. Hi Chris,

    It appears that after 15minutes, the pi allows you to connect via ssh which I did do, and stop the mmdvm
    created the menu as describe in your web pages, make life a lot easier 🙂 thank you for that..

    I disabled everything except Fusion, then set the software running again…
    and this is what I get, http://www.highforce.com/p2.jpg

    Thank you for your help & support..

    All the best from Alan

    (Traduction)
    Salut chris,

        Finalement après 15 minutes, le pi m’a autorisé à m’y connecter via ssh, chose que j’ai faite et puis arrêter mmdvm
        J’ai créé le menu comme décrit sur votre site Web, ce qui rend la vie beaucoup plus facile 🙂 merci pour ça …

        J’ai désactivé tout, sauf Fusion, puis réinitialiser le logiciel …
        Et c’est ce que je reçois, http://www.highforce.com/p2.jpg

    Merci de votre aide et de votre support..

    Salutations Alan

  11. Je crois qu’il manque la commande:
    sudo systemctl enable mmdvmhost.timer

    Sans elle le service ne démarrait pas sur mon Hotspot.

    73 Ghislain/F4HGA.

    (Translation)
    I think the command is missing:
    sudo systemctl enable mmdvmhost.timer

    Without it, the service would not start on my Hotspot.

    73 Ghislain/F4HGA.

  12. Hello to all.
    Use MMDVM on a repeater with Raspberry PI3, Arduino and NTH radio card.
    On the raspberry I mounted a UTAH SD but I have the problem that when I restart the raspberry, the MMDVMHost does not start automatically ..
    By launching MMDVMHost instead manually, it works regularly.
    I checked all the files needed for the automatic start of MMDVMHost and they all seem correct.
    From the MMDVMHost log I see these lines, from which it seems that the system is stopped, but I do not know why

    ---------------------omissis
    I: 2018-05-27 22:42:19.720 Mode Hang: 20s
    M: 2018-05-27 22:42:19.720 MMDVMHost-20180327 is running
    M: 2018-05-27 22:42:19.720 Closing the MMDVM
    I: 2018-05-27 22:42:20.720 Stopped the DMR Id lookup reload thread
    M: 2018-05-27 22:42:20.720 DMR, Closing DMR Network
    I: 2018-05-27 22:42:20.720 MMDVMHost-20180327 exited on receipt of SIGTERM
    I: 2018-05-27 22:44:42.955 This software is for use on amateur radio networks only,
    I: 2018-05-27 22:44:42.956 it is to be used for educational purposes only. Its use on
    I: 2018-05-27 22:44:42.956 commercial networks is strictly prohibited.
    I: 2018-05-27 22:44:42.956 Copyright(C) 2015-2018 by Jonathan Naylor, G4KLX and others
    M: 2018-05-27 22:44:42.956 MMDVMHost-20180327 is starting
    M: 2018-05-27 22:44:42.956 Built 23:31:03 May 15 2018 (GitID #992b0f2)
    -----------omissis

    On the same SD, for better remote control, I installed VNC, VIRTUALHERE and MMDVM DASHBOARD ..
    Does anyone have any idea what the solution to the problem might be? I have already tried in various ways without success.

    Thank you
    ’73 de Adam, IK4NZD

    (Traduction)
    Bonjour à tous.
    J’utilise le MMDVM en tant que relais avec une carte radio Raspberry PI3, Arduino et NTH.
    Sur le raspberry pi, j’ai monté une SD UTAH mais j’ai le problème que lorsque je redémarre le raspberry , le MMDVMHost ne démarre pas automatiquement.
    En lançant MMDVMHost à la place manuellement, il fonctionne correctement.
    J’ai vérifié tous les fichiers nécessaires au démarrage automatique de MMDVMHost et ils semblent tous corrects.
    Depuis le journal MMDVMHost je vois ces lignes, dont il semble que le système est arrêté, mais je ne sais pas pourquoi.

    Sur la même SD, pour une meilleure télécommande, j’ai installé VNC, VIRTUALHERE et MMDVM DASHBOARD ..
    Quelqu’un a-t-il une idée de la solution au problème ? J’ai déjà essayé de diverses façons, mais sans succès.

    Je vous remercie
    73 de Adam, IK4NZD

  13. Advertisements
  14. Hi I have followed you process and get the following:

    root@raspberrypi:/opt/MMDVMHost# sudo ps aux | grep MMDVMHost
    root 1645 0.0 0.0 7348 552 pts/0 S+ 21:24 0:00 grep MMDVMHost

    root@raspberrypi:/opt/MMDVMHost# sudo systemctl status mmdvmhost.service
    ● mmdvmhost.service - MMDVM Host Service
    Loaded: loaded (/lib/systemd/system/mmdvmhost.service; linked; vendor preset:
    Active: inactive (dead)
    lines 1-3/3 (END)...skipping...
    ● mmdvmhost.service - MMDVM Host Service
    Loaded: loaded (/lib/systemd/system/mmdvmhost.service; linked; vendor preset: enabled)
    Active: inactive (dead)
    ~

    I am trying to install this on the buster os for raspberry pi. As you can see I get these errors above. Can you help.

    regards
    Paul

    (Traduction)

    Bonjour, j’ai suivi votre processus et j’ai obtenu ce qui suit :

    root@raspberrypi:/opt/MMDVMHost# sudo ps aux | grep MMDVMHost
    root 1645 0.0 0.0 7348 552 pts/0 S+ 21:24 0:00 grep MMDVMHost

    root@raspberrypi:/opt/MMDVMHost# sudo systemctl status mmdvmhost.service
    ● mmdvmhost.service - MMDVM Host Service
    Loaded: loaded (/lib/systemd/system/mmdvmhost.service; linked; vendor preset:
    Active: inactive (dead)
    lines 1-3/3 (END)...skipping...
    ● mmdvmhost.service - MMDVM Host Service
    Loaded: loaded (/lib/systemd/system/mmdvmhost.service; linked; vendor preset: enabled)
    Active: inactive (dead)
    ~

    J’essaie de l’installer sur le buster os pour Raspberry Pi. Comme vous pouvez le voir, je reçois ces erreurs ci-dessus. Pouvez-vous m’aider ?
    concernant

    Paul

    1. Hello,
      It has nothing to do with the OS. Check that the installation directory is correct. The command executed directly should launch MMDVMHost without error. If not, check that the directories are the ones used by your installation. The command should run without error
      /usr/bin/screen -S MMDVMHost -D -m /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
      the users command must return root in the list.

      Have a good fix.

      (Traduction)

      Bonjour,
      Cela n’a rien a voir avoir l’OS. Vérifier que le répertoire d’installation est bien correcte. La commande exécutée directement devrait lancer MMDVMHost sans erreur. Si ce n’est pas le cas, vérifier que les répertoires sont bien ceux utilisés par votre installation. La commande doit s’exécuter sans erreur
      /usr/bin/screen -S MMDVMHost -D -m /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
      la commande users doit retourner root dans la liste.

      Bon dépannage.

Répondre à F5UII Annuler la réponse

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *