With old Debian version, we can start miniSIPServer at boot by updating ‘/etc/rc.local’ file. Since most Debian versions have been migrated to systemd, so we have to change to other ways to do that.
The first way is to keep “rc.local”, so we need to enable “rc-local.service” in systemd. This service is disabled by default, we can use command below to activate it.
sudo systemctl enable rc-local
It is not a very good way because we have to update “rc-local.service” to fit miniSIPServer requirements which might affect other applications defined in the same “/etc/rc.local” file.
It is better to define an independent service to start miniSIPServer in systemd. In fact, it is quite easy. Lets explain the details in Raspberry Pi system for example. In this scenario, we will indicate Pi to start miniSIPServer (command line) at boot and the default user is “pi”.
First, please create a “minisipserver.service” file in directory “/lib/systemd/system” with content below.
[Unit] Description=miniSIPServer After=network.target mariadb.service Requires=network.target mariadb.service [Service] Type=simple GuesMainPID=no User=pi KillMode=process ExecStart=/opt/sipserver/minisipserver-cli [Install] WantedBy=multi-user.target
Then, you can use command to activate this service.
sudo systemctl enable minisipserver
Once “minisipserver.service” is enabled, miniSIPServer (command line) will start up automatically when the system is reboot.
In the “minisipserver.service” file, we can see two important sections, [Unit] and [Service], and we need to describe more details about them.
Please click here to get more details about unit section in systemd.
We care “After=” and “Requires=” parameters. Since miniSIPServer is a network application, so it requires network is ready and need to be started up after the network. In our environment, miniSIPServer is connected with Mariadb/MySQL database, so it requires the database is ready too. If you don’t need database, you can remove “mariadb.service” from “After=” and “Requires=” parameters .
Please click here to get more details about service section in systemd.
We care “User=” and “ExecStart=” parameters. “User=” parameter indicate systemd who is trying to run this service and start specific application. Since we are using Raspberry Pi system and the default user is “pi”, we set this parameter to “pi”. You need to change it to your own user name in your own Linux system. By default, miniSIPServer is installed at “/opt/sipserver” directory and the command line file is “minisipserver-cli”, so we set “ExecStart=” parameter to indicate systemd where to get the executing file and run it.