<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>32578</bug_id>
          
          <creation_ts>2016-10-05 19:41:02 +0300</creation_ts>
          <short_desc>FR: supply a default simple implementation if condrestart is missing in init-script</short_desc>
          <delta_ts>2016-10-05 19:41:02 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>service</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>32577</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Ivan Zakharyaschev">imz</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>glebfm</cc>
    
    <cc>ldv</cc>
    
    <cc>legion</cc>
    
    <cc>placeholder</cc>
    
    <cc>stanv</cc>
    
    <cc>viy</cc>
    
    <cc>vt</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>159043</commentid>
    <comment_count>0</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2016-10-05 19:41:02 +0300</bug_when>
    <thetext>service-0.5.26-alt1

Something like this could be used to fallback to a default implementation:

service &quot;$1&quot; condrestart || if service &quot;$1&quot; status &gt;/dev/null; then service &quot;$1&quot; restart; fi

This would be useful for init-scripts written for Debian which are able to function thanks to /lib/lsb/init-functions (from lsb-init), but usually lack a condrestart command.

This would make lsb-init more useful and powerful for the cases when a Debian init-script is borrowed into ALT Sisyphus.

Potential cases:

# apt-cache whatdepends lsb-init
lsb-init-4.0-alt5
  starboard-preinstall-1.0-alt4
    Depends: lsb-init
  owamp-server-3.5.0-alt1
    Depends: lsb-init &gt;= 4.0-alt4
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  lsb-core-4.0-alt5
    Depends: lsb-init = 4.0
  tomcat-1:8.0.32-alt4_4jpp8
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  laptop-mode-tools-1.70-alt1
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  xtreemfs-server-1.5.1-alt1
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  xen-runtime-4.7.0-alt1
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  turbovnc-server-1.2.1-alt3
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  thermald-1.5.3-alt2
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  drbd83-tools-8.3.8-alt3
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  drbd-tools-8.3.16-alt1
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5
  ceph-0.94.9-alt2
    Depends: &lt;/lib/lsb/init-functions&gt;
      lsb-init-4.0-alt5


+++ This bug was initially created as a clone of Bug #32577 +++

laptop-mode-tools-1.70-alt1

ALT&apos;s /usr/sbin/post_service invokes the init-script&apos;s condrestart command:

                service &quot;$1&quot; condrestart

but the Debian-style /etc/init.d/laptop-mode doesn&apos;t have it (similarly to all other Debian-style init-scripts).

I&apos;ve patched some other Debian-style init-scripts for this (&quot;condrestart&quot;) in a simple way:

http://git.altlinux.org/gears/o/owamp.git?p=owamp.git;a=commitdiff;h=ae7ac80b0eb4dd255d8918791a5b06099d69305e

diff --git a/debian/owamp-server.init b/debian/owamp-server.init
index 1a7998b..24951c3 100755
--- a/debian/owamp-server.init
+++ b/debian/owamp-server.init
@@ -122,8 +122,18 @@ case &quot;$1&quot; in
 		;;
 	esac
 	;;
+  condrestart|condreload)
+        if &quot;$0&quot; status &gt;/dev/null; then
+            exec &quot;$0&quot; restart
+        fi
+        ;;
+  condstop)
+        if &quot;$0&quot; status &gt;/dev/null; then
+            exec &quot;$0&quot; stop
+        fi
+        ;;
   *)
-	echo &quot;Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}&quot; &gt;&amp;2
+	echo &quot;Usage: $SCRIPTNAME {start|stop|status|restart|force-reload|condrestart|condreload|condstop}&quot; &gt;&amp;2
 	exit 3
 	;;
 esac

A very similar patch:

http://git.altlinux.org/gears/t/thermald.git?p=thermald.git;a=commitdiff;h=5e6857d421e2bd21323bb831ec500308cb049130

Perhaps, this trick can be moved into package service (instead of patching each individual package). (I&apos;m going to submit such a FR.)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>