summaryrefslogtreecommitdiffstats
path: root/debuginfofs-server.init
blob: ac294bc219b1b9bcc79be2299894fd70ba514d2b (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
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: debuginfofs-server
# Required-Start: $local_fs $network $named $remote_fs $syslog
# Required-Stop: $local_fs $network $named $remote_fs $syslog
# Short-Description: Remote debuginfo filesystem server
# Description: Export a filesystem with debuginfo for use with debugging tools
### END INIT INFO

# debuginfofs   Starts/stops the debuginfofs WebDAV server
#
# chkconfig: - 85 15
# description: debuginfofs-server starts a WebDAV server which exports the \
#              debuginfo data fetched with debuginfofs-mirror.
# config: /etc/debuginfofs.conf

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Read our configuration
export DEBUGINFOFS_EXPORTDIR="$(sed -ne 's/ *exportdir *=\(.*\)$/\1/p' /etc/debuginfofs.conf 2>/dev/null)"

RETVAL=0
prog="debuginfofs-server"
pidfile="/var/run/$prog.pid"

start() {
        # Check that networking is up.
        [ ${NETWORKING} = "no" ] && exit 1

        # Sanity check binary and configuration
        [ -x /usr/sbin/httpd ] || exit 1
        [ -d "$DEBUGINFOFS_EXPORTDIR" ] || mkdir -p "$DEBUGINFOFS_EXPORTDIR"
        [ -r "$DEBUGINFOFS_EXPORTDIR" ] || exit 1

        echo -n $"Starting debuginfofs-server: "
        /usr/sbin/httpd -f /usr/share/debuginfofs/dav-debuginfo.conf
        RETVAL=$?

        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/debuginfofs-server
        [ $RETVAL -eq 0 ] && success $"$prog startup" || failure $"$prog startup"
        echo
        return $RETVAL
}

stop() {
        echo -n $"Stopping debuginfofs: "
        /usr/sbin/httpd -f /usr/share/debuginfofs/dav-debuginfo.conf -k stop
        RETVAL=$?
        rm -f /var/lock/subsys/debuginfofs-server
        [ $RETVAL -eq 0 ] && success $"$prog shutdown" || failure $"$prog shutdown"
        echo
        return $RETVAL
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload|force-reload)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f /var/lock/subsys/debuginfofs-server ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $RETVAL