gammu 1.42, gammu-smsd service error, LD_LIBRARY_PATH not found
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:
[[email protected] 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: Starting SMS daemon for Gammu... Oct 25 12:13:42 Centos8Gateway gammu-smsd: /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: gammu-smsd.service: Control process exited, code=exited status=127 Oct 25 12:13:42 Centos8Gateway systemd: gammu-smsd.service: Failed with result 'exit-code'. Oct 25 12:13:42 Centos8Gateway systemd: Failed to start SMS daemon for Gammu. [[email protected] 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!
/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.:
Note that I’ve omitted
. compared to what you have in
- 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.
.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.