diff mbox series

package/swupdate: Add basic systemd service

Message ID 20200414135231.27737-1-matthew.weber@rockwellcollins.com
State Changes Requested
Headers show
Series package/swupdate: Add basic systemd service | expand

Commit Message

Matt Weber April 14, 2020, 1:52 p.m. UTC
From: Sam Voss <sam.voss@rockwellcollins.com>

Signed-off-by: Sam Voss <sam.voss@rockwellcollins.com>
Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
---
 package/swupdate/swupdate.mk      | 10 ++++++++++
 package/swupdate/swupdate.service | 17 +++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 package/swupdate/swupdate.service

Comments

Thomas Petazzoni April 14, 2020, 4:23 p.m. UTC | #1
On Tue, 14 Apr 2020 08:52:31 -0500
Matt Weber <matthew.weber@rockwellcollins.com> wrote:

> From: Sam Voss <sam.voss@rockwellcollins.com>
> 
> Signed-off-by: Sam Voss <sam.voss@rockwellcollins.com>
> Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
> ---
>  package/swupdate/swupdate.mk      | 10 ++++++++++
>  package/swupdate/swupdate.service | 17 +++++++++++++++++
>  2 files changed, 27 insertions(+)
>  create mode 100644 package/swupdate/swupdate.service
> 
> diff --git a/package/swupdate/swupdate.mk b/package/swupdate/swupdate.mk
> index 2b51edb66d..2300220d93 100644
> --- a/package/swupdate/swupdate.mk
> +++ b/package/swupdate/swupdate.mk
> @@ -189,4 +189,14 @@ $(error No Swupdate configuration file specified, check your BR2_PACKAGE_SWUPDAT
>  endif
>  endif
>  
> +ifeq ($(BR2_PACKAGE_SWUPDATE_INSTALL_WEBSITE),y)
> +define SWUPDATE_INSTALL_INIT_SYSTEMD
> +	$(INSTALL) -D -m 644 package/swupdate/swupdate.service \
> +		$(TARGET_DIR)/usr/lib/systemd/system/swupdate.service
> +	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
> +	ln -sf ../../../../usr/lib/systemd/system/swupdate.service \
> +		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/swupdate.service

This symlink is no longer needed now that we have host-systemd as far
as I understand.

Best regards,

Thomas
Matt Weber April 14, 2020, 5:31 p.m. UTC | #2
Thomas,

On Tue, Apr 14, 2020 at 11:24 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> On Tue, 14 Apr 2020 08:52:31 -0500
> Matt Weber <matthew.weber@rockwellcollins.com> wrote:
>
> > From: Sam Voss <sam.voss@rockwellcollins.com>
> >
> > Signed-off-by: Sam Voss <sam.voss@rockwellcollins.com>
> > Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
> > ---
> >  package/swupdate/swupdate.mk      | 10 ++++++++++
> >  package/swupdate/swupdate.service | 17 +++++++++++++++++
> >  2 files changed, 27 insertions(+)
> >  create mode 100644 package/swupdate/swupdate.service
> >
> > diff --git a/package/swupdate/swupdate.mk b/package/swupdate/swupdate.mk
> > index 2b51edb66d..2300220d93 100644
> > --- a/package/swupdate/swupdate.mk
> > +++ b/package/swupdate/swupdate.mk
> > @@ -189,4 +189,14 @@ $(error No Swupdate configuration file specified, check your BR2_PACKAGE_SWUPDAT
> >  endif
> >  endif
> >
> > +ifeq ($(BR2_PACKAGE_SWUPDATE_INSTALL_WEBSITE),y)
> > +define SWUPDATE_INSTALL_INIT_SYSTEMD
> > +     $(INSTALL) -D -m 644 package/swupdate/swupdate.service \
> > +             $(TARGET_DIR)/usr/lib/systemd/system/swupdate.service
> > +     mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
> > +     ln -sf ../../../../usr/lib/systemd/system/swupdate.service \
> > +             $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/swupdate.service
>
> This symlink is no longer needed now that we have host-systemd as far
> as I understand.
>

Is there a good example of how that works?

Matt
Matt Weber April 15, 2020, 1:21 p.m. UTC | #3
Thomas,


On Tue, Apr 14, 2020 at 12:31 PM Matthew Weber
<matthew.weber@rockwellcollins.com> wrote:
>
> Thomas,
>
> On Tue, Apr 14, 2020 at 11:24 AM Thomas Petazzoni
> <thomas.petazzoni@bootlin.com> wrote:
> >
> > On Tue, 14 Apr 2020 08:52:31 -0500
> > Matt Weber <matthew.weber@rockwellcollins.com> wrote:
> >
> > > From: Sam Voss <sam.voss@rockwellcollins.com>
> > >
> > > Signed-off-by: Sam Voss <sam.voss@rockwellcollins.com>
> > > Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
> > > ---
> > >  package/swupdate/swupdate.mk      | 10 ++++++++++
> > >  package/swupdate/swupdate.service | 17 +++++++++++++++++
> > >  2 files changed, 27 insertions(+)
> > >  create mode 100644 package/swupdate/swupdate.service
> > >
> > > diff --git a/package/swupdate/swupdate.mk b/package/swupdate/swupdate.mk
> > > index 2b51edb66d..2300220d93 100644
> > > --- a/package/swupdate/swupdate.mk
> > > +++ b/package/swupdate/swupdate.mk
> > > @@ -189,4 +189,14 @@ $(error No Swupdate configuration file specified, check your BR2_PACKAGE_SWUPDAT
> > >  endif
> > >  endif
> > >
> > > +ifeq ($(BR2_PACKAGE_SWUPDATE_INSTALL_WEBSITE),y)
> > > +define SWUPDATE_INSTALL_INIT_SYSTEMD
> > > +     $(INSTALL) -D -m 644 package/swupdate/swupdate.service \
> > > +             $(TARGET_DIR)/usr/lib/systemd/system/swupdate.service
> > > +     mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
> > > +     ln -sf ../../../../usr/lib/systemd/system/swupdate.service \
> > > +             $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/swupdate.service
> >
> > This symlink is no longer needed now that we have host-systemd as far
> > as I understand.
> >
>
> Is there a good example of how that works?

Nevermind, I looked through [231ad359bcc0] package/systemd: use
host-systemctl preset all to enable units.  Seems pretty transparent.
I'll send an update.

Matt
diff mbox series

Patch

diff --git a/package/swupdate/swupdate.mk b/package/swupdate/swupdate.mk
index 2b51edb66d..2300220d93 100644
--- a/package/swupdate/swupdate.mk
+++ b/package/swupdate/swupdate.mk
@@ -189,4 +189,14 @@  $(error No Swupdate configuration file specified, check your BR2_PACKAGE_SWUPDAT
 endif
 endif
 
+ifeq ($(BR2_PACKAGE_SWUPDATE_INSTALL_WEBSITE),y)
+define SWUPDATE_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 644 package/swupdate/swupdate.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/swupdate.service
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	ln -sf ../../../../usr/lib/systemd/system/swupdate.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/swupdate.service
+endef
+endif
+
 $(eval $(kconfig-package))
diff --git a/package/swupdate/swupdate.service b/package/swupdate/swupdate.service
new file mode 100644
index 0000000000..cb065a0414
--- /dev/null
+++ b/package/swupdate/swupdate.service
@@ -0,0 +1,17 @@ 
+[Unit]
+Description=SWUpdate daemon
+Documentation=https://github.com/sbabic/swupdate
+Documentation=https://sbabic.github.io/swupdate
+
+[Service]
+# Default environment variables in case /etc/default/swupdate isn't providing them
+Environment=SWU_POST_UPDATE_CMD="touch /tmp/.swu_complete"
+Environment=SWU_WEBSERVER_ARGS="-p 8080 -r /var/www/swupdate/"
+
+# Always take what is in the environment files when exists
+EnvironmentFile=/etc/default/swupdate
+
+ExecStart=/usr/bin/swupdate ${SWU_KEY_ARGS} -p ${SWU_POST_UPDATE_CMD} -v -L -w "${SWU_WEBSERVER_ARGS}"
+
+[Install]
+WantedBy=multi-user.target