buildroot.busybox.net archive mirror
 help / color / mirror / Atom feed
* [Buildroot] [PATCH next 0/3] package/inadyn: start script rework + repost
@ 2021-12-05 10:29 Joachim Wiberg
  2021-12-05 10:29 ` [Buildroot] [PATCH next 1/3] package/inadyn: replace local systemd unit file with upstream Joachim Wiberg
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Joachim Wiberg @ 2021-12-05 10:29 UTC (permalink / raw)
  To: buildroot; +Cc: Joachim Wiberg, thomas.petazzoni

Hi Thomas, all!

This patch set contains the rework of the inadyn start script.  It is
now modeled closely on BusyBox S01syslogd, as requested.

I'm also including a repost of the .conf example update and the switch
to use the upstrem systemd unit file.

Best regards
 /Joachim

Joachim Wiberg (3):
  package/inadyn: replace local systemd unit file with upstream
  package/inadyn: refactor start script
  package/inadyn: update inadyn.conf example

 package/inadyn/S70inadyn      | 100 ++++++++++++++++++++++------------
 package/inadyn/inadyn.conf    |  25 +++++++--
 package/inadyn/inadyn.mk      |   2 +-
 package/inadyn/inadyn.service |  10 ----
 4 files changed, 86 insertions(+), 51 deletions(-)
 mode change 100644 => 100755 package/inadyn/S70inadyn
 delete mode 100644 package/inadyn/inadyn.service

-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH next 1/3] package/inadyn: replace local systemd unit file with upstream
  2021-12-05 10:29 [Buildroot] [PATCH next 0/3] package/inadyn: start script rework + repost Joachim Wiberg
@ 2021-12-05 10:29 ` Joachim Wiberg
  2021-12-05 10:32   ` Joachim Wiberg
  2021-12-05 10:29 ` [Buildroot] [PATCH next 2/3] package/inadyn: refactor start script Joachim Wiberg
  2021-12-05 10:29 ` [Buildroot] [PATCH next 3/3] package/inadyn: update inadyn.conf example Joachim Wiberg
  2 siblings, 1 reply; 7+ messages in thread
From: Joachim Wiberg @ 2021-12-05 10:29 UTC (permalink / raw)
  To: buildroot; +Cc: Joachim Wiberg, thomas.petazzoni

If systemd is available at configure time, the inadyn configure script
detects it and generates the unit file.

Also, the local unit file had the wrong absolute path to the binary.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
---
 package/inadyn/inadyn.mk      |  2 +-
 package/inadyn/inadyn.service | 10 ----------
 2 files changed, 1 insertion(+), 11 deletions(-)
 delete mode 100644 package/inadyn/inadyn.service

diff --git a/package/inadyn/inadyn.mk b/package/inadyn/inadyn.mk
index fc04fd5f25..9ccb16ddfe 100644
--- a/package/inadyn/inadyn.mk
+++ b/package/inadyn/inadyn.mk
@@ -31,7 +31,7 @@ define INADYN_INSTALL_INIT_SYSV
 endef
 
 define INADYN_INSTALL_INIT_SYSTEMD
-	$(INSTALL) -D -m 644 package/inadyn/inadyn.service \
+	$(INSTALL) -D -m 644 $(@D)/inadyn.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/inadyn.service
 endef
 
diff --git a/package/inadyn/inadyn.service b/package/inadyn/inadyn.service
deleted file mode 100644
index abc0a1e401..0000000000
--- a/package/inadyn/inadyn.service
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=DDNS client
-After=syslog.target network.target
-
-[Service]
-ExecStart=/usr/bin/inadyn
-Restart=always
-
-[Install]
-WantedBy=multi-user.target
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH next 2/3] package/inadyn: refactor start script
  2021-12-05 10:29 [Buildroot] [PATCH next 0/3] package/inadyn: start script rework + repost Joachim Wiberg
  2021-12-05 10:29 ` [Buildroot] [PATCH next 1/3] package/inadyn: replace local systemd unit file with upstream Joachim Wiberg
@ 2021-12-05 10:29 ` Joachim Wiberg
  2022-01-09  8:57   ` Peter Korsgaard
  2021-12-05 10:29 ` [Buildroot] [PATCH next 3/3] package/inadyn: update inadyn.conf example Joachim Wiberg
  2 siblings, 1 reply; 7+ messages in thread
From: Joachim Wiberg @ 2021-12-05 10:29 UTC (permalink / raw)
  To: buildroot; +Cc: Joachim Wiberg, thomas.petazzoni

This patch is a complete rewrite of the Inadyn start script, based on
the BusyBox S01syslogd template.  Additional features, compared to the
template, are limited to the ability to:

 - Check if enabled, using an ENABLED="yes" from /etc/default/inadyn,
   this for compatibility with the previous version of the script
 - Override INADYN_ARGS from /etc/default/inadyn
 - A reload command that sends SIGHUP, since that works and is both
   quicker and a less resource intensive operation

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
---
 package/inadyn/S70inadyn | 100 +++++++++++++++++++++++++--------------
 1 file changed, 65 insertions(+), 35 deletions(-)
 mode change 100644 => 100755 package/inadyn/S70inadyn

diff --git a/package/inadyn/S70inadyn b/package/inadyn/S70inadyn
old mode 100644
new mode 100755
index ca7b414678..d44acacec3
--- a/package/inadyn/S70inadyn
+++ b/package/inadyn/S70inadyn
@@ -1,44 +1,74 @@
 #!/bin/sh
+# Customizations are sourced from /etc/default/inadyn.  For example,
+# override INADYN_ARGS to adjust log level, add a startup delay, etc.
 #
-# Start & stop the inadyn client
-#
+# NOTE: to start, add a line ENABLED="yes" to /etc/default/inadyn
+
+DAEMON="inadyn"
+PIDFILE="/var/run/$DAEMON.pid"
+
+INADYN_ARGS=""
 
-CONFIG=/etc/inadyn.conf
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
 
-# check if CONFIG exists, print message & exit if it doesn't
-[ ! -f $CONFIG ] && ( echo "The config file "$CONFIG" is missing...exiting now." && exit 2 )
+start()
+{
+	printf 'Starting %s: ' "$DAEMON"
+	if [ "$ENABLED" != "yes" ]; then
+		echo "SKIPPED"
+		exit 0
+	fi
+	# shellcheck disable=SC2086 # we need the word splitting
+	start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
+			  -- $INADYN_ARGS
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
 
-# Allow a few customizations from a config file. Especially inadyn
-# must be explicitly enabled by adding ENABLED="yes" in this file.
-test -r /etc/default/inadyn && . /etc/default/inadyn
+stop()
+{
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon -K -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f "$PIDFILE"
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+restart()
+{
+	stop
+	sleep 1
+	start
+}
+
+reload()
+{
+	printf 'Reloading %s: ' "$DAEMON"
+	start-stop-daemon -K -s HUP -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
 
 case "$1" in
-	start)
-		printf "Starting inadyn: "
-		if test "${ENABLED}" != "yes" ; then
-		    echo "SKIPPED"
-		    exit 0
-		fi
-		start-stop-daemon -b -q -S -p /var/run/inadyn.pid -x /usr/sbin/inadyn
-		[ $? = 0 ] && echo "OK" || echo "FAIL"
-		;;
-	stop)
-		printf "Stopping inadyn: "
-		if test "${ENABLED}" != "yes" ; then
-		    echo "SKIPPED"
-		    exit 0
-		fi
-		start-stop-daemon -q -K -p /var/run/inadyn.pid -x /usr/sbin/inadyn
-		[ $? = 0 ] && echo "OK" || echo "FAIL"
-		rm -f /var/run/inadyn.pid
-		;;
-	restart)
-		"$0" stop
-		"$0" start
-		;;
-		*)
-		echo "Usage: $0 {start|stop|restart}"
+	start|stop|restart|reload)
+		"$1";;
+	*)
+		echo "Usage: $0 {start|stop|restart|reload}"
 		exit 1
 esac
-
-exit $?
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH next 3/3] package/inadyn: update inadyn.conf example
  2021-12-05 10:29 [Buildroot] [PATCH next 0/3] package/inadyn: start script rework + repost Joachim Wiberg
  2021-12-05 10:29 ` [Buildroot] [PATCH next 1/3] package/inadyn: replace local systemd unit file with upstream Joachim Wiberg
  2021-12-05 10:29 ` [Buildroot] [PATCH next 2/3] package/inadyn: refactor start script Joachim Wiberg
@ 2021-12-05 10:29 ` Joachim Wiberg
  2021-12-11 20:42   ` Arnout Vandecappelle
  2 siblings, 1 reply; 7+ messages in thread
From: Joachim Wiberg @ 2021-12-05 10:29 UTC (permalink / raw)
  To: buildroot; +Cc: Joachim Wiberg, thomas.petazzoni

 - Comment out iface setting, usually not what you want
 - Update DynDNS example, show use of multiple hostnames
 - Add FreeDNS sample config, free and stable service
 - Add link to syntax and examples

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
---
 package/inadyn/inadyn.conf | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/package/inadyn/inadyn.conf b/package/inadyn/inadyn.conf
index 1b29027606..3328ee2218 100644
--- a/package/inadyn/inadyn.conf
+++ b/package/inadyn/inadyn.conf
@@ -1,11 +1,26 @@
-# Basic configuration file for inadyn
+# Example /etc/inadyn.conf
 #
-# /etc/inadyn.conf
-iface    = eth0
+# Remember to change this file to match your provider and credentials
+# Username and password can be included from another file.  For more
+# info, see https://man.troglobit.com/man5/inadyn.conf.5.html
+
+# Use IP address of interface instead of external checkip server.
+# Useful when you want to register internal IP addresses
+#iface    = eth0
+
+# IP address change check interval
 period   = 300
 
-provider default@dyndns.org {
+# Remove of change to match your Dyn account
+provider dyndns.org {
 	username    = test
 	password    = test
-	hostname    = test
+	hostname    = { "my.example.com", "other.example.org" }
+}
+
+# Remove or change to match your FreeDNS account
+provider freedns {
+     username   = lower-case-username
+     password   = case-sensitive-pwd
+     hostname   = some.example.com
 }
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH next 1/3] package/inadyn: replace local systemd unit file with upstream
  2021-12-05 10:29 ` [Buildroot] [PATCH next 1/3] package/inadyn: replace local systemd unit file with upstream Joachim Wiberg
@ 2021-12-05 10:32   ` Joachim Wiberg
  0 siblings, 0 replies; 7+ messages in thread
From: Joachim Wiberg @ 2021-12-05 10:32 UTC (permalink / raw)
  To: buildroot; +Cc: thomas.petazzoni

Hi,

please ignore this specific patch repost.  I see now it actually made it
into next already.

Sorry for the noise!

Best regards
 /Joachim

On 12/5/21 11:29 AM, Joachim Wiberg wrote:
> If systemd is available at configure time, the inadyn configure script
> detects it and generates the unit file.
> 
> Also, the local unit file had the wrong absolute path to the binary.
> 
> Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
> ---
>  package/inadyn/inadyn.mk      |  2 +-
>  package/inadyn/inadyn.service | 10 ----------
>  2 files changed, 1 insertion(+), 11 deletions(-)
>  delete mode 100644 package/inadyn/inadyn.service
> 
> diff --git a/package/inadyn/inadyn.mk b/package/inadyn/inadyn.mk
> index fc04fd5f25..9ccb16ddfe 100644
> --- a/package/inadyn/inadyn.mk
> +++ b/package/inadyn/inadyn.mk
> @@ -31,7 +31,7 @@ define INADYN_INSTALL_INIT_SYSV
>  endef
>  
>  define INADYN_INSTALL_INIT_SYSTEMD
> -	$(INSTALL) -D -m 644 package/inadyn/inadyn.service \
> +	$(INSTALL) -D -m 644 $(@D)/inadyn.service \
>  		$(TARGET_DIR)/usr/lib/systemd/system/inadyn.service
>  endef
>  
> diff --git a/package/inadyn/inadyn.service b/package/inadyn/inadyn.service
> deleted file mode 100644
> index abc0a1e401..0000000000
> --- a/package/inadyn/inadyn.service
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -[Unit]
> -Description=DDNS client
> -After=syslog.target network.target
> -
> -[Service]
> -ExecStart=/usr/bin/inadyn
> -Restart=always
> -
> -[Install]
> -WantedBy=multi-user.target
> 

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH next 3/3] package/inadyn: update inadyn.conf example
  2021-12-05 10:29 ` [Buildroot] [PATCH next 3/3] package/inadyn: update inadyn.conf example Joachim Wiberg
@ 2021-12-11 20:42   ` Arnout Vandecappelle
  0 siblings, 0 replies; 7+ messages in thread
From: Arnout Vandecappelle @ 2021-12-11 20:42 UTC (permalink / raw)
  To: Joachim Wiberg, buildroot; +Cc: thomas.petazzoni



On 05/12/2021 11:29, Joachim Wiberg wrote:
>   - Comment out iface setting, usually not what you want
>   - Update DynDNS example, show use of multiple hostnames
>   - Add FreeDNS sample config, free and stable service
>   - Add link to syntax and examples
> 
> Signed-off-by: Joachim Wiberg <troglobit@gmail.com>

  Applied to master, thanks.

  Regards,
  Arnout

> ---
>   package/inadyn/inadyn.conf | 25 ++++++++++++++++++++-----
>   1 file changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/package/inadyn/inadyn.conf b/package/inadyn/inadyn.conf
> index 1b29027606..3328ee2218 100644
> --- a/package/inadyn/inadyn.conf
> +++ b/package/inadyn/inadyn.conf
> @@ -1,11 +1,26 @@
> -# Basic configuration file for inadyn
> +# Example /etc/inadyn.conf
>   #
> -# /etc/inadyn.conf
> -iface    = eth0
> +# Remember to change this file to match your provider and credentials
> +# Username and password can be included from another file.  For more
> +# info, see https://man.troglobit.com/man5/inadyn.conf.5.html
> +
> +# Use IP address of interface instead of external checkip server.
> +# Useful when you want to register internal IP addresses
> +#iface    = eth0
> +
> +# IP address change check interval
>   period   = 300
>   
> -provider default@dyndns.org {
> +# Remove of change to match your Dyn account
> +provider dyndns.org {
>   	username    = test
>   	password    = test
> -	hostname    = test
> +	hostname    = { "my.example.com", "other.example.org" }
> +}
> +
> +# Remove or change to match your FreeDNS account
> +provider freedns {
> +     username   = lower-case-username
> +     password   = case-sensitive-pwd
> +     hostname   = some.example.com
>   }
> 
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH next 2/3] package/inadyn: refactor start script
  2021-12-05 10:29 ` [Buildroot] [PATCH next 2/3] package/inadyn: refactor start script Joachim Wiberg
@ 2022-01-09  8:57   ` Peter Korsgaard
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Korsgaard @ 2022-01-09  8:57 UTC (permalink / raw)
  To: Joachim Wiberg; +Cc: thomas.petazzoni, buildroot

>>>>> "Joachim" == Joachim Wiberg <troglobit@gmail.com> writes:

 > This patch is a complete rewrite of the Inadyn start script, based on
 > the BusyBox S01syslogd template.  Additional features, compared to the
 > template, are limited to the ability to:

 >  - Check if enabled, using an ENABLED="yes" from /etc/default/inadyn,
 >    this for compatibility with the previous version of the script
 >  - Override INADYN_ARGS from /etc/default/inadyn
 >  - A reload command that sends SIGHUP, since that works and is both
 >    quicker and a less resource intensive operation

 > Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
 > ---
 >  package/inadyn/S70inadyn | 100 +++++++++++++++++++++++++--------------
 >  1 file changed, 65 insertions(+), 35 deletions(-)
 >  mode change 100644 => 100755 package/inadyn/S70inadyn

 > diff --git a/package/inadyn/S70inadyn b/package/inadyn/S70inadyn
 > old mode 100644
 > new mode 100755
 > index ca7b414678..d44acacec3
 > --- a/package/inadyn/S70inadyn
 > +++ b/package/inadyn/S70inadyn
 > @@ -1,44 +1,74 @@
 >  #!/bin/sh
 > +# Customizations are sourced from /etc/default/inadyn.  For example,
 > +# override INADYN_ARGS to adjust log level, add a startup delay, etc.
 >  #
 > -# Start & stop the inadyn client
 > -#
 > +# NOTE: to start, add a line ENABLED="yes" to /etc/default/inadyn
 > +
 > +DAEMON="inadyn"
 > +PIDFILE="/var/run/$DAEMON.pid"
 > +
 > +INADYN_ARGS=""
 
 > -CONFIG=/etc/inadyn.conf
 > +# shellcheck source=/dev/null
 > +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
 
 > -# check if CONFIG exists, print message & exit if it doesn't
 > -[ ! -f $CONFIG ] && ( echo "The config file "$CONFIG" is missing...exiting now." && exit 2 )
 > +start()
 > +{

Our other init scripts have the { on the same line as the function, so
changed that and committed, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-09  8:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-05 10:29 [Buildroot] [PATCH next 0/3] package/inadyn: start script rework + repost Joachim Wiberg
2021-12-05 10:29 ` [Buildroot] [PATCH next 1/3] package/inadyn: replace local systemd unit file with upstream Joachim Wiberg
2021-12-05 10:32   ` Joachim Wiberg
2021-12-05 10:29 ` [Buildroot] [PATCH next 2/3] package/inadyn: refactor start script Joachim Wiberg
2022-01-09  8:57   ` Peter Korsgaard
2021-12-05 10:29 ` [Buildroot] [PATCH next 3/3] package/inadyn: update inadyn.conf example Joachim Wiberg
2021-12-11 20:42   ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).