瀏覽代碼

package/openrc: cleanup sysv-rcs script

Currently, the sysv-rcs script has two issues:
  - The return code of each RCS script is not checked.
  - The output does not match the formatting of the other openrc
    init scripts.

Modify the script in the following ways to fix both issues:
  - Remove the "einfo "Starting sysv rc scripts"" at the top of the
    start function in favor of "einfo "Starting $i" in the loop
    itself.

  - Add a "> /dev/null" to the end of $i start; this suppresses
    stdout while still allowing for stderr messages to print to the
    terminal.

  - add an "eend $? to both the start and stop functions, this
    allows for openrc to show if an RCS script returned 0 or
    not.

The following is the startup output of OpenRC on a minimal system
with S01syslogd modified to exit with a return code 1 for testing
purposes:

Before:
 * Adding static routes ...
 [ ok ]
Starting default runlevel
 * Starting sysv rc scripts
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK

After:
 * Adding static routes ...
 [ ok ]
Starting default runlevel
 * Starting /etc/init.d/S01syslogd ...
 [ !! ]
 * Starting /etc/init.d/S02klogd ...
 [ ok ]
 * Starting /etc/init.d/S02sysctl ...
 [ ok ]

Signed-off-by: Adam Duskett <aduskett@greenlots.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Adam Duskett 5 年之前
父節點
當前提交
bc66a64193
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      package/openrc/sysv-rcs

+ 6 - 4
package/openrc/sysv-rcs

@@ -7,19 +7,21 @@ depend() {
 }
 
 start() {
-    einfo "Starting sysv rc scripts"
     for i in /etc/init.d/S??*; do
         # Ignore dangling symlinks (if any).
         [ -e "$i" ] || continue
-        $i start
+        einfo "Starting $i"
+        $i start > /dev/null
+        eend $?
     done
 }
 
 stop() {
-    einfo "Stopping sysv rc scripts"
     for i in $(ls -r /etc/init.d/S??*); do
         # Ignore dangling symlinks (if any).
         [ -e "$i" ] || continue
-        $i stop
+        einfo "Stopping $i"
+        $i stop > /dev/null
+        eend $?
     done
 }