summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-05 16:42:48 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-05 16:42:48 -0800
commit5db776a29c90d05f864645e7e171840660f4b268 (patch)
treedf8d452272a33ffea3732138c17e8439967e402f
parentdc847212c3a95016a315f4aaf3bf3e134d2bbebd (diff)
downloadvyatta-cfg-quagga-5db776a29c90d05f864645e7e171840660f4b268.tar.gz
vyatta-cfg-quagga-5db776a29c90d05f864645e7e171840660f4b268.zip
Move sudo from vyatta-protocol to nodes
Much cleaner to do sudo once rather than repeatedly
-rwxr-xr-xscripts/vyatta-protocol28
-rw-r--r--templates/protocols/bgp/node.def4
-rw-r--r--templates/protocols/ospf/node.def4
-rw-r--r--templates/protocols/rip/node.def4
-rw-r--r--templates/protocols/ripng/node.def4
5 files changed, 25 insertions, 19 deletions
diff --git a/scripts/vyatta-protocol b/scripts/vyatta-protocol
index 0e76f8c2..d6e91167 100755
--- a/scripts/vyatta-protocol
+++ b/scripts/vyatta-protocol
@@ -5,13 +5,14 @@
progname=$0
usage() {
echo "Usage: $progname {start|stop|restart} {bgpd|ospfd|ripd|ripngd}"
- exit 1;
+ exit 1
}
if [ $# -lt 2 ]; then
usage
fi
+
daemon=$2
exe_file=/usr/sbin/vyatta-$daemon
@@ -21,15 +22,20 @@ log_dir=/var/log/vyatta/quagga
if [ ! -x $exe_file ]; then
echo "Unknown daemon $daemon"
- exit 1;
+ exit 1
+fi
+
+if [ $EUID -ne 0 ]; then
+ echo "must be root!"
+ exit 1
fi
case "$1" in
start)
- sudo start-stop-daemon --start --quiet \
+ 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 \
+ start-stop-daemon --start --quiet \
--chdir $log_dir \
--exec /usr/sbin/vyatta-watchquagga \
-- -p $pid_dir/watch-${daemon}.pid \
@@ -37,22 +43,22 @@ case "$1" in
;;
stop)
- sudo start-stop-daemon --stop --quiet --oknodo --retry 2 \
+ start-stop-daemon --stop --quiet --oknodo --retry 2 \
--pidfile $pid_dir/watch-${daemon}.pid
- sudo rm -f $pid_dir/watch-${daemon}.pid
- sudo start-stop-daemon --stop --quiet --oknodo --retry 2 \
+ rm -f $pid_dir/watch-${daemon}.pid
+ start-stop-daemon --stop --quiet --oknodo --retry 2 \
--exec $exe_file
- sudo rm -f $pid_dir/${daemon}.pid
+ rm -f $pid_dir/${daemon}.pid
;;
restart)
# Restart daemon
- sudo start-stop-daemon --stop --quiet --oknodo --exec $exe_file
- sudo start-stop-daemon --start --quiet \
+ start-stop-daemon --stop --quiet --oknodo --exec $exe_file
+ start-stop-daemon --start --quiet \
--chdir $log_dir --exec $exe_file \
-- -d -P 0 -i $pid_dir/${daemon}.pid
- sudo /opt/vyatta/sbin/vyatta-cfg-reload protocols ${daemon/%d/}
+ /opt/vyatta/sbin/vyatta-cfg-reload protocols ${daemon/%d/}
;;
*)
usage;;
diff --git a/templates/protocols/bgp/node.def b/templates/protocols/bgp/node.def
index ca1ae005..ea3a9c4c 100644
--- a/templates/protocols/bgp/node.def
+++ b/templates/protocols/bgp/node.def
@@ -6,14 +6,14 @@ syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 4294967294 ; \
"AS number must be between 1 and 4294967294"
create: if [ $(pgrep -c -x vyatta-bgpd) -eq 0 ]
- then ${vyatta_sbindir}/vyatta-protocol start bgpd
+ then sudo ${vyatta_sbindir}/vyatta-protocol start bgpd
fi
vyatta-vtysh -c "configure terminal" -c "router bgp $VAR(@)"
update: vyatta-vtysh -c "configure terminal" -c "router bgp $VAR(@)" \
-c "bgp network import-check"
delete: vyatta-vtysh -c "configure terminal" -c "no router bgp $VAR(@)"
if ! ${vyatta_sbindir}/vyatta-check-typeless-node.pl "protocols bgp"
- then ${vyatta_sbindir}/vyatta-protocol stop bgpd
+ then sudo ${vyatta_sbindir}/vyatta-protocol stop bgpd
fi
diff --git a/templates/protocols/ospf/node.def b/templates/protocols/ospf/node.def
index 5405abac..f14b1fb8 100644
--- a/templates/protocols/ospf/node.def
+++ b/templates/protocols/ospf/node.def
@@ -1,5 +1,5 @@
help: Configure Open Shortest Path First protocol (OSPF) parameters
-create: /opt/vyatta/sbin/vyatta-protocol start ospfd
+create: sudo ${vyatta_sbindir}/vyatta-protocol start ospfd
vyatta-vtysh -c "configure terminal" -c "router ospf"
delete: vyatta-vtysh -c "configure terminal" -c "no router ospf"
- /opt/vyatta/sbin/vyatta-protocol stop ospfd
+ sudo ${vyatta_sbindir}/vyatta-protocol stop ospfd
diff --git a/templates/protocols/rip/node.def b/templates/protocols/rip/node.def
index a77bdb30..20cb58ad 100644
--- a/templates/protocols/rip/node.def
+++ b/templates/protocols/rip/node.def
@@ -1,7 +1,7 @@
help: Configure Routing Information Protocol (RIP) parameters
-create: /opt/vyatta/sbin/vyatta-protocol start ripd
+create: sudo ${vyatta_sbindir}/vyatta-protocol start ripd
vyatta-vtysh -c "configure terminal" -c "router rip"
delete: vyatta-vtysh -c "configure terminal" -c "no router rip"
- /opt/vyatta/sbin/vyatta-protocol stop ripd
+ sudo ${vyatta_sbindir}/vyatta-protocol stop ripd
diff --git a/templates/protocols/ripng/node.def b/templates/protocols/ripng/node.def
index 18735607..73f86c92 100644
--- a/templates/protocols/ripng/node.def
+++ b/templates/protocols/ripng/node.def
@@ -1,5 +1,5 @@
help: Configure Routing Information Protocol (RIPng) parameters
-create: /opt/vyatta/sbin/vyatta-protocol start ripngd
+create: sudo ${vyatta_sbindir}/vyatta-protocol start ripngd
vyatta-vtysh -c "configure terminal" -c "router ripng"
delete: vyatta-vtysh -c "configure terminal" -c "no router ripng"
- /opt/vyatta/sbin/vyatta-protocol stop ripngd
+ sudo ${vyatta_sbindir}/vyatta-protocol stop ripngd