[yocto] trouble getting systemd oneshot to run
Jeremy Thien
jeremyt at adtecinc.com
Wed Mar 14 13:08:50 PDT 2018
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>
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 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
> https://lists.yoctoproject.org/listinfo/yocto
>
--
Jeremy Thien
Director of Engineering | Adtec Digital
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/7b4bd204/attachment.html>
More information about the yocto
mailing list