]>
Commit | Line | Data |
---|---|---|
1e6d2d09 VD |
1 | #!/bin/bash |
2 | # | |
3 | # Script to start/stop spanning tree called from kernel | |
4 | # Make sure umask is sane | |
5 | umask 022 | |
6 | ||
7 | # Set up a default search path. | |
8 | PATH="/sbin:/usr/sbin:/bin:/usr/bin" | |
9 | export PATH | |
10 | ||
11 | if [ $# -ne 2 ]; then | |
12 | echo "Usage: bridge-stp <bridge> {start|stop}" | |
13 | exit 1 | |
14 | fi | |
15 | bridge=$1 | |
16 | service=mstpd | |
17 | pid_file=/var/run/${service}.pid | |
18 | ||
19 | # Set this to the list of bridges for which MSTP should be used | |
20 | MSTP_BRIDGES="br0" | |
21 | ||
22 | # Set $pid to pids from /var/run* for {program}. $pid should be declared | |
23 | # local in the caller. | |
24 | # Returns LSB exit code for the 'status' action. | |
25 | checkpid() | |
26 | { | |
27 | pid= | |
28 | if [ -f "$1" ] ; then | |
29 | local line p | |
30 | read line < "$pid_file" | |
31 | for p in $line ; do | |
32 | [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p" | |
33 | done | |
34 | if [ -n "$pid" ]; then | |
35 | return 0 | |
36 | fi | |
37 | return 1 # "Program is dead and /var/run pid file exists" | |
38 | fi | |
39 | return 3 # "Program is not running" | |
40 | } | |
41 | ||
42 | case $2 in | |
43 | start) | |
44 | checkpid $pid_file || exit 1 | |
45 | for b in $MSTP_BRIDGES; do | |
46 | if [ "$bridge" == "$b" ]; then | |
47 | exit 0; | |
48 | fi | |
49 | done | |
50 | exit 1 ;; | |
51 | stop) | |
52 | exit 0 ;; | |
53 | *) | |
54 | echo "Unknown action:" $2 | |
55 | echo "Usage: bridge-stp <bridge> {start|stop}" | |
56 | exit 1 | |
57 | esac |