From da79c6705e8f3cf5fb1c29dac6ea8167e5bc5410 Mon Sep 17 00:00:00 2001 From: thompsa Date: Thu, 25 Mar 2010 21:53:41 +1300 Subject: Be safer about reloading ospfd. Use the return value of ospfctl to determine if ospfd is running which is more reliable than grokking ps. --- config/openospfd/openospfd.inc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index d6a3e67d..c6368271 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -176,10 +176,10 @@ function ospfd_install_conf() { exec("chmod u+rw /usr/local/etc/ospfd.conf"); // ospfd process running? if so reload, elsewise start. - if(is_ospfd_running() == true) { - exec("/usr/local/sbin/ospfctl reload"); - } else { - exec("/usr/local/sbin/ospfd"); + exec("/usr/local/sbin/ospfctl reload", $rval); + if ($rval != 0) { + exec("/bin/pkill -x ospfd"); + exec("/usr/local/sbin/ospfd -f /usr/local/etc/ospfd.conf"); } conf_mount_ro(); @@ -231,13 +231,4 @@ function ospfd_put_raw_config($conffile) { $config['installedpackages']['ospfd']['rawconfig'] = $conffile; } } - -function is_ospfd_running() { - $status = `ps awux | grep ospfd | grep "parent" | grep -v grep | wc -l | awk '{ print \$1 }'`; - if(intval($status) > 0) - return true; - else - return false; -} - ?> -- cgit v1.2.3