]> git.pld-linux.org Git - packages/ddclient.git/commitdiff
add support for try-restart in init script and use it in %post
authorJan Palus <atler@pld-linux.org>
Sun, 10 Dec 2023 20:59:37 +0000 (21:59 +0100)
committerJan Palus <atler@pld-linux.org>
Sun, 10 Dec 2023 20:59:37 +0000 (21:59 +0100)
ddclient.init
ddclient.spec

index ca6795e2bda47cf1d314b903372790fc52d92070..5c08bf914994fe768d90b1e81756de6a3b57c1e9 100755 (executable)
@@ -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
 
index 127ede28c3aed2d1cc39185432be235ba1413809..b1b50b40b3ad5730d11097521abdb5e88cd2c7e9 100644 (file)
@@ -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
This page took 0.118861 seconds and 4 git commands to generate.