Virtual.System-Tools Usage of JQ in a systemctl service

  • I installed the virtual.system-tools add-on to be able to use jq json parsing as part of a systemctl service for my LibreELEC Kodi version living on a Raspberry Pi.

    I am able to execute the jq command from my SSH shell. However, I am getting what looks to be an issue finding an associated library file, libonig.so.5 when I try to execute the same command as part of a systemctl service.

    Code
    ; ExecStartPre checks if the certificate is ready for renewal, based on the exit status of the command.
    ; Check to see if cert is more than 66% to expiration, (24h * 0.66% = 16h) and if it is, and if so, renew it.
    ExecStartPre= /usr/bin/env bash -c \
      '/storage/bin/step certificate inspect /storage/.kodi/userdata/server.pem --format json --roots "/storage/.step/certs/root_ca.crt" | \
            /storage/.kodi/addons/virtual.system-tools/bin/jq -e "(((.validity.start | fromdate) + \
                ((.validity.end | fromdate) - (.validity.start | fromdate)) * 0.66) - now) \
                <= 0" > /dev/null'

    The relevant systemctl status error for my service:

    Code
    Mar 11 12:14:48 RaspyMedia env[3190]: /storage/.kodi/addons/virtual.system-tools/bin/jq: error while loading shared libraries: libonig.so.5: cannot open shared object file: No such file or directory

    I found this thread discussing what looks to be this exact problem. https://discourse.coreelec.org/t/bad-jq-in-vi…-9-0-111/3499/6

    However, when I prefixed /etc/profile;  to myExecStartPre's jq command, I got permission denied errors.

    Code
    Mar 11 12:14:48 RaspyMedia env[3188]: bash: /etc/profile: Permission denied

    Sudo is obviously no help here as such a thing doesn't exist in LibreELEC for the Pi.

    I'd really appreciate some help if anyone has any ideas on what I can change to make this work.

  • You would need to use the Environment directive to set LD_LIBRARY_PATH, more than likely.

    systemd.exec

    Something like, assuming the missing libraries are in said folder:

    Environment="LD_LIBRARY_PATH=/storage/.kodi/addons/virtual.system-tools/lib"