commit 386ae21a213158ad01db61e8c4dd3161fc898eea
Author: Jan Palus <[email protected]>
Date:   Sun Dec 10 21:59:37 2023 +0100

    add support for try-restart in init script and use it in %post

 ddclient.init | 15 ++++++++++++++-
 ddclient.spec |  4 +++-
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/ddclient.spec b/ddclient.spec
index 127ede2..b1b50b4 100644
--- a/ddclient.spec
+++ b/ddclient.spec
@@ -103,7 +103,9 @@ rm -rf $RPM_BUILD_ROOT
 
 %post
 /sbin/chkconfig --add %{name}
-%service %{name} restart "%{name} daemon"
+if [ "$1" = "2" ]; then
+       %service %{name} try-restart "%{name} daemon"
+fi
 
 %preun
 if [ "$1" = "0" ]; then
diff --git a/ddclient.init b/ddclient.init
index ca6795e..5c08bf9 100755
--- a/ddclient.init
+++ b/ddclient.init
@@ -53,6 +53,16 @@ stop() {
        rm -f $pidfile /var/lock/subsys/ddclient >/dev/null 2>&1
 }
 
+condrestart() {
+       if [ ! -f /var/lock/subsys/ddclient ]; then
+               msg_not_running "Dynamic DNS Client"
+               return 0
+       fi
+
+       stop
+       start
+}
+
 reload() {
        if [ ! -f /var/lock/subsys/ddclient ]; then
                msg_not_running "Dynamic DNS Client"
@@ -78,6 +88,9 @@ case "$1" in
        stop
        start
        ;;
+  try-restart)
+       condrestart
+       ;;
   reload|force-reload)
        reload
        ;;
@@ -86,7 +99,7 @@ case "$1" in
        exit $?
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+       msg_usage "$0 
{start|stop|restart|try-restart|reload|force-reload|status}"
        exit 3
 esac
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/ddclient.git/commitdiff/86fae1c3767f78475470c8310fa3e29bb50faa2b

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to