Shell-Skript starting from Service to read config

46 views
Skip to first unread message

Florian Bär

unread,
Sep 11, 2023, 2:35:52 AM9/11/23
to swupdate
Hello, 
i implemented an automatic start of swupdate on my client with autostarting swupdate.service. 

i placed following file inside /etc/swupdate/conf.d/...
#!/bin/sh

SWUPDATE_ARGS='-f /etc/swupdate/swupdate.conf '
SWUPDATE_SURICATTA_ARGS="-t default -i dev01 -u http://<URL> -k <hawkBit security token>"

it executes everything just fine. But i don't want to hardcode the suricatta args here. Is there a possibility to use my .conf file as in SWUPDATE_ARGS?

Kind Regards

Dimitar Maznekov

unread,
Sep 11, 2023, 3:00:10 AM9/11/23
to swup...@googlegroups.com
Sure, you can hardcode all arguments in swupdate.cfg like described here: https://github.com/sbabic/swupdate/blob/master/examples/configuration/swupdate.cfg#L199
And then command line should looks like swupdate -u "" to take settings from swupdate.cfg

Dimitar Maznekov



--
You received this message because you are subscribed to the Google Groups "swupdate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swupdate+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swupdate/e6447a34-a961-41d7-8680-c87867b65c24n%40googlegroups.com.




OPTIX Co. Disclaimer ISO 27001:2013 [ F1 ]
This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.
OPTIX Co. is an industry leader in the field of optics, opto-mechanical devices and opto-electronic systems. We provide the most comprehensive solutions of custom designs for both civil and defense application.



Florian Bär

unread,
Sep 11, 2023, 3:11:27 AM9/11/23
to swupdate
Quite not,  i think. Because in /usr/lib/swupdate/swupdate.sh

you got following if-cases:

#  handle variable escaping in a simmple way. Use exec to forward open filedescriptors from systemd open.
if [ "$SWUPDATE_WEBSERVER_ARGS" != "" -a  "$SWUPDATE_SURICATTA_ARGS" != "" ]; then
  exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS" -u "$SWUPDATE_SURICATTA_ARGS"
elif [ "$SWUPDATE_WEBSERVER_ARGS" != "" ]; then
  exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS"
elif [ "$SWUPDATE_SURICATTA_ARGS" != "" ]; then
  exec /usr/bin/swupdate $SWUPDATE_ARGS -u "$SWUPDATE_SURICATTA_ARGS"
else
  exec /usr/bin/swupdate $SWUPDATE_ARGS
fi

and if SWUPDATE_SURICATTA_ARGS == "" what it would be in your suggestion it would not execute the command with option "-u" meaning it would not execute suricatta. 

If i delete or set it to empty string SWUPDATE_SURICATTA_ARGS in my conf.d/... file i get following error message:

ep 11 07:09:54 dh-stm32mp1-dhcor-avenger96 swupdate.sh[413]: [DEBUG] : SWUPDATE running :  [read_module_settings] : No config settings found for module webserver
Sep 11 07:09:54 dh-stm32mp1-dhcor-avenger96 swupdate.sh[413]: [TRACE] : SWUPDATE running :  [start_swupdate_subprocess] : Started webserver with pid 424 and fd 9
Sep 11 07:09:54 dh-stm32mp1-dhcor-avenger96 swupdate.sh[413]: [DEBUG] : SWUPDATE running :  [read_settings_file] : Reading config file /etc/swupdate/swupdate.conf
Sep 11 07:09:54 dh-stm32mp1-dhcor-avenger96 swupdate.sh[413]: [DEBUG] : SWUPDATE running :  [read_module_settings] : No config settings found for module webserver
Sep 11 07:09:54 dh-stm32mp1-dhcor-avenger96 swupdate.sh[413]: [INFO ] : SWUPDATE running :  [start_mongoose] : Mongoose web server version 7.8 with pid 424 started on [31.144.0.0] with web root [/www]

Dimitar Maznekov

unread,
Sep 11, 2023, 5:09:56 AM9/11/23
to swup...@googlegroups.com
No one can stop you to edit it for your needs
SWUPDATE_ARGS="-f /settings/swupdate.cfg --key /settings/swupdate-public.pem  $SWUPDATE_EXTRA_ARGS -p /usr/lib/swupdate/sysreboot"
SWUPDATE_WEBSERVER_ARGS=""
SWUPDATE_SURICATTA_ARGS=""
SELECT_ARGS="stable,full"

# source all files from /etc/swupdate/conf.d and /usr/lib/swupdate/conf.d/
# A file found in /etc replaces the same file in /usr
for f in `(test -d /usr/lib/swupdate/conf.d/ && ls -1 /usr/lib/swupdate/conf.d/; test -d /etc/swupdate/conf.d && ls -1 /etc/swupdate/conf.d) | sort -u`; do
  if [ -f /etc/swupdate/conf.d/$f ]; then
    . /etc/swupdate/conf.d/$f
  else
    . /usr/lib/swupdate/conf.d/$f
  fi
done

exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS" -u "$SWUPDATE_SURICATTA_ARGS" --select "$SELECT_ARGS"

Dimitar Maznekov

Florian Bär

unread,
Sep 11, 2023, 5:19:01 AM9/11/23
to swupdate
Working perfectly. Thx a lot
Reply all
Reply to author
Forward
0 new messages