summaryrefslogtreecommitdiff
path: root/scripts/vyatta-protocol
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-04 13:58:41 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-04 15:13:44 -0800
commit7158009fa019bb9eb5b871750e3658590b3a122f (patch)
treeb14de3ba75a42a218bf9e768bf229cc3992604c3 /scripts/vyatta-protocol
parentde5866ef8e4c4249448a9e0d962f3f957c954ccd (diff)
downloadvyatta-cfg-quagga-7158009fa019bb9eb5b871750e3658590b3a122f.tar.gz
vyatta-cfg-quagga-7158009fa019bb9eb5b871750e3658590b3a122f.zip
Protocol daemon management
Bug 3828 Start protocols from configuration system, and use watchquagga to restart protocol daemons after failure
Diffstat (limited to 'scripts/vyatta-protocol')
-rwxr-xr-xscripts/vyatta-protocol74
1 files changed, 74 insertions, 0 deletions
diff --git a/scripts/vyatta-protocol b/scripts/vyatta-protocol
new file mode 100755
index 00000000..2d4ba430
--- /dev/null
+++ b/scripts/vyatta-protocol
@@ -0,0 +1,74 @@
+#! /bin/bash
+#
+# This is special script for start,stop,restart of quagga daemons
+#
+progname=$0
+usage() {
+ echo "Usage: $progname {start|stop|reload} {bgp|ospf|rip|ripng}"
+ exit 1;
+}
+
+if [ $# -lt 2 ]; then
+ usage
+fi
+
+protocol=$2
+daemon=${protocol}d
+exe_file=/usr/sbin/vyatta-$daemon
+
+pid_dir=/var/run/vyatta/quagga
+pid_file=$pid_dir/${daemon}.pid
+log_dir=/var/log/vyatta/quagga
+
+if [ ! -x $exe_file ]; then
+ echo "Unknown protocol: $protocol";
+ exit 1;
+fi
+
+case "$1" in
+ start)
+ echo -n "Starting $protocol..."
+ sudo start-stop-daemon --start --quiet \
+ --chdir $log_dir \
+ --exec $exe_file \
+ -- -d -P 0 -i $pid_dir/${daemon}.pid
+ sudo start-stop-daemon --start --quiet \
+ --chdir $log_dir \
+ --pidfile $pid_dir/watch-${daemon}.pid \
+ --exec /usr/sbin/vyatta-watchquagga \
+ -- -dz -R "/opt/vyatta/sbin/vyatta-quagga reload $protocol" $daemon
+ echo "done."
+ ;;
+
+ stop)
+ echo -n "Stopping $protocol..."
+ sudo start-stop-daemon --stop --quiet --oknodo --retry 2 \
+ --pidfile $pid_dir/watch-${daemon}.pid
+ sudo start-stop-daemon --stop --quiet --oknodo --retry 2 \
+ --exec $exe_file
+ echo "done."
+ ;;
+
+ reload)
+ echo -n "Reloading $1..."
+ # Start new transaction
+ /opt/vyatta/sbin/vyatta-cfg-cmd-wrapper begin
+
+ # In case of error undo
+ trap "/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper end" EXIT HUP INT QUIT TERM
+
+ # Save current configuration
+ tmp=/tmp/${protocol}-restart.$$
+ /opt/vyatta/sbin/vyatta-save-config.pl $tmp
+
+ # Erase active configuration for that protocol
+ rm -fr /opt/vyatta/config/active/protocols/$protocol
+
+ # Reload causing configuration to activate - implies commit
+ /opt/vyatta/sbin/vyatta-load-config.pl $TMP
+ echo "done."
+ ;;
+ *)
+ usage;;
+esac
+