File: bagpipe-bgp

package info (click to toggle)
networking-bagpipe 23.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,872 kB
  • sloc: python: 15,677; sh: 927; makefile: 62
file content (97 lines) | stat: -rwxr-xr-x 2,568 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
### BEGIN INIT INFO
# Provides: bagpipe-bgp
# Should-Start:
# Required-Stop:
# Required-Start:
# Should-Stop:
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Short-Description: BGP component daemon service
# Description: Provides BGP component daemon service
### END INIT INFO
#
# Copyright 2014 Orange

PID_DIR=/var/run/bagpipe-bgp
LOG_DIR=/var/log/bagpipe-bgp

BGP_DAEMON=$(which bagpipe-bgp)
BGP_DATAPLANE_CLEANUP=$(which bagpipe-bgp-cleanup)

#OPTIONS="--config-file=/etc/bagpipe-bgp/conf_alt.conf"

mkdir -p "$PID_DIR"


if [ ! -f "$BGP_DAEMON" ]; then
    echo "ERROR: BGP component daemon service not found..."
    exit 1
fi

case "$1" in
  start)
    # Start the daemon
    if [ "$(pgrep -fl $BGP_DAEMON)" == "" ]; then
        echo "Starting BGP component..."
        $BGP_DAEMON --ack-oslo-log start $OPTIONS
    else
        echo "WARNING: BGP component has already been started..."
    fi
    ;;
  stop)
    # Stop the daemon with dataplane cleanup
    echo "Stopping BGP component with dataplane cleanup..."
    if [ "$(pgrep -fl $BGP_DAEMON)" != "" ]; then
        $BGP_DAEMON --ack-oslo-log stop $OPTIONS

        # Clean dataplane when daemon has been stopped
        while pgrep -fl $BGP_DAEMON > /dev/null; do
            sleep 1;
        done

        echo "Cleaning dataplane..."
        $BGP_DATAPLANE_CLEANUP --ack-oslo-log $OPTIONS
    else
        echo "WARNING: BGP component was already stopped..."
    fi
    ;;
  stop-noclean)
    # Stop the daemon without dataplane cleanup
    echo "Stopping BGP component (without dataplane cleanup)..."
    if [ "$(pgrep -fl $BGP_DAEMON)" != "" ]; then
        $BGP_DAEMON --ack-oslo-log stop $OPTIONS
    else
        echo "WARNING: BGP component was already stopped..."
    fi
    ;;
  restart)
    if [ "$(pgrep -fl $BGP_DAEMON)" != "" ]; then
        echo -n "Restarting BGP component... stopping..."
        $BGP_DAEMON --ack-oslo-log stop  $OPTIONS
        while pgrep -fl $BGP_DAEMON > /dev/null; do
            sleep 1
            echo -n "."
        done
        echo "...starting"
        $BGP_DAEMON --ack-oslo-log start  $OPTIONS
    else
        echo "Starting BGP component (was already stopped)"
        $BGP_DAEMON --ack-oslo-log start  $OPTIONS
    fi
    ;;
  status)
    if [ "$(pgrep -fl $BGP_DAEMON)" != "" ]; then
        echo "BGP component is running."
    else
        echo "BGP component is stopped."
    fi
    ;;
  *)
    # Refuse to do other stuff
    echo "Usage: service bagpipe-bgp {start|stop|restart|stop-noclean|status}"
    exit 1
    ;;
esac

exit 0