package/swupdate: add basic systemd service
PATCH v3 1/1 package/swupdate: add basic systemd service
From: Sam Voss <[email protected]>
---
Test cfg for verifying systemd created the symlink:
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_SYSTEMD=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.16.7" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config" BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_SWUPDATE=y
BR2_TARGET_ROOTFS_EXT2=y
Changes
v2 -> v3
- During testing we found that the service killmode needed adjusting to prevent a hang/timeout during shutdown/reboot
(https://github.com/sbabic/meta-swupdate/blob/master/recipes-support/swupdate/swupdate/swupdate.service)
v1 -> v2
[Thomas P
- Remove symlink because it is created by
[231ad359bcc0] package/systemd: use host-systemctl preset all to enable units
--- package/swupdate/swupdate.mk | 8 ++++++++ package/swupdate/swupdate.service | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 package/swupdate/swupdate.service
package/swupdate/swupdate.mk +8 -0
@@ -189,4 +189,12 @@ $(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 +endef +endif + $(eval $(kconfig-package))
package/swupdate/swupdate.service new file +18 -0
@@ -0,0 +1,18 @@ +[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}" +KillMode=mixed + +[Install] +WantedBy=multi-user.target
Signature · 1 line
2.17.1
PATCH v3 1/1 package/swupdate: add basic systemd service
package/swupdate/swupdate.mk $(error No Swupdate configuration file specified, check your BR2_PACKAGE_SWUPDAT · line 196
Quoted 5 lines · On Thu, 16 Apr 2020 14:02:09 -0500 Matt Weber…
package/swupdate/swupdate.mk +5
-0+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
Is creating this directory still necessary? I believe not. Other packages that install a systemd .service do not create such a directory.
Quoted 11 lines
$(eval $(kconfig-package))
package/swupdate/swupdate.service new file +4
-0@@ -0,0 +1,18 @@ +[Unit] +Description=SWUpdate daemon +Documentation=https://github.com/sbabic/swupdate +Documentation=https://sbabic.github.io/swupdate
package/swupdate/swupdate.service line 14
Quoted 10 lines
package/swupdate/swupdate.service new file +10
-0+ +[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}"
It this really the right way of doing this, i.e to force the options to be -p ... -v -L -w .. ?
Shouldn't this be replaced entirely by:
[Service]
Environment=SWUPDATE_ARGS="your default set of options" EnvironmentFile=/etc/default/swupdate ExecStart=/usr/bin/swupdate ${SWUPDATE_ARGS}
so that the arguments can be fully customized from /etc/default/swupdate ?
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v3 1/1 package/swupdate: add basic systemd service
Thomas,
Quoted 4 lines · Thomas Petazzoni
On Thu, 16 Apr 2020 14:02:09 -0500
Matt Weber <[email protected]> wrote:
Quoted 8 lines
package/swupdate/swupdate.mk $(error No Swupdate configuration file specified, check your BR2_PACKAGE_SWUPDAT · line 196
Quoted 5 lines
package/swupdate/swupdate.mk +5
-0+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.wantsIs creating this directory still necessary? I believe not. Other packages that install a systemd .service do not create such a directory.
True that doesn't need to be created any more.
Quoted 28 lines
Quoted 12 lines
$(eval $(kconfig-package))
package/swupdate/swupdate.service new file +4
-0@@ -0,0 +1,18 @@ +[Unit] +Description=SWUpdate daemon +Documentation=https://github.com/sbabic/swupdate +Documentation=https://sbabic.github.io/swupdatepackage/swupdate/swupdate.service line 14
Quoted 10 lines
package/swupdate/swupdate.service new file +10
-0+ +[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}"It this really the right way of doing this, i.e to force the options to be -p ... -v -L -w .. ?
Shouldn't this be replaced entirely by:
Quoted 8 lines
[Service]
Environment=SWUPDATE_ARGS="your default set of options" EnvironmentFile=/etc/default/swupdate ExecStart=/usr/bin/swupdate ${SWUPDATE_ARGS}so that the arguments can be fully customized from
/etc/default/swupdate?
Yeah the problematic part is that the web server args require a specific quoting so that that sub option can pick those up. I'll take a look at the yocto approach as they went to a shell script launch
instead to add swupdate.d/ as an option as well. [1][2] Maybe we
just adopt exactly what they're doing as it doesn't look to bad (config file is in a different location)
Regards,
Matt
[1] https://github.com/sbabic/meta-swupdate/blob/master/recipes-support/swupdate/swupdate/swupdate.service#L7
[2] https://github.com/sbabic/meta-swupdate/blob/master/recipes-support/swupdate/swupdate/swupdate.sh
PATCH v3 1/1 package/swupdate: add basic systemd service
Quoted 6 lines · On Fri, 17 Apr 2020 07:33:46 -0500 Matthew Weber <[email protected]>…
Yeah the problematic part is that the web server args require a specific quoting so that that sub option can pick those up. I'll take a look at the yocto approach as they went to a shell script launch
instead to add swupdate.d/ as an option as well. [1][2] Maybe we
just adopt exactly what they're doing as it doesn't look to bad (config file is in a different location)
Yes, the "arguments in the arguments" logic of swupdate has also caused me some troubles not long ago. It's not such a great idea :-/
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com