Automatic start of MMDVMHost

In this article, you will learn how to make MMDVMHost automatically start when your Raspberry Pi is turned on.

The automatic start of MMDVMHost

On the Raspberry Pi, there are two solutions (the ones I know) to automatically launch software when the Raspbeery Pi is turned on (or rebooted), running under Raspbian.

Simple startup

To start MMDVMHost automatically, the easiest solution is to edit this startup file and add the command line to start MMDVMHost before the statement 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

Starting with declaring a MMDVMHost service

Another solution, a little more elegant is to create a service.

Prerequisites

Installation of screen

sudo apt-get install screen

Creating the service file

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

In the [Service] section, the last two lines make it possible to restart MMDVMHost in the event of a crash. It should be noted that it is very rare to be confronted with unexpected stops of MMDVMHost. We will test the proper functioning of the restart further down in the article.

The MMDVMHost launch directories shown here correspond to those used during the MMDVMHost install tutorial.

Creating the launch timer file

The start of the service is delayed after 60 seconds after startup

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

[Install]
WantedBy=multi-user.target


Enforcement and 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

We can restart the service manager

sudo systemctl daemon-reload

Now the MMDVMHost service is ready to start. At this point, we can start the service without restarting.

sudo systemctl start mmdvmhost.service

Verification of Service Operation

You can verify that the service launch MMDVMHost, by appearing in processes (ps) with the following statement. Must be displayed 3 rows.

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

For verify the operation of the service, you will have access to the MMDVMHost log with the following command

sudo screen -r MMDVMHost

The operating status of the service is returned with this command

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.

Let’s now test the automatic restart.

Step 1: The service is running, MMDVMHost is present in the list of processes:

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

Step 2: We will kill the MMDVMhost process with

sudo killall MMDVMHost

Step 3: Immediately check the list of processes.

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

There is only one line left … But 10 seconds later, the same command again displays the 3 lines. MMDVMHost has been restarted!

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

Other command

To stop the service

sudo systemctl stop mmdvmhost.service

Conclusion

Vous aurez compris que la seconde solution présentée et qui consiste à démarrer MMDVMHost en tant que service est plus robuste grâce à la fonction offerte par le service de redémarrer automatiquement MMDVMHost sur arrêt intempestif.

Au besoin les commentaires sont ouverts ci-dessous pour vos remarques, ou 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 thoughts on “Automatic start of 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.

Leave a Reply to F5UII Cancel reply

Your email address will not be published. Required fields are marked *