diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/quagga-manager | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/scripts/quagga-manager b/scripts/quagga-manager index e7b5d5ae..58c91b66 100755 --- a/scripts/quagga-manager +++ b/scripts/quagga-manager @@ -4,10 +4,10 @@ # # debug -#echo $* | logger -p local7.debug -t quagga-manager +# echo $* | logger -p local7.debug -t quagga-manager usage() { - echo "Usage: $0 {check|start|stop|restart} {bgpd|ospfd|ripd|ripngd}" + echo "Usage: $0 {check|start|stop|restart} {bgpd|ospfd|ripd|ospf6d|ripngd}" exit 1 } @@ -42,6 +42,8 @@ start() { zebra) args+=( -l -S -s 1048576 ) ;; watchquagga) args=( -dz -p ${pid_dir}/${daemon}.pid ); + # Note: at present ospf/rip only monitored if actually active + # probably should get smarter in future here local -a protocols=(`/opt/vyatta/bin/vyatta-show-protocols exists`) if [ ${#protocols[*]} -eq 0 ] @@ -72,9 +74,19 @@ stop() { rm -f $pid_dir/${daemon}.pid } +get_protocol() { + local daemon=$1 + case $daemon in + bgpd|ospfd|ripd|ripngd|isisd) echo ${daemon/%d/};; + ospf6d) echo "ospfv3";; + *) echo "Unknown daemon $daemon" 1>&2; exit 1;; + esac +} + reload_config() { local daemon=$1 - local proto=${daemon/%d/} + local proto=$(get_protocol $daemon) + local vyatta_cfg=/opt/vyatta/config/active local path=$vyatta_cfg/protocols/$proto @@ -94,10 +106,14 @@ reload_config() { # Erase portion of active configuration for that protocol rm -fr $path - # special case for interface configuration + # special case for interface, remove parameters force reload case $proto in rip|ospf) - find $vyatta_cfg/interfaces -type d -name $daemon -exec rm -fr '{}' \; ;; + find $vyatta_cfg/interfaces -type d -path "*/ip/$proto" \ + -exec rm -fr '{}' \; ;; + ripng|ospfv3) + find $vyatta_cfg/interfaces -type d -path "*/ipv6/$proto" \ + -exec rm -fr '{}' \; ;; esac # Reload causing configuration to activate - implies commit @@ -108,7 +124,24 @@ reload_config() { trap "" EXIT HUP INT QUIT TERM } +# Check if interface configuration exists for this protocol +okay_to_stop() { + local daemon=$1 + local proto=$(get_protocol $daemon) + local cfg=/opt/vyatta/config/active/interfaces + + case $proto in + rip|ospf) + return $(find $cfg -type d -path "*/ip/$proto" | wc -l);; + ripng|ospfv3) + return $(find $cfg -type d -path "*/ipv6/$proto" | wc -l);; + *) + return 0;; + esac +} + update() { + # get list of daemons deleted and added in current transaction local -a deleted=( `/opt/vyatta/bin/vyatta-show-protocols deleted` ) local -a added=( `/opt/vyatta/bin/vyatta-show-protocols added` ) @@ -120,7 +153,11 @@ update() { # Cleanup any daemons no longer needed for p in ${deleted[*]} - do stop $p + do + # Need daemon to hold state of interface + if okay_to_stop $p + then stop $p + fi done start watchquagga |