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

# debuginfofs   This shell script takes care of mounting and unmounting the
#               debuginfo filesystem.
#
# chkconfig: - 60 50
# description: debuginfofs mounts a WebDAV share of debuginfo files at the \
#              appropriate place(s) in the filesystem for use by gdb and other \
#              debugging tools.
# config: /etc/sysconfig/debuginfofs

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

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

# Source our configuration
. /etc/sysconfig/debuginfofs

RETVAL=0
prog="debuginfofs"

start() {
        # Mount filesystems.

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

        # Sanity check binary and configuration
        [ -x /usr/bin/wdfs ] || exit 1
        [ -n "$BUILDID_URL" ] || exit 1
        [ -n "$BUILDID_MOUNTPOINT" ] || exit 1
        [ -d "$BUILDID_MOUNTPOINT" ] || mkdir -p "$BUILDID_MOUNTPOINT"

        echo -n $"Starting debuginfofs: "
        wdfs "$BUILDID_URL" "$BUILDID_MOUNTPOINT" -o allow_other -o nonempty \
             -o intr $BUILDID_ARGS
        RETVAL=$?

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

stop() {
        echo -n $"Stopping debuginfofs: "
        fusermount -u "$BUILDID_MOUNTPOINT"
        RETVAL=$?
        rm -f /var/lock/subsys/debuginfofs
        [ $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)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f /var/lock/subsys/debuginfofs ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $RETVAL