aboutsummaryrefslogtreecommitdiffstats
path: root/testing/darwin-streaming-server/dss.initd
blob: 15dd6f9ced3764930fc19c42ee61c89a965d53e0 (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/sbin/runscript

opts="statusdss statusadmin restart"

depend() {
        need net
        use dns
}

start() {
        ebegin "Starting DSS (per Streaming Admin Server)"
        /usr/sbin/streamingadminserver.pl
        eend $?
}

stop(){

        PIDFILE="/var/run/darwinstreaming/adminserver.pid"

        if [ -f "$PIDFILE" ]; then

                PID=`cat "$PIDFILE"`
                ps axo pid | grep $PID &>/dev/null

                if [ $? -eq 0 ]; then
                        ebegin "Stopping Streaming Admin Server"
                        kill $PID
                        eend $?
                else
                        einfo "Streaming Admin Server not running."
                        ebegin "Dropping stale PID file"
                        rm "$PIDFILE"
                        eend $?
                fi

        else
                einfo "Streaming Admin Server not running obviously."
        fi


        # DSS isn't writing PID file actually
        # --> use ps to check for running instance

        PID=`ps axo user,pid,cmd | grep -E '^qtss ' | grep Streaming | awk '{print $2}'`

        if [ $? -eq 0 ]; then
                ebegin "Stopping DSS"
                kill $PID
                eend $?
        else
                einfo "DSS not running."
        fi

}

statusdss() {
        PIDFILE="/var/run/darwinstreaming/DarwinStreamingServer.pid"
        if [ -f "$PIDFILE" ]; then

                PID=`cat "$PIDFILE"`
                ps axo pid | grep PID &>/dev/null

                if [ $? -eq 0 ]; then
                        einfo "DSS is running"
                        return 0
                else
                        ewarning "found stale PID file"
                fi
        fi

        einfo "DSS is not running"
        return 1
}

statusadmin() {
        PIDFILE="/var/run/darwinstreaming/adminserver.pid"
        if [ -f "$PIDFILE" ]; then

                PID=`cat "$PIDFILE"`
                ps axo pid | grep PID &>/dev/null

                if [ $? -eq 0 ]; then
                        einfo "Streaming Admin Server is running"
                        return 0
                else
                        ewarning "found stale PID file"
                fi
        fi

        einfo "Streaming Admin Server is not running"
        return 1
}

restart() {
        stop
        start
}