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

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

    <bug>
          <bug_id>31952</bug_id>
          
          <creation_ts>2016-04-07 20:35:04 +0300</creation_ts>
          <short_desc>Обновить functions-compat до современного состояния functions в Fedora</short_desc>
          <delta_ts>2017-07-27 17:06:34 +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>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>33431</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Danil Mikhaylov">danil</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>aen</cc>
    
    <cc>cas</cc>
    
    <cc>glebfm</cc>
    
    <cc>imz</cc>
    
    <cc>lav</cc>
    
    <cc>ldv</cc>
    
    <cc>legion</cc>
    
    <cc>mike</cc>
    
    <cc>placeholder</cc>
    
    <cc>snejok</cc>
    
    <cc>vt</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>155994</commentid>
    <comment_count>0</comment_count>
    <who name="Danil Mikhaylov">danil</who>
    <bug_when>2016-04-07 20:35:04 +0300</bug_when>
    <thetext>Столкнулся с такой проблемой: при использовании пакета jenkins для fedora на altlinux:
http://pkg.jenkins-ci.org/redhat/jenkins-1.651-1.1.noarch.rpm

Идущий в пакете init скрипт запускает daemon из functions-compat c параметром --pidfile &quot;$JENKINS_PID_FILE&quot; который не поддерживается нашим daemon. Запуск:

. functions; daemon --user &quot;$JENKINS_USER&quot; --pidfile &quot;$JENKINS_PID_FILE&quot; $JAVA_CMD $PARAMS &gt; /dev/null

Приводит к:
Usage: daemon [options]... {program}...

Возможно стоит обновить functions-compat до 
https://git.fedorahosted.org/cgit/initscripts.git/tree/rc.d/init.d/functions</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155998</commentid>
    <comment_count>1</comment_count>
    <who name="Vitaly Lipatov">lav</who>
    <bug_when>2016-04-08 02:35:38 +0300</bug_when>
    <thetext>Совместимость по init-скриптам и пакетам с Fedora/RHEL — хорошая и достижимая цель.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163678</commentid>
    <comment_count>2</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-05-15 14:52:45 +0300</bug_when>
    <thetext>*** Bug 33431 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163681</commentid>
    <comment_count>3</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-05-15 17:28:52 +0300</bug_when>
    <thetext>(In reply to comment #0)

&gt; Возможно стоит обновить functions-compat до 
&gt; https://git.fedorahosted.org/cgit/initscripts.git/tree/rc.d/init.d/functions

fedorahosted is retired. According to http://pkgs.fedoraproject.org/cgit/rpms/initscripts.git/tree/initscripts.spec , the new URL is: https://github.com/fedora-sysv/initscripts

This file is at: https://github.com/fedora-sysv/initscripts/blob/master/rc.d/init.d/functions</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163682</commentid>
    <comment_count>4</comment_count>
    <who name="Lenar Shakirov">snejok</who>
    <bug_when>2017-05-15 17:35:53 +0300</bug_when>
    <thetext>Тоже столкнулся с несовместимостью init functions при установке и запуске Grafana
ping!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164632</commentid>
    <comment_count>5</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-07-10 13:59:54 +0300</bug_when>
    <thetext>Я пока подготовил серию патчей, берущих текущие functions из Fedora (тег 9.72) и превращающие их в functions-compat для ALT. Всё смотрел историю в ALT, пытался сколь-нибудь существенные изменения для ALT учесть. (Но цель: поменьше патчить, чтобы проще и понятнее rebase-ить на новые версии из Fedora.)

Недоделки: где я возвращаю initlog, там на самом деле initlog не умеет выполнять shell-команды, поэтому собираюсь переписать так, чтобы передавать команду в переменной окружения и вызывать что-нибудь такое: /bin/sh -c $daemon_cmd_for_service.

А также внести в эту команду limited из ALT.

В спеке можно будет, имея оригинальную копию из Fedora, накладывать серию патчей. (Подшивать историю git, думаю, будет несколько громоздко, неудобно. А для работы последующей можно локально у себя делать git commit-ы.)

Ветка 9.72-ALT-funcs-compat в git.altlinux.org/people/imz/packages/service.git

commit c8d696ed8a5dff273cf54db811fcb4a74bb3a926
Author: Dmitry V. Levin &lt;ldv@altlinux.org&gt;
Date:   Wed Jan 21 12:54:08 2004 +0000

    hide pidof
    
    (cherry picked from commit 53a0c0ed901e307607a0fcfc28aa6fd248873040)

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index e8c2d07..6f6e134 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -130,8 +130,11 @@ __pids_var_run() {
 
 # Output PIDs of matching processes, found using pidof
 __pids_pidof() {
-    pidof -c -m -o $$ -o $PPID -o %PPID -x &quot;$1&quot; || \
-        pidof -c -m -o $$ -o $PPID -o %PPID -x &quot;${1##*/}&quot;
+	local PIDOF=/bin/pidof
+	[ -x &quot;$PIDOF&quot; ] &amp;&amp; {
+		&quot;$PIDOF&quot; -c -m -o $$ -o $PPID -o %PPID -x &quot;$1&quot; ||
+        &quot;$PIDOF&quot; -c -m -o $$ -o $PPID -o %PPID -x &quot;${1##*/}&quot;
+	}
 }
 
 

commit ab6bf17663b0eb1af5c11f8ef7c58dd71495e1fd
Author: Dmitry V. Levin &lt;ldv@altlinux.org&gt;
Date:   Mon May 12 10:48:00 2003 +0000

    functions-compat: use msg_usage everywhere

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index e7cd4ac..e8c2d07 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -178,7 +178,7 @@ daemon() {
             shift
             ;;
         *)
-            echo $&quot;$0: Usage: daemon [+/-nicelevel] {program}&quot; &quot;[arg1]...&quot;
+            msg_usage &quot;daemon [+/-nicelevel] [options]... {program} [arg1]...&quot;
             return 1
             ;;
       esac
@@ -231,7 +231,7 @@ killproc() {
     RC=0; delay=3; try=0
     # Test syntax.
     if [ &quot;$#&quot; -eq 0 ]; then
-        echo $&quot;Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]&quot;
+        msg_usage &quot;killproc [-p pidfile] [ -d delay] {program} [-signal]&quot;
         return 1
     fi
     if [ &quot;$1&quot; = &quot;-p&quot; ]; then
@@ -240,8 +240,8 @@ killproc() {
     fi
     if [ &quot;$1&quot; = &quot;-b&quot; ]; then
         if [ -z $pid_file ]; then
-            echo $&quot;-b option can be used only with -p&quot;
-            echo $&quot;Usage: killproc -p pidfile -b binary program&quot;
+            echo $&quot;-b option can be used only with -p&quot; &gt;&amp;2
+            msg_usage &quot;killproc -p pidfile -b binary program&quot;
             return 1
         fi
         binary=$2
@@ -250,7 +250,7 @@ killproc() {
     if [ &quot;$1&quot; = &quot;-d&quot; ]; then
         delay=$(echo $2 | awk -v RS=&apos; &apos; -v IGNORECASE=1 &apos;{if($1!~/^[0-9.]+[smhd]?$/) exit 1;d=$1~/s$|^[0-9.]*$/?1:$1~/m$/?60:$1~/h$/?60*60:$1~/d$/?24*60*60:-1;if(d==-1) exit 1;delay+=d*$1} END {printf(&quot;%d&quot;,delay+0.5)}&apos;)
         if [ &quot;$?&quot; -eq 1 ]; then
-            echo $&quot;Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]&quot;
+            msg_usage &quot;killproc [-p pidfile] [ -d delay] {program} [-signal]&quot;
             return 1
         fi
         shift 2
@@ -313,7 +313,7 @@ pidfileofproc() {
 
     # Test syntax.
     if [ &quot;$#&quot; != 1 ] ; then
-        echo $&quot;Usage: pidfileofproc {program}&quot;
+        msg_usage &quot;pidfileofproc {program}&quot;
         return 1
     fi
 
@@ -328,7 +328,7 @@ pidofproc() {
 
     # Test syntax.
     if [ &quot;$#&quot; = 0 ]; then
-        echo $&quot;Usage: pidofproc [-p pidfile] {program}&quot;
+        msg_usage &quot;pidofproc [-p pidfile] {program}&quot;
         return 1
     fi
     if [ &quot;$1&quot; = &quot;-p&quot; ]; then

commit 45bb7e5ff65681485672b716473a31ad356c8655
Author: Ivan Zakharyaschev &lt;imz@altlinux.org&gt;
Date:   Fri Jul 7 16:47:23 2017 +0300

    restored (but TODO: also use ALT&apos;s limited): initlog $INITLOG_ARGS -n &quot;$base&quot;
    
    initlog was deprecated and dropped in RH/Fedora:
    
    https://bugzilla.redhat.com/show_bug.cgi?id=223446
    -- Boot time messages from init scripts not being logged to /var/log/boot.log
    
    https://access.redhat.com/solutions/9834
    -- How to enable boot-time logging (/var/log/boot.log) in Red Hat Enterprise Linux 5?

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index 11da9ff..e7cd4ac 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -216,9 +216,9 @@ daemon() {
 
     # And start it up.
     if [ -z &quot;$user&quot; ]; then
-       $cgroup $nice /bin/bash -c &quot;$corelimit &gt;/dev/null 2&gt;&amp;1 ; $*&quot;
+       $cgroup $nice initlog $INITLOG_ARGS -n &quot;$base&quot; -c &quot;$corelimit &gt;/dev/null 2&gt;&amp;1 ; $*&quot;
     else
-       $cgroup $nice runuser -s /bin/bash $user -c &quot;$corelimit &gt;/dev/null 2&gt;&amp;1 ; $*&quot;
+       $cgroup $nice initlog $INITLOG_ARGS -n &quot;$base&quot; -c &quot;su -s /bin/bash - $user -c \&quot;$corelimit &gt;/dev/null 2&gt;&amp;1 ; $*\&quot;&quot;
     fi
 
     [ &quot;$?&quot; -eq 0 ] &amp;&amp; success $&quot;$base startup&quot; || failure $&quot;$base startup&quot;

commit 28a9a40578033c6288966fb8c81ba798607aa11c
Author: Ivan Zakharyaschev &lt;imz@altlinux.org&gt;
Date:   Fri Jul 7 16:13:59 2017 +0300

    more reliable syntax: kill KILLLEVEL -- pids

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index f69d1c7..11da9ff 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -67,7 +67,7 @@ __kill_pids_term_kill() {
 
     [ -z &quot;$kill_list&quot; ] &amp;&amp; return 0
 
-    kill -TERM $kill_list &gt;/dev/null 2&gt;&amp;1
+    kill -TERM -- $kill_list &gt;/dev/null 2&gt;&amp;1
     sleep 0.1
 
     kill_list=$(__kill_pids_term_kill_checkpids $base_stime $kill_list)
@@ -79,7 +79,7 @@ __kill_pids_term_kill() {
             let try+=1
         done
         if [ -n &quot;$kill_list&quot; ] ; then
-            kill -KILL $kill_list &gt;/dev/null 2&gt;&amp;1
+            kill -KILL -- $kill_list &gt;/dev/null 2&gt;&amp;1
             sleep 0.1
             kill_list=$(__kill_pids_term_kill_checkpids $base_stime $kill_list)
         fi
@@ -284,7 +284,7 @@ killproc() {
         # use specified level only
         else
             if checkpid $pid; then
-                kill $killlevel $pid &gt;/dev/null 2&gt;&amp;1
+                kill $killlevel -- $pid &gt;/dev/null 2&gt;&amp;1
                 RC=$?
                 [ &quot;$RC&quot; -eq 0 ] &amp;&amp; success $&quot;$base $killlevel&quot; || failure $&quot;$base $killlevel&quot;
             elif [ -n &quot;${LSB:-}&quot; ]; then

commit d6949da6a0777a07457944e824a0018e8652b713
Author: Ivan Zakharyaschev &lt;imz@altlinux.org&gt;
Date:   Fri Jul 7 16:09:03 2017 +0300

    pidfileofproc(), pidofproc(): more restrictive syntax testing

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index e3f1024..f69d1c7 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -312,7 +312,7 @@ pidfileofproc() {
     local pid
 
     # Test syntax.
-    if [ &quot;$#&quot; = 0 ] ; then
+    if [ &quot;$#&quot; != 1 ] ; then
         echo $&quot;Usage: pidfileofproc {program}&quot;
         return 1
     fi

commit b41ef81dfe46a1bb63bb0c7e2b438ccd390c886a
Author: Ivan Zakharyaschev &lt;imz@altlinux.org&gt;
Date:   Fri Jul 7 14:45:29 2017 +0300

    unused var bg removed from daemon() (after the bg option was removed)

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index 80867d2..e3f1024 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -139,7 +139,7 @@ __pids_pidof() {
 daemon() {
     # Test syntax.
     local gotbase= force= corelimit
-    local pid base= user= nice= bg= pid_file=
+    local pid base= user= nice= pid_file=
     local cgroup=
     while [ &quot;$1&quot; != &quot;${1##[-+]}&quot; ]; do
         case $1 in

commit deb5173d1bf4b4498fd53ac09546a92668ee7f9f
Author: Ivan Zakharyaschev &lt;imz@altlinux.org&gt;
Date:   Fri Jul 7 14:43:28 2017 +0300

    unreachable case removed from option parsing in daemon()

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index 4e71304..80867d2 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -143,10 +143,6 @@ daemon() {
     local cgroup=
     while [ &quot;$1&quot; != &quot;${1##[-+]}&quot; ]; do
         case $1 in
-        &apos;&apos;)
-            echo $&quot;$0: Usage: daemon [+/-nicelevel] {program}&quot; &quot;[arg1]...&quot;
-            return 1
-            ;;
         --check)
             base=$2
             gotbase=&quot;yes&quot;

commit 0f7e77fd4f4c363c0f6146593b5be0b36ee38c2c
Author: Ivan Zakharyaschev &lt;imz@altlinux.org&gt;
Date:   Fri Jul 7 14:42:41 2017 +0300

    unused var nicelevel removed from daemon()

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index ae640ec..4e71304 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -138,10 +138,9 @@ __pids_pidof() {
 # A function to start a program.
 daemon() {
     # Test syntax.
-    local gotbase= force= nicelevel corelimit
+    local gotbase= force= corelimit
     local pid base= user= nice= bg= pid_file=
     local cgroup=
-    nicelevel=0
     while [ &quot;$1&quot; != &quot;${1##[-+]}&quot; ]; do
         case $1 in
         &apos;&apos;)

commit 7727ce118f1aed7136a547054d022dbc54e28141
Author: Ivan Zakharyaschev &lt;imz@altlinux.org&gt;
Date:   Fri Jul 7 14:03:31 2017 +0300

    removed things which are already in the main ALT&apos;s functions
    
    Compare with what we had in ALT (in older releases) with:
    
    git --no-pager diff -w HEAD:service/rc.d/init.d/functions-compat ac9db9953687b9589c26b6661c2d1e95b9b64759:rc.d/init.d/functions-compat

diff --git a/service/rc.d/init.d/functions-compat b/service/rc.d/init.d/functions-compat
index 0f627f1..ae640ec 100644
--- a/service/rc.d/init.d/functions-compat
+++ b/service/rc.d/init.d/functions-compat
@@ -1,104 +1,18 @@
+#!/bin/sh
 # -*-Shell-script-*-
 #
-# functions This file contains functions to be used by most or all
-#       shell scripts in the /etc/init.d directory.
+# Functions defined in this file are still used by many rc scripts;
+# they offer some RedHat/Mandrake compatibility for 3rd party rc scripts.
 #
-
-TEXTDOMAIN=initscripts
+# Version: 9.72 from https://github.com/fedora-sysv/initscripts
+# adapted for use in ALT (by means of a few patches).
+#
+# Author:	Miquel van Smoorenburg, &lt;miquels@drinkel.nl.mugnet.org&gt;
+# Hacked by:    Greg Galloway and Marc Ewing
 
 # Make sure umask is sane
 umask 022
 
-# Set up a default search path.
-PATH=&quot;/sbin:/usr/sbin:/bin:/usr/bin&quot;
-export PATH
-
-if [ $PPID -ne 1 -a -z &quot;$SYSTEMCTL_SKIP_REDIRECT&quot; ] &amp;&amp; \
-        [ -d /run/systemd/system ] ; then
-    case &quot;$0&quot; in
-    /etc/init.d/*|/etc/rc.d/init.d/*)
-        _use_systemctl=1
-        ;;
-    esac
-fi
-
-systemctl_redirect () {
-    local s
-    local prog=${1##*/}
-    local command=$2
-    local options=&quot;&quot;
-
-    case &quot;$command&quot; in
-    start)
-        s=$&quot;Starting $prog (via systemctl): &quot;
-        ;;
-    stop)
-        s=$&quot;Stopping $prog (via systemctl): &quot;
-        ;;
-    reload|try-reload)
-        s=$&quot;Reloading $prog configuration (via systemctl): &quot;
-        ;;
-    restart|try-restart|condrestart)
-        s=$&quot;Restarting $prog (via systemctl): &quot;
-        ;;
-    esac
-
-    if [ -n &quot;$SYSTEMCTL_IGNORE_DEPENDENCIES&quot; ] ; then
-        options=&quot;--ignore-dependencies&quot;
-    fi
-
-    if ! systemctl show &quot;$prog.service&quot; &gt; /dev/null 2&gt;&amp;1 || \
-            systemctl show -p LoadState &quot;$prog.service&quot; | grep -q &apos;not-found&apos; ; then
-        action $&quot;Reloading systemd: &quot; /bin/systemctl daemon-reload
-    fi
-
-    action &quot;$s&quot; /bin/systemctl $options $command &quot;$prog.service&quot;
-}
-
-# Get a sane screen width
-[ -z &quot;${COLUMNS:-}&quot; ] &amp;&amp; COLUMNS=80
-
-if [ -z &quot;${CONSOLETYPE:-}&quot; ]; then
-    if [ -c &quot;/dev/stderr&quot; -a -r &quot;/dev/stderr&quot; ]; then
-        CONSOLETYPE=&quot;$(/sbin/consoletype &lt; /dev/stderr 2&gt;/dev/null)&quot;
-    else
-        CONSOLETYPE=&quot;serial&quot;
-    fi
-fi
-
-if [ -z &quot;${NOLOCALE:-}&quot; ] &amp;&amp; [ -z &quot;${LANGSH_SOURCED:-}&quot; ] &amp;&amp; \
-        [ -f /etc/sysconfig/i18n -o -f /etc/locale.conf ] ; then
-    . /etc/profile.d/lang.sh 2&gt;/dev/null
-    # avoid propagating LANGSH_SOURCED any further
-    unset LANGSH_SOURCED
-fi
-
-# Read in our configuration
-if [ -z &quot;${BOOTUP:-}&quot; ]; then
-    if [ -f /etc/sysconfig/init ]; then
-        . /etc/sysconfig/init
-    else
-        # This all seem confusing? Look in /etc/sysconfig/init,
-        # or in /usr/share/doc/initscripts-*/sysconfig.txt
-        BOOTUP=color
-        RES_COL=60
-        MOVE_TO_COL=&quot;echo -en \\033[${RES_COL}G&quot;
-        SETCOLOR_SUCCESS=&quot;echo -en \\033[1;32m&quot;
-        SETCOLOR_FAILURE=&quot;echo -en \\033[1;31m&quot;
-        SETCOLOR_WARNING=&quot;echo -en \\033[1;33m&quot;
-        SETCOLOR_NORMAL=&quot;echo -en \\033[0;39m&quot;
-        LOGLEVEL=1
-    fi
-    if [ &quot;$CONSOLETYPE&quot; = &quot;serial&quot; ]; then
-        BOOTUP=serial
-        MOVE_TO_COL=
-        SETCOLOR_SUCCESS=
-        SETCOLOR_FAILURE=
-        SETCOLOR_WARNING=
-        SETCOLOR_NORMAL=
-    fi
-fi
-
 # Check if any of $pid (could be plural) are running
 checkpid() {
     local i
@@ -439,253 +353,3 @@ pidofproc() {
     [ -n &quot;$pid_file&quot; ] &amp;&amp; return $RC
     __pids_pidof &quot;$1&quot; || return $RC
 }
-
-status() {
-    local base pid lock_file= pid_file= binary=
-
-    # Test syntax.
-    if [ &quot;$#&quot; = 0 ] ; then
-        echo $&quot;Usage: status [-p pidfile] {program}&quot;
-        return 1
-    fi
-    if [ &quot;$1&quot; = &quot;-p&quot; ]; then
-        pid_file=$2
-        shift 2
-    fi
-    if [ &quot;$1&quot; = &quot;-l&quot; ]; then
-        lock_file=$2
-        shift 2
-    fi
-    if [ &quot;$1&quot; = &quot;-b&quot; ]; then
-        if [ -z $pid_file ]; then
-            echo $&quot;-b option can be used only with -p&quot;
-            echo $&quot;Usage: status -p pidfile -b binary program&quot;
-            return 1
-        fi
-        binary=$2
-        shift 2
-    fi
-    base=${1##*/}
-
-    if [ &quot;$_use_systemctl&quot; = &quot;1&quot; ]; then
-        systemctl status ${0##*/}.service
-        ret=$?
-        # LSB daemons that dies abnormally in systemd looks alive in systemd&apos;s eyes due to RemainAfterExit=yes
-        # lets adjust the reality a little bit
-        if systemctl show -p ActiveState ${0##*/}.service | grep -q &apos;=active$&apos; &amp;&amp; \
-        systemctl show -p SubState ${0##*/}.service | grep -q &apos;=exited$&apos; ; then
-            ret=3
-        fi
-        return $ret
-    fi
-
-    # First try &quot;pidof&quot;
-    __pids_var_run &quot;$1&quot; &quot;$pid_file&quot; &quot;$binary&quot;
-    RC=$?
-    if [ -z &quot;$pid_file&quot; -a -z &quot;$pid&quot; ]; then
-        pid=&quot;$(__pids_pidof &quot;$1&quot;)&quot;
-    fi
-    if [ -n &quot;$pid&quot; ]; then
-        echo $&quot;${base} (pid $pid) is running...&quot;
-        return 0
-    fi
-
-    case &quot;$RC&quot; in
-    0)
-        echo $&quot;${base} (pid $pid) is running...&quot;
-        return 0
-        ;;
-    1)
-        echo $&quot;${base} dead but pid file exists&quot;
-        return 1
-        ;;
-    4)
-        echo $&quot;${base} status unknown due to insufficient privileges.&quot;
-        return 4
-        ;;
-    esac
-    if [ -z &quot;${lock_file}&quot; ]; then
-        lock_file=${base}
-    fi
-    # See if /var/lock/subsys/${lock_file} exists
-    if [ -f /var/lock/subsys/${lock_file} ]; then
-        echo $&quot;${base} dead but subsys locked&quot;
-        return 2
-    fi
-    echo $&quot;${base} is stopped&quot;
-    return 3
-}
-
-echo_success() {
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $MOVE_TO_COL
-    echo -n &quot;[&quot;
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $SETCOLOR_SUCCESS
-    echo -n $&quot;  OK  &quot;
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $SETCOLOR_NORMAL
-    echo -n &quot;]&quot;
-    echo -ne &quot;\r&quot;
-    return 0
-}
-
-echo_failure() {
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $MOVE_TO_COL
-    echo -n &quot;[&quot;
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $SETCOLOR_FAILURE
-    echo -n $&quot;FAILED&quot;
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $SETCOLOR_NORMAL
-    echo -n &quot;]&quot;
-    echo -ne &quot;\r&quot;
-    return 1
-}
-
-echo_passed() {
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $MOVE_TO_COL
-    echo -n &quot;[&quot;
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $SETCOLOR_WARNING
-    echo -n $&quot;PASSED&quot;
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $SETCOLOR_NORMAL
-    echo -n &quot;]&quot;
-    echo -ne &quot;\r&quot;
-    return 1
-}
-
-echo_warning() {
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $MOVE_TO_COL
-    echo -n &quot;[&quot;
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $SETCOLOR_WARNING
-    echo -n $&quot;WARNING&quot;
-    [ &quot;$BOOTUP&quot; = &quot;color&quot; ] &amp;&amp; $SETCOLOR_NORMAL
-    echo -n &quot;]&quot;
-    echo -ne &quot;\r&quot;
-    return 1
-}
-
-# Inform the graphical boot of our current state
-update_boot_stage() {
-    if [ -x /bin/plymouth ]; then
-        /bin/plymouth --update=&quot;$1&quot;
-    fi
-    return 0
-}
-
-# Log that something succeeded
-success() {
-    [ &quot;$BOOTUP&quot; != &quot;verbose&quot; -a -z &quot;${LSB:-}&quot; ] &amp;&amp; echo_success
-    return 0
-}
-
-# Log that something failed
-failure() {
-    local rc=$?
-    [ &quot;$BOOTUP&quot; != &quot;verbose&quot; -a -z &quot;${LSB:-}&quot; ] &amp;&amp; echo_failure
-    [ -x /bin/plymouth ] &amp;&amp; /bin/plymouth --details
-    return $rc
-}
-
-# Log that something passed, but may have had errors. Useful for fsck
-passed() {
-    local rc=$?
-    [ &quot;$BOOTUP&quot; != &quot;verbose&quot; -a -z &quot;${LSB:-}&quot; ] &amp;&amp; echo_passed
-    return $rc
-}
-
-# Log a warning
-warning() {
-    local rc=$?
-    [ &quot;$BOOTUP&quot; != &quot;verbose&quot; -a -z &quot;${LSB:-}&quot; ] &amp;&amp; echo_warning
-    return $rc
-}
-
-# Run some action. Log its output.
-action() {
-    local STRING rc
-
-    STRING=$1
-    echo -n &quot;$STRING &quot;
-    shift
-    &quot;$@&quot; &amp;&amp; success $&quot;$STRING&quot; || failure $&quot;$STRING&quot;
-    rc=$?
-    echo
-    return $rc
-}
-
-# returns OK if $1 contains $2
-strstr() {
-    [ &quot;${1#*$2*}&quot; = &quot;$1&quot; ] &amp;&amp; return 1
-    return 0
-}
-
-# Check whether file $1 is a backup or rpm-generated file and should be ignored
-is_ignored_file() {
-    case &quot;$1&quot; in
-    *~ | *.bak | *.old | *.orig | *.rpmnew | *.rpmorig | *.rpmsave)
-        return 0
-        ;;
-    esac
-    return 1
-}
-
-# Evaluate shvar-style booleans
-is_true() {
-    case &quot;$1&quot; in
-    [tT] | [yY] | [yY][eE][sS] | [tT][rR][uU][eE] | 1)
-        return 0
-        ;;
-    esac
-    return 1
-}
-
-# Evaluate shvar-style booleans
-is_false() {
-    case &quot;$1&quot; in
-    [fF] | [nN] | [nN][oO] | [fF][aA][lL][sS][eE] | 0)
-        return 0
-        ;;
-    esac
-    return 1
-}
-
-# Apply sysctl settings, including files in /etc/sysctl.d
-apply_sysctl() {
-    if [ -x /lib/systemd/systemd-sysctl ]; then
-    /lib/systemd/systemd-sysctl
-    else
-        for file in /usr/lib/sysctl.d/*.conf ; do
-            is_ignored_file &quot;$file&quot; &amp;&amp; continue
-            [ -f /run/sysctl.d/${file##*/} ] &amp;&amp; continue
-            [ -f /etc/sysctl.d/${file##*/} ] &amp;&amp; continue
-            test -f &quot;$file&quot; &amp;&amp; sysctl -e -p &quot;$file&quot; &gt;/dev/null 2&gt;&amp;1
-        done
-        for file in /run/sysctl.d/*.conf ; do
-            is_ignored_file &quot;$file&quot; &amp;&amp; continue
-            [ -f /etc/sysctl.d/${file##*/} ] &amp;&amp; continue
-            test -f &quot;$file&quot; &amp;&amp; sysctl -e -p &quot;$file&quot; &gt;/dev/null 2&gt;&amp;1
-        done
-        for file in /etc/sysctl.d/*.conf ; do
-            is_ignored_file &quot;$file&quot; &amp;&amp; continue
-            test -f &quot;$file&quot; &amp;&amp; sysctl -e -p &quot;$file&quot; &gt;/dev/null 2&gt;&amp;1
-        done
-        sysctl -e -p /etc/sysctl.conf &gt;/dev/null 2&gt;&amp;1
-    fi
-}
-
-# A sed expression to filter out the files that is_ignored_file recognizes
-__sed_discard_ignored_files=&apos;/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d&apos;
-
-if [ &quot;$_use_systemctl&quot; = &quot;1&quot; ]; then
-        if  [ &quot;x$1&quot; = xstart -o \
-              &quot;x$1&quot; = xstop -o \
-              &quot;x$1&quot; = xrestart -o \
-              &quot;x$1&quot; = xreload -o \
-              &quot;x$1&quot; = xtry-restart -o \
-              &quot;x$1&quot; = xforce-reload -o \
-              &quot;x$1&quot; = xcondrestart ] ; then
-
-        systemctl_redirect $0 $1
-        exit $?
-    fi
-fi
-
-strstr &quot;$(cat /proc/cmdline)&quot; &quot;rc.debug&quot; &amp;&amp; set -x
-return 0
-</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164769</commentid>
    <comment_count>6</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-07-18 13:08:22 +0300</bug_when>
    <thetext>С совместимостью по функции status() есть такая неприятность (помимо наличия в Fedora коротких опций):

в ALT проверка совпадения /proc/PID/exe с обязательным аргументом происходит по умолчанию, а в Fedora опционально (с тем, что указано опцией -b; и только если такая опция есть).

Так что вызов status, который работал в Fedora, не обязательно будет работать в ALT.

У меня есть вариант functions-compat с перекрытием функции status (лучше работает, но может по ошибке пролезть в наши скрипты) и без.

В принципе, в дальнейшем, можно переименовать функцию status в ALT. Потребует простой замены в пакетах из списка: apt-cache whatdepends &apos;/etc/rc.d/init.d(status)&apos; (больше 400). И на всякий случай запретить Requires на старое имя, как уже сделано для некоторых функций из functions-compat (наверное, в sisyphus-check).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164770</commentid>
    <comment_count>7</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2017-07-18 13:28:07 +0300</bug_when>
    <thetext>(In reply to comment #6)
&gt; С совместимостью по функции status() есть такая неприятность (помимо наличия в
&gt; Fedora коротких опций):
&gt; 
&gt; в ALT проверка совпадения /proc/PID/exe с обязательным аргументом происходит по
&gt; умолчанию, а в Fedora опционально (с тем, что указано опцией -b; и только если
&gt; такая опция есть).
&gt; 
&gt; Так что вызов status, который работал в Fedora, не обязательно будет работать в
&gt; ALT.
&gt; 
&gt; У меня есть вариант functions-compat с перекрытием функции status (лучше
&gt; работает, но может по ошибке пролезть в наши скрипты) и без.

А почему бы нам вообще не оторвать /etc/init.d/functions-compat от /etc/init.d/functions и пакета service (и в обратную сторону тоже оторвать)? Назвать пакет initscripts-fedora-compat или как-нибудь ещё, у пусть там происходит что угодно.
На всякий случай запретить зависимости на этот пакет в sisyphus_check.
Мы же всё равно не рассчитываем, что пакеты для федоры будут у нас работать без изменений.

&gt; В принципе, в дальнейшем, можно переименовать функцию status в ALT. Потребует
&gt; простой замены в пакетах из списка: apt-cache whatdepends
&gt; &apos;/etc/rc.d/init.d(status)&apos; (больше 400).

Вообще не вариант.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164771</commentid>
    <comment_count>8</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-07-18 13:48:58 +0300</bug_when>
    <thetext>(In reply to comment #7)

&gt; &gt; У меня есть вариант functions-compat с перекрытием функции status (лучше
&gt; &gt; работает, но может по ошибке пролезть в наши скрипты) и без.
&gt; 
&gt; А почему бы нам вообще не оторвать /etc/init.d/functions-compat от
&gt; /etc/init.d/functions и пакета service (и в обратную сторону тоже оторвать)?
&gt; Назвать пакет initscripts-fedora-compat или как-нибудь ещё, у пусть там
&gt; происходит что угодно.

Да, мне кажется, так даже проще будет.

&gt; На всякий случай запретить зависимости на этот пакет в sisyphus_check.
&gt; Мы же всё равно не рассчитываем, что пакеты для федоры будут у нас работать без
&gt; изменений.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164772</commentid>
    <comment_count>9</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2017-07-18 13:55:42 +0300</bug_when>
    <thetext>aptbox/apt-cache whatdepends &apos;/etc/rc.d/init.d(checkpid)&apos; &apos;/etc/rc.d/init.d(daemon)&apos; &apos;/etc/rc.d/init.d(wait_pid)&apos; &apos;/etc/rc.d/init.d(killproc)&apos; &apos;/etc/rc.d/init.d(pidfileofproc)&apos; &apos;/etc/rc.d/init.d(pidofproc)&apos;          
&lt;/etc/rc.d/init.d(checkpid)&gt;
  xrdp-0.9.2-alt1
    Depends: &lt;/etc/rc.d/init.d(checkpid)&gt;
      service-0.5.26-alt1
  jetty-9.4.0-alt1_0.2.M0jpp8
    Depends: &lt;/etc/rc.d/init.d(checkpid)&gt;
      service-0.5.26-alt1

checkpid сама по себе безвредная функция.
Придётся либо исправить эти два пакета, либо перенести checkpid из compat.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164900</commentid>
    <comment_count>10</comment_count>
    <who name="Repository Robot">repository-robot</who>
    <bug_when>2017-07-27 17:06:34 +0300</bug_when>
    <thetext>initscripts-compat-fedora-9.72-alt1 -&gt; sisyphus:

* Tue Jul 04 2017 Ivan Zakharyaschev &lt;imz@altlinux&gt; 9.72-alt1
- functions-compat: copied the central piece of code from Fedora (tag 9.72)
  and restored as in ALT: initlog, limited, hide pidof; ALT&apos;s status() overridden
  because the check of the PID&apos;s executable is default in ALT and optional
  in Fedora (with -b). (ALT#31952)

* Thu May 25 2017 David Kaspar [Dee&apos;Kej] &lt;dkaspar@redhat.com&gt; - 9.72-1
- rename_device.c: rewrite of isCfg() function
- Add *.old to list of ignored files
- Replace usleep(1) calls with sleep(1) calls

* Wed May 24 2017 David Kaspar [Dee&apos;Kej] &lt;dkaspar@redhat.com&gt; - 9.71-1
- usleep: print deprecation warning from now on
- sysconfig.txt: mention previously introduced NO_DHCP_HOSTNAME option
- DHCP_FQDN and DHCP_SEND_HOSTNAME introduced
- re-add missing $HOSTNAME initialization
- ifup: add support for VLAN_EGRESS_PRIORITY_MAP
- specfile: mark &apos;rwtab&apos; and &apos;statetab&apos; as config files
- killproc/status: add missing &apos;-b &lt;binary&gt;&apos; option
- ifdown-eth: we need to flush global scope as well
- ifup-eth: remove quote marks
- po: download latest translations from zanata
- rwtab: add /var/lib/systemd/timers
- Update initscripts.pot
- Port headers in xgettext_sh.py to 2017</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>