[yocto] trouble getting systemd oneshot to run

Greg Wilson-Lindberg GWilson at sakuraus.com
Wed Mar 14 15:04:24 PDT 2018


I changed it to look like:

PACKAGES += "${PN}-service"

FILES_${PN} = "${datadir}/*"
FILES_${PN}-service = "${systemd_system_unitdir}/canstart.service"

do_install () {
    if test -e ${WORKDIR}/can_start.sh &&
       test -e ${WORKDIR}/canstart.service; then
        install -d ${D}${datadir}/canstart
        install -m 0755 ${WORKDIR}/can_start.sh ${D}${datadir}/canstart
        install -d ${D}${systemd_system_unitdir}
        install -m 0644 ${WORKDIR}/canstart.service ${D}${systemd_system_unitdir}
        sed -i -e 's|@SCRIPTDIR@|${datadir}/canstart|g' ${D}${systemd_system_unitdir}/canstart.service
    fi
}


SYSTEMD_PACKAGES = "${PN}-service"
SYSTEMD_SERVICE_${PN}-service = "canstart.service"
SYSTEMD_AUTO_ENABLE_${PN}-service = "enable"



Still got the same results, my task is not running at startup.
To make sure that there wasn't some problem in running the script, I changed the ExecStart to echo to a file in /tmp. Nothing there. The .service file is not being executed.
I've obviously got something totally messed up, but I'm darned if I understand what it is.


________________________________
From: Jeremy Thien <jeremyt at adtecinc.com>
Sent: Wednesday, March 14, 2018 1:08 PM
To: Greg Wilson-Lindberg
Cc: yocto at yoctoproject.org
Subject: Re: [yocto] trouble getting systemd oneshot to run

I am no expert, but I have a similar recipe. It might be over complicated, but I put the script in one package and the service in another something like:

PACKAGES += "${PN}-service"
FILES_${PN} = "${datadir}/canstart/canstart.sh "
FILES_${PN}-service = "${systemd_unitdir}/system/canstart.service "
SYSTEMD_PACKAGES = ${PN}-service"
SYSTEMD_SERVICE_${PN}-service = canstart.service"
SYSTEMD_AUTO_ENABLE_${PN}-service = "enable"

Of course, this requires image to install both canstart and canstart-service.

Hope this helps,
Jeremy Thien

On Wed, Mar 14, 2018 at 3:21 PM Greg Wilson-Lindberg <GWilson at sakuraus.com<mailto:GWilson at sakuraus.com>> wrote:

I'm building yocto for a raspberry pi3 from Qt's b2qt version.


I'm running into two problems, I've got all of the files copying to the correct locations but the .service is not running at startup. I used connman-conf.bb<http://connman-conf.bb> as the template for my .bb file:


SUMMARY="recipe to create CAN bus startup service"

LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""

inherit systemd

SRC_URI = "file://can_start.sh \
           file://canstart.service \
"

S = "${WORKDIR}"

PACKAGE_ARCH = "${MACHINE_ARCH}"

FILES_${PN} = "${datadir}/*"

do_install () {
    if test -e ${WORKDIR}/can_start.sh &&
       test -e ${WORKDIR}/canstart.service; then
        install -d ${D}${datadir}/canstart
        install -m 0755 ${WORKDIR}/can_start.sh ${D}${datadir}/canstart
        install -d ${D}${systemd_system_unitdir}
        install -m 0644 ${WORKDIR}/canstart.service ${D}${systemd_system_unitdir}
        sed -i -e 's|@SCRIPTDIR@|${datadir}/canstart|g' ${D}${systemd_system_unitdir}/canstart.service
    fi
}

SYSTEMD_SERVICE_${PN} = "canstart.service"



Service file:




[Unit]
Description=Startup CAN bus interface

[Service]
Type=oneshot
ExecStart=@SCRIPTDIR@/can_start.sh

[Install]
WantedBy=network.target



>From looking at the connman-conf sample I'm setting everything up correctly and the service should default to running on startup but it is not.

The second 'problem' is really just perplexing, if I dump the variables S contains a path to a directory in my root not "${WORKDIR}".


Any and all help with this would be greatly appreciated.


Regards,

Greg Wilson-Lindberg

--
_______________________________________________
yocto mailing list
yocto at yoctoproject.org<mailto:yocto at yoctoproject.org>
https://lists.yoctoproject.org/listinfo/yocto
--
Jeremy Thien
Director of Engineering | Adtec Digital
jeremy.thien at adtecdigital.net<mailto:jeremy.thien at adtecdigital.net> | mobile: +1 (904) 910-1749
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20180314/e93315bd/attachment.html>


More information about the yocto mailing list