The following is taken from a file that was uploaded to the MMDVM Yahoo group by KC7WSU; it is not my original work, but it does the job far better than anything I could have figured out – why re-invent the wheel!
I have dissected the file to add my own comments to explain what is going on at each stage to aid in your self-learning.
Use Raspbian Jessie Lite
This first instruction is to use Raspbian Jessie Lite ; it should work equally well in the full version of Jessie. To download the img file, goto the Raspberry Pi website here. Instructions on how to flash the image to an SD card are also there.
You should be executing the following commands using the command line interface accessible from a terminal session if you are running the full Jessie image. If you are using Jessie Lite, you should be familiar with the command line interface as that’s the only option you have!
1. Expand File System # sudo raspi-config
This first step will open a textual dialogue with various options, select the first option and follow any instructions given.
2. Update Raspberry Pi # sudo apt-get update # sudo apt-get upgrade
Step 2 ensures the RPi is up-to-date and running the latest software.
3. Install Pre-Requisite Software # sudo apt-get install git screen
At step 3, we install some software that will be of use in the following steps. Git is the software we will use to download MMDVMHost and/or MMDVMCal in the next step. Screen is a terminal multiplexer which will enable us to connect to the output of MMDVMHost and see what it’s doing later on.
4. Download MMDVM Software # cd /opt # sudo git clone https://github.com/g4klx/MMDVMHost.git # sudo git clone https://github.com/g4klx/MMDVMCal.git
Step 4 downloads the software’s source code. (MMDVMCal is optional).
5. Build MMDVM Host Software # cd /opt/MMDVMHost # sudo make # sudo nano MMDVM.ini Edit Settings according to Format **Make sure you change the port settings**6. Build MMDVM Calibration Tool # cd /opt/MMDVMCal # sudo make
Steps 5 and 6 build the executables and configure MMDVMHost. (MMDVMCal is still optional, but obviously it won’t be there to build if you optionally decided not to download it in step 4!)
My advice here is, once you are happy with the way the system is running, set the logging level to 0 (FileLevel=0) so you don’t write to the SD card constantly; DisplayLevel=1 is fine as-is or if you want something slightly more readable than all the hex/ascii data DisplayLevel=2 is probably what you want.
OK, here’s the bit we are interested in, else you wouldn’t be here, right …?!
7. Create 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 [Install] WantedBy=multi-user.target # sudo chmod 755 /lib/systemd/system/mmdvmhost.service Create a symbolic link between your script and a special location under /etc: # sudo ln -s /lib/systemd/system/mmdvmhost.service /etc/systemd/system/mmdvmhost.service
This step opens a text editor for you to copy the RED text and save it to a file, set some permissions and then link it to the required file elsewhere in the filesystem.
8. Create Timer # sudo nano /lib/systemd/system/mmdvmhost.timer [Timer] OnStartupSec=60 [Install] WantedBy=multi-user.target # sudo chmod 755 /lib/systemd/system/mmdvmhost.timer Create a symbolic link between your script and a special location under /etc: # sudo ln -s /lib/systemd/system/mmdvmhost.timer /etc/systemd/system/mmdvmhost.timer
Step 8 is similar to step 7 above, but this one tells it to start 60 seconds after boot.
9. Make systemd aware of your new service # sudo systemctl daemon-reload # sudo systemctl enable mmdvmhost.timer # sudo reboot Service should start 60 sec after bootup.
What we are doing in step 9 is making Jessie aware we have added and new service and enabling the 60 second timer. We’re also done, so reboot to fire her up!
The rest of the file are commands we can use to control the MMDVMHost service and how to update the software when new updates are released. Some more advice for you, copy your MMDVM.ini file somewhere safe before you update as it may be overwritten.
Appendix A Start Service manually # sudo systemctl start mmdvmhost.service Stop Service manually # sudo systemctl stop mmdvmhost.service Restart Service manually # sudo systemctl restart mmdvmhost.service Service Status # sudo systemctl status mmdvmhost.service Connect to Screen Output # sudo screen -r MMDVMHost Ctrl+a then d to disconnect from screen and keep the service running. Run MMDVMHost # sudo /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini Run MMDVMCal # sudo /opt/MMDVMHost/MMDVMCal /dev/ttyACM0 Appendix B Update MMDVM Host Software # cd /opt/MMDVMHost # sudo git pull # sudo make # sudo nano MMDVM.ini Edit Settings according to Format **Make sure you change the port settings** Update MMDVM Calibration Tool # cd /opt/MMDVMCal # sudo git pull # sudo make