]> git.proxmox.com Git - mirror_frr.git/blob - tools/frrinit.sh.in
zebra: Convert socket interface to use `union sockunion`
[mirror_frr.git] / tools / frrinit.sh.in
1 #!/bin/sh
2 #
3 ### BEGIN INIT INFO
4 # Provides: frr
5 # Required-Start: $local_fs $network $remote_fs $syslog
6 # Required-Stop: $local_fs $network $remote_fs $syslog
7 # Default-Start: 2 3 4 5
8 # Default-Stop: 0 1 6
9 # Short-Description: start and stop the FRR routing suite
10 # Description: FRR is a routing suite for IP routing protocols like
11 # BGP, OSPF, RIP and others. This script contols the main
12 # "watchfrr" daemon.
13 ### END INIT INFO
14 #
15 # This is the main init script for FRR. It mostly wraps frrcommon.sh which
16 # provides the actual functions to start/stop/restart things.
17 #
18
19 if [ -r "/lib/lsb/init-functions" ]; then
20 . /lib/lsb/init-functions
21 else
22 log_success_msg() {
23 echo "$@"
24 }
25 log_warning_msg() {
26 echo "$@" >&2
27 }
28 log_failure_msg() {
29 echo "$@" >&2
30 }
31 fi
32
33 self="`dirname $0`"
34 if [ -r "$self/frrcommon.sh" ]; then
35 . "$self/frrcommon.sh"
36 else
37 . "@CFG_SBIN@/frrcommon.sh"
38 fi
39
40 case "$1" in
41 start)
42 daemon_list daemons
43 watchfrr_options="$watchfrr_options $daemons"
44 daemon_start watchfrr
45 ;;
46 stop)
47 daemon_stop watchfrr
48 all_stop --reallyall
49 exit ${still_running:-0}
50 ;;
51
52 restart|force-reload)
53 daemon_stop watchfrr
54 all_stop --reallyall
55
56 daemon_list daemons
57 watchfrr_options="$watchfrr_options $daemons"
58 daemon_start watchfrr
59 ;;
60
61 status)
62 fail=0
63 print_status watchfrr || fail=1
64 all_status || fail=1
65 exit $fail
66 ;;
67
68 reload)
69 if [ ! -x "$RELOAD_SCRIPT" ]; then
70 log_failure_msg "The frr-pythontools package is required for reload functionality."
71 exit 1
72 fi
73
74 # restart watchfrr to pick up added daemons.
75 # NB: This will NOT cause the other daemons to be restarted.
76 daemon_list daemons
77 watchfrr_options="$watchfrr_options $daemons"
78 daemon_stop watchfrr && \
79 daemon_start watchfrr
80
81 NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}"
82 [ ! -r $NEW_CONFIG_FILE ] && log_failure_msg "Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1
83 "$RELOAD_SCRIPT" --reload "$NEW_CONFIG_FILE"
84 exit $?
85 ;;
86
87 *)
88 log_failure_msg "Unknown command: $1" >&2
89 exit 1
90 esac