inadyn: fix init script and default config file
PATCH v2 1/1 inadyn: fix init script and default config file
This commit does a number of fixes to the inadyn package to make it work properly "out of the box":
* inadyn is installed in /usr/sbin, not /usr/bin, so we fix the path in the init script
* Use "printf" for the Starting and Stopping messages, so that the OK / FAIL stay on the same line.
* Pass the -q option to the start sequence, since it's passed in the stop sequence.
* Fix the configuration file to use an existing dyndns_system and avoid a failure at startup.
* Use a variable called ENABLED in /etc/default/inadyn to decide whether to start the service or not. By default, it is not started, as suggested by Gustavo, and an explicit ENABLED="yes" is needed.
* Store the PID file in /var/run/inadyn.pid, like we do for all other daemons.
---
Changes since v1:
* Store PID file in /var/run/inadyn.pid instead of /var/run/inadyn/inadyn.pid.
* Use the background functionality of start-stop-daemon instead of the one of inadyn itself (suggested by Gustavo)
* Specify the path to the inadyn executable even when stopping, so that start-stop-daemon can check we're not killing the wrong program (suggested by Arnout).
* Do not start inadyn by default, and use an ENABLED variable in /etc/default/inadyn to decide if it should be started (suggested by Gustavo).
--- package/inadyn/S70inadyn | 24 ++++++++++++++++-------- package/inadyn/inadyn.conf | 4 ++-- 2 files changed, 18 insertions(+), 10 deletions(-)
package/inadyn/S70inadyn +16 -8
@@ -4,25 +4,33 @@ # CONFIG=/etc/inadyn.conf -VR_INADYN=/var/run/inadyn # check if CONFIG exists, print message & exit if it doesn't [ ! -f $CONFIG ] && ( echo "The config file "$CONFIG" is missing...exiting now." && exit 2 ) -# check if VR_INADYN exists, create it if not -[ ! -d $VR_INADYN ] && mkdir -p $VR_INADYN +# 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 case "$1" in start) - echo "Starting inadyn: " - start-stop-daemon -S -x /usr/bin/inadyn + 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) - echo "Stopping inadyn: " - start-stop-daemon -q -K -x /usr/bin/inadyn + 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/inadyn.pid + rm -f /var/run/inadyn.pid ;; restart) "$0" stop
package/inadyn/inadyn.conf +2 -2
@@ -1,11 +1,11 @@ # Basic configuration file for inadyn # # /etc/inadyn.conf -background +pidfile /var/run/inadyn.pid update_period_sec 600 # Check for a new IP every 600 seconds username test # replace 'test' with your username password test # replace 'test' with your password -dyndns_system dyndns at dyndns.org # replace w/ your provider +dyndns_system default at dyndns.org # replace w/ your provider # uncomment the alias statement below to test it on your system alias test.homeip.net
Signature · 1 line
2.6.2
PATCH v2 1/1 inadyn: fix init script and default config file
Thomas, All,
On 2015-10-17 16:05 +0200, Thomas Petazzoni spake thusly:
Quoted 19 lines
This commit does a number of fixes to the inadyn package to make it work properly "out of the box":
* inadyn is installed in
/usr/sbin, not/usr/bin, so we fix the path in the init script* Use "printf" for the Starting and Stopping messages, so that the OK / FAIL stay on the same line.
* Pass the -q option to the start sequence, since it's passed in the stop sequence.
* Fix the configuration file to use an existing
dyndns_systemand avoid a failure at startup.* Use a variable called ENABLED in
/etc/default/inadynto decide whether to start the service or not. By default, it is not started, as suggested by Gustavo, and an explicit ENABLED="yes" is needed.
Quoted 7 lines
* Store the PID file in
/var/run/inadyn.pid, like we do for all other daemons.Cc Alex Suykov <[email protected]>Signed-off-by Thomas Petazzoni <[email protected]>Signed-off-by Thomas Petazzoni <[email protected]>
Twice your SoB line.
Yet, still a minor thingy...
[--SNIP--]
Quoted 8 lines
package/inadyn/inadyn.conf +0
-0@@ -1,11 +1,11 @@ # Basic configuration file for inadyn # # /etc/inadyn.conf
package/inadyn/inadyn.conf line 11
Quoted 10 lines
package/inadyn/inadyn.conf +2
-2-background +pidfile /var/run/inadyn.pid update_period_sec 600 # Check for a new IP every 600 seconds username test # replace 'test' with your username password test # replace 'test' with your password -dyndns_system dyndns at dyndns.org # replace w/ your provider +dyndns_system default at dyndns.org # replace w/ your provider # uncomment the alias statement below to test it on your system alias test.homeip.net
The alias line is not commented, which makes the comment above a bit confusing...
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v2 1/1 inadyn: fix init script and default config file
Dear Yann E. MORIN,
Quoted 5 lines · Yann E. MORIN
Quoted 2 lines
# uncomment the alias statement below to test it on your system alias test.homeip.net
The alias line is not commented, which makes the comment above a bit confusing...
Indeed, thanks. I've dropped it when applying.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 1/1 inadyn: fix init script and default config file
In reply to Thomas PetazzoniHello,
Quoted 19 lines · Thomas Petazzoni
This commit does a number of fixes to the inadyn package to make it work properly "out of the box":
* inadyn is installed in
/usr/sbin, not/usr/bin, so we fix the path in the init script* Use "printf" for the Starting and Stopping messages, so that the OK / FAIL stay on the same line.
* Pass the -q option to the start sequence, since it's passed in the stop sequence.
* Fix the configuration file to use an existing
dyndns_systemand avoid a failure at startup.* Use a variable called ENABLED in
/etc/default/inadynto decide whether to start the service or not. By default, it is not started, as suggested by Gustavo, and an explicit ENABLED="yes" is needed.
Quoted 8 lines
* Store the PID file in
/var/run/inadyn.pid, like we do for all other daemons.Cc Alex Suykov <[email protected]>Signed-off-by Thomas Petazzoni <[email protected]>Signed-off-by Thomas Petazzoni <[email protected]>---
Applied after dropping the silly comment in inadyn.conf, as suggested by Yann.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 1/1 inadyn: fix init script and default config file
In reply to Thomas PetazzoniQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Hi,
Quoted 7 lines
Changes since v1:
* Store PID file in
/var/run/inadyn.pidinstead of/var/run/inadyn/inadyn.pid.* Use the background functionality of start-stop-daemon instead of the one of inadyn itself (suggested by Gustavo)
Didn't Gustavoz suggest the opposite? E.G. to use the inadyn option to force the background mode on, independently of what the config file states?
I also see that you are not passing the --syslog option to inadyn, so log messages go to stdout (which start-stop-daemon redirects to /dev/null) :/
package/inadyn/inadyn.conf line 4
Quoted 7 lines
+++
b/package/inadyn/inadyn.confpackage/inadyn/inadyn.conf +1
-1@@ -1,11 +1,11 @@ # Basic configuration file for inadyn # # /etc/inadyn.conf -background +pidfile /var/run/inadyn.pid
We should instead use the --pidfile inadyn command line option to force this as we _REQUIRE_ this for start-stop-daemon.
Signature · 1 line
Bye, Peter Korsgaard