0

I'm trying install Gammu 1.42 to serve my SMS gateway on Centos 8.

make, make test, make install works fine.

LD_LIBRARY_PATH configured in /etc/profile as:

......
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:.:/usr/local/lib64
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL LD_LIBRARY_PATH
......

I print env by printenv, LD_LIBRARY_PATH found. /etc/gammu-smsdrc configured as:

......
[gammu]
device = /dev/ttyUSB0
model = E3131
connection = at115200

[smsd]
service = sql
driver = native_pgsql
logFIle = /var/log/gammu/smsd.log
logFormat = errorsdate
Host = xx.0.1.xx:xxxx
user = xxxx
password = xxxxx
database = xxxxx
debuglevel = 2
StatusFrequency = 60
LoopSleep = 60
DeliveryReport = sms
PhoneID = ozssc-smsd
SMSC = +614xxxxxxxx
BackendRetries = 60

I tried start gammu command line in terminal, it works fine. But when I tried to start system service by using systemctl, it failed.

error query result as:

[root@Centos8Gateway etc]# systemctl status gammu-smsd.service
● gammu-smsd.service - SMS daemon for Gammu
  Loaded: loaded (/usr/lib/systemd/system/gammu-smsd.service; disabled; vendor preset: disabled)
  Active: failed (Result: exit-code) since Sun 2020-10-25 12:13:42 AEDT; 19s ago
     Docs: man:gammu-smsd(1)
  Process: 23247 ExecStopPost=/bin/rm -f /var/run/gammu-smsd.pid (code=exited, status=0/SUCCESS)
  Process: 23245 ExecStart=/usr/local/bin/gammu-smsd --pid=/var/run/gammu-smsd.pid --daemon (code=exited, status=127)

Oct 25 12:13:42 Centos8Gateway systemd[1]: Starting SMS daemon for Gammu...
Oct 25 12:13:42 Centos8Gateway gammu-smsd[23245]: /usr/local/bin/gammu-smsd: error while loading shared libraries: libgsmsd.so.8: cannot open shared object file: No such file or directory
Oct 25 12:13:42 Centos8Gateway systemd[1]: gammu-smsd.service: Control process exited, code=exited status=127
Oct 25 12:13:42 Centos8Gateway systemd[1]: gammu-smsd.service: Failed with result 'exit-code'.
Oct 25 12:13:42 Centos8Gateway systemd[1]: Failed to start SMS daemon for Gammu.
[root@Centos8Gateway etc]# 

I'm trying to find out why Centos 8 system service loader not use configured system environment variable? and not provide command line LD lib path parameters as well.

What I missed? Please advise!

cidy.long
  • 101
  • 3

2 Answers2

0

/etc/profile is used by shells like bash; it is not used to set up the environment for systemd services.

To provide an environment variable to a systemd service, use Environment=` in the systemd unit file, e.g.:

Environment="LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64"

Note that I've omitted $LD_LIBRARY_PATH and . compared to what you have in /etc/profile:

  1. That variable will usually be empty by default and any definitions in a systemd unit file for such an important variable should probably be completely explicit, for clarity and clear expectations.
  2. . is a bit unusual; in the context of a systemd unit, it will be the value of WorkingDirectory which you can already know/should know, in which case you can explicitly expand it, again, for clarity and clear expectations.
Craig Miskell
  • 4,216
  • 1
  • 16
  • 16
0

There is an other way to fix this issue by:

  1. Add a new file as gammu-smsd-1.42.0-x86_64.conf under /etc/ld.so.conf.d only one line in it as:

    /usr/local/lib64

  2. Then run ldconfig by root user.

retry to start gammu-smsd from systemctl done.

cidy.long
  • 101
  • 3