File: runit-default

package info (click to toggle)
runit 2.2.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,568 kB
  • sloc: ansic: 6,071; sh: 3,419; makefile: 399
file content (76 lines) | stat: -rwxr-xr-x 3,259 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh

#called from invoke-rc.d like  "/etc/runit/override-sysv.d/runit-default servicename action [extraparam]"
#then the return code is checked to decide whether to continue with sysv

rservice="$1"
rservice="${rservice%.sh}"
raction="$2"
extra="$3"

# single service override
if [ -f /etc/runit/override-sysv.d/"$rservice".block ] || [ -f /etc/runit/override-sysv.d/"$rservice".pkgblock ]; then
    [ -e /etc/runit/verbose ] && echo "runit override: $rservice: invoke-rc.d action $raction blocked "
    exit 1 #block invoke-rc.d, don't forward to sv
fi
if [ -f /etc/runit/override-sysv.d/"$rservice".runit ] || [ -f /etc/runit/override-sysv.d/"$rservice".pkgrunit ]; then
    if [ -d /etc/service/"$rservice" ]; then
        case "$raction" in
          start|stop|restart|reload|status|try-restart|force-stop|force-reload|force-restart)
            if [ "$raction" = "force-reload" ]; then
              raction=reload #bluez force-reload dbus in postinst, restarting dbus instead of reload
            fi
	    [ -e /etc/runit/verbose ] && echo "runit override: $rservice: invoke-rc.d action $raction forwarded to sv "
            sv "$raction" "$rservice" || true # forward to runit
            exit 1 #block invoke-rc.d
          ;;
          *)
            [ -e /etc/runit/verbose ] && echo "runit override: $rservice: $raction not supported by sv, forwarding to the sysv script"
            exit 104
          ;;
        esac
    fi
    exit 1 #block invoke-rc.d
fi
if [ -f /etc/runit/override-sysv.d/"$rservice".sysv ]; then
    [ -e /etc/runit/verbose ] && echo "runit override: $rservice: forwarding action $raction to sysv via invoke-rc.d "
    exit 104 #continue with invoke-rc.d, don't forward to sv
fi

# default package policy

#map runit's default multi instance to sysv e.g ssh@default=ssh
rinstance="$rservice"
if [ -d /etc/sv/"$rservice@default" ] || [ -d /usr/share/runit/sv.current/"$rservice@default" ] ; then
    rinstance="$rservice@default"
fi

if [ -h /etc/service/"$rinstance" ]; then
    [ -e "/usr/share/runit/meta/$rinstance/installed" ] && exit 1 #dh-runit/runit-helper managed
    [ -e "/etc/sv/$rinstance/.meta/bin" ] && exit 1 # runit trigger-sv
    [ -e "/usr/share/runit/sv.current/$rinstance/.meta/bin" ] && exit 1 # runit trigger-sv
    case "$raction" in
      start|stop|restart|reload|status|try-restart|force-stop|force-reload|force-restart)
        if [ "$raction" = "force-reload" ]; then
              raction=reload #bluez force-reload dbus in postinst, restarting dbus instead of reload
        fi
        sv "$raction" "$rinstance" || true
        exit 1 #block invoke-rc.d
    ;;
      *)
        [ -e /etc/runit/verbose ] && echo "runit override: $rinstance: $raction not supported by sv, forwarding to the sysv script"
        exit 104
    ;;
    esac
else
    [ -d "/etc/sv/$rinstance" ] && exit 1 # disabled
    [ -d "/usr/share/runit/sv.current/$rinstance" ] && exit 1 # disabled
fi
#no runscrit found for $rservice: continue with sysvinit script
[ -e /etc/runit/verbose ] && echo "runit override: $rinstance: no runscript found, forwarding to sysv script "
exit 104

# to always block sysv do
#exit 1 || exit 0 (any value different from 104 does the job)
# to always continue with sysv do
#exit 104