Re: [yocto] Enable systemd service with parameter

2019-11-18 Thread Mateusz Majchrzycki
Thanks for you help, finally I've got it working.

Just for clarification, I'm using Yocto rocko. I've checked and support for
parametrized systemd services is available in systemd.bbclass.
Also I've tried to make a dummy profile file and populate it on rootfs
instead of symlink. It also didn't work.

Finally I've change my recipe from standalone to append. My
openvpn_%.bbappend looks like:

inherit systemd
SYSTEMD_SERVICE_${PN} = "openvpn@clientprofile.service"
SYSTEMD_AUTO_ENABLE = "enable"

do_install_append() {
install -d ${D}${sysconfdir}/openvpn/
ln -sf /data/etc/openvpn/clientprofile.conf
${D}${sysconfdir}/openvpn/clientprofile.conf
}

And it works. I suppose my standalone recipe has been missing something
that prevents systemd from finding/enabling the service.
Hope it helps someone.

Mateusz


On Mon, Nov 18, 2019 at 10:47 AM Ross Burton  wrote:

> On 17/11/2019 19:44, Mateusz Majchrzycki wrote:
> > What am I doing wrong? I suppose the symlink is not a problem as
> > normally systemctl enables service with non-existent file as a parameter
> > (it fails on start, but not enabling).
>
> The problem is that the systemd class doesn't know what to do here.  I
> thought there were patches to handle this already, what release of yocto
> are you using?
>
> Ross
> --
> ___
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>


-- 
Pozdrawiam
Mateusz Majchrzycki
-- 
___
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


Re: [yocto] Enable systemd service with parameter

2019-11-18 Thread Ross Burton

On 17/11/2019 19:44, Mateusz Majchrzycki wrote:
What am I doing wrong? I suppose the symlink is not a problem as 
normally systemctl enables service with non-existent file as a parameter 
(it fails on start, but not enabling).


The problem is that the systemd class doesn't know what to do here.  I 
thought there were patches to handle this already, what release of yocto 
are you using?


Ross
--
___
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


Re: [yocto] Enable systemd service with parameter

2019-11-17 Thread Maciej Pijanowski


On 17.11.2019 20:44, Mateusz Majchrzycki wrote:

Hi!

Hi,
I have a pretty unusual problem. I need to enable a systemd service 
(openvpn) with a profile as a parameter (typically you do it by 
'systemctl enable openvpn@profile'). But the profile on build time 
doesn't exist (it is just symlink to non existing file).

My recipe bb looks like (I'm omitting SUMMARY etc.):

inherit systemd
SYSTEMD_SERVICE_${PN} = "openvpn@clientprofile.service"
SYSTEMD_AUTO_ENABLE = "enable"
DEPENDS = "openvpn"
SYSTEMD_PACKAGES = "${PN}"

do_install() {
install -d ${D}${sysconfdir}/openvpn/
ln -sf /data/etc/openvpn/clientprofile.conf 
${D}${sysconfdir}/openvpn/clientprofile.conf

}

Unfortunately, on build I get the following error:
ERROR: openvpn-client-1.0-r3 do_package: 
SYSTEMD_SERVICE_openvpn-client value openvpn@clientprofile.service 
does not exist
ERROR: openvpn-client-1.0-r3 do_package: Function failed: 
systemd_populate_packages


What am I doing wrong? I suppose the symlink is not a problem as 
normally systemctl enables service with non-existent file as a 
parameter (it fails on start, but not enabling).
Maybe you could just create that file 
/data/etc/openvpn/clientprofile.conf and install it within the recipe?
It can be even empty. The service will keep failing. The build shall 
pass. Sounds reasonable?


Best regards,
Mateusz



--
Maciej Pijanowski
Embedded Systems Engineer
https://3mdeb.com | @3mdeb_com

-- 
___
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto