aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/quagga_ospfd/quagga_ospfd.inc57
-rw-r--r--config/quagga_ospfd/quagga_ospfd.xml2
-rw-r--r--config/quagga_ospfd/quaggactl5
-rw-r--r--pkg_config.8.xml2
-rw-r--r--pkg_config.8.xml.amd642
5 files changed, 45 insertions, 23 deletions
diff --git a/config/quagga_ospfd/quagga_ospfd.inc b/config/quagga_ospfd/quagga_ospfd.inc
index 7d47617c..d62c0efa 100644
--- a/config/quagga_ospfd/quagga_ospfd.inc
+++ b/config/quagga_ospfd/quagga_ospfd.inc
@@ -28,6 +28,15 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+$quagga_config_base = "/var/etc/quagga";
+$pkg_login = "quagga";
+$pkg_uid = "101";
+$pkg_group = "quagga";
+$pkg_gid = "101";
+$pkg_gecos = "Quagga route daemon pseudo user";
+$pkg_homedir = "/var/etc/quagga";
+$pkg_shell = "/usr/sbin/nologin";
+
function quagga_ospfd_get_interfaces() {
global $config;
$interfaces = get_configured_interface_with_descr();
@@ -54,7 +63,7 @@ function quagga_ospfd_get_interfaces() {
}
function quagga_ospfd_install_conf() {
- global $config, $g, $input_errors;
+ global $config, $g, $input_errors, $quagga_config_base, $pkg_login, $pkg_uid, $pkg_group, $pkg_gid, $pkg_gecos, $pkg_homedir, $pkg_shell;
conf_mount_rw();
@@ -175,17 +184,16 @@ function quagga_ospfd_install_conf() {
if (is_array($interface_networks)) {
foreach ($interface_networks as $ifn) {
-
if (is_subnet($ifn['subnet'])) {
$conffile .= " network {$ifn['subnet']} area {$ifn['area']}\n";
}
-
}
}
if (is_array($ospfd_conf['row'])) {
foreach ($ospfd_conf['row'] as $redistr) {
-
+ if (empty($redistr['routevalue']))
+ continue;
if (isset($redistr['redistribute'])) {
$conffile .= " no ";
}
@@ -198,7 +206,8 @@ function quagga_ospfd_install_conf() {
}
}
}
- $fd = fopen("/usr/local/etc/quagga/ospfd.conf", "w");
+ safe_mkdir($quagga_config_base);
+ $fd = fopen("{$quagga_config_base}/ospfd.conf", "w");
// Write out the configuration file
fwrite($fd, $conffile);
@@ -212,31 +221,43 @@ function quagga_ospfd_install_conf() {
$zebraconffile .= "password {$ospfd_conf['password']}\n";
if ($ospfd_conf['logging'])
$zebraconffile .= "log syslog\n";
- $fd = fopen("/usr/local/etc/quagga/zebra.conf", "w");
+ $fd = fopen("{$quagga_config_base}/zebra.conf", "w");
fwrite($fd, $zebraconffile);
fclose($fd);
// Create rc.d file
$rc_file_stop = <<<EOF
-kill -9 `cat /var/run/quagga/zebra.pid`
-kill -9 `cat /var/run/quagga/ospfd.pid`
-rm -f /var/run/quagga/zebra.pid
-rm -f /var/run/quagga/ospfd.pid
+if [ -e /var/run/quagga/zebra.pid ]; then
+ kill -9 `cat /var/run/quagga/zebra.pid`
+ rm -f /var/run/quagga/zebra.pid
+fi
+if [ -e /var/run/quagga/ospfd.pid ]; then
+ kill -9 `cat /var/run/quagga/ospfd.pid`
+ rm -f /var/run/quagga/ospfd.pid
+fi
EOF;
$rc_file_start = <<<EOF
/bin/mkdir -p /var/run/quagga
/bin/mkdir -p /var/log/quagga
rm -f /var/run/quagga/zebra.pid
rm -f /var/run/quagga/ospfd.pid
-/usr/sbin/chown -R quagga:quagga /usr/local/etc/quagga/
+
+if [ `pw groupshow quagga 2>&1 | grep -c "pw: unknown group"` -gt 0 ]; then
+ /usr/sbin/pw groupadd {$pkg_group} -g {$pkg_gid}
+fi
+if [ `pw usershow quagga 2>&1 | grep -c "pw: no such user"` -gt 0 ]; then
+ /usr/sbin/pw useradd {$pkg_login} -u {$pkg_uid} -g {$pkg_gid} -c "{$pkg_gecos}" -d {$pkg_homedir} -s {$pkg_shell}
+fi
+
+/usr/sbin/chown -R quagga:quagga {$quagga_config_base}/
/usr/sbin/chown -R quagga:quagga /var/run/quagga
/usr/sbin/chown -R quagga:quagga /var/log/quagga
# Ensure no other copies of the daemons are running or it breaks.
-killall -9 zebra
-killall -9 ospfd
+killall -9 zebra 2>/dev/null
+killall -9 ospfd 2>/dev/null
sleep 1
-/usr/local/sbin/zebra -d -f /usr/local/etc/quagga/zebra.conf
-/usr/local/sbin/ospfd -d -f /usr/local/etc/quagga/ospfd.conf
+/usr/local/sbin/zebra -d -f {$quagga_config_base}/zebra.conf
+/usr/local/sbin/ospfd -d -f {$quagga_config_base}/ospfd.conf
EOF;
write_rcfile(array(
"file" => "quagga.sh",
@@ -247,8 +268,8 @@ EOF;
// Ensure files have correct permissions
exec("chmod a+rx /usr/local/etc/rc.d/quagga.sh");
- exec("chmod u+rw,go-rw /usr/local/etc/quagga/ospfd.conf");
- exec("chmod u+rw,go-rw /usr/local/etc/quagga/zebra.conf");
+ exec("chmod u+rw,go-rw {$quagga_config_base}/ospfd.conf");
+ exec("chmod u+rw,go-rw {$quagga_config_base}/zebra.conf");
// Kick off newly created rc.d script
exec("/usr/local/etc/rc.d/quagga.sh restart");
@@ -289,7 +310,7 @@ function quagga_ospfd_validate_input() {
// get the raw ospfd confi file for manual inspection/editing
function quagga_ospfd_get_raw_config() {
- return file_get_contents("/usr/local/etc/quagga/ospfd.conf");
+ return file_get_contents("{$quagga_config_base}/ospfd.conf");
}
// serialize the raw ospfd confi file to config.xml
diff --git a/config/quagga_ospfd/quagga_ospfd.xml b/config/quagga_ospfd/quagga_ospfd.xml
index 7989b855..d3b6861f 100644
--- a/config/quagga_ospfd/quagga_ospfd.xml
+++ b/config/quagga_ospfd/quagga_ospfd.xml
@@ -1,6 +1,6 @@
<packagegui>
<name>quagga_ospfd</name>
- <version>0.1</version>
+ <version>0.2</version>
<title>Services: Quagga OSPFd</title>
<include_file>/usr/local/pkg/quagga_ospfd.inc</include_file>
<aftersaveredirect>pkg_edit.php?xml=quagga_ospfd.xml&amp;id=0</aftersaveredirect>
diff --git a/config/quagga_ospfd/quaggactl b/config/quagga_ospfd/quaggactl
index 198a8411..f370b425 100644
--- a/config/quagga_ospfd/quaggactl
+++ b/config/quagga_ospfd/quaggactl
@@ -1,11 +1,12 @@
#!/bin/sh
RC_SCRIPT=/usr/local/etc/rc.d/quagga.sh
+QUAGGA_CONFIG_BASE=/var/etc/quagga
-ZEBRA_CONFIG=/usr/local/etc/quagga/zebra.conf
+ZEBRA_CONFIG=${QUAGGA_CONFIG_BASE}/zebra.conf
ZEBRA_PORT=2601
ZEBRA_PASSWORD=`/usr/bin/grep '^password ' ${ZEBRA_CONFIG} | /usr/bin/awk '{print $2};'`
-OSPF_CONFIG=/usr/local/etc/quagga/ospfd.conf
+OSPF_CONFIG=${QUAGGA_CONFIG_BASE}/ospfd.conf
OSPF_PORT=2604
OSPF_PASSWORD=`/usr/bin/grep '^password ' ${OSPF_CONFIG} | /usr/bin/awk '{print $2};'`
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index 487aba9b..739aa6a9 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -1463,7 +1463,7 @@
<name>Quagga OSPF</name>
<descr>OSPF routing protocol using Quagga -- WARNING! Installs files to the same place as OpenOSPFD. Installing both will break things.</descr>
<maintainer>jimp@pfsense.org</maintainer>
- <version>0.99.20.1 v0.1.1</version>
+ <version>0.99.20.1 v0.2</version>
<category>Routing</category>
<status>BETA</status>
<depends_on_package_base_url>http://files.pfsense.org/packages/8/All/</depends_on_package_base_url>
diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64
index 97eceb31..fa062b57 100644
--- a/pkg_config.8.xml.amd64
+++ b/pkg_config.8.xml.amd64
@@ -1413,7 +1413,7 @@
<name>Quagga OSPF</name>
<descr>OSPF routing protocol using Quagga -- WARNING! Installs files to the same place as OpenOSPFD. Installing both will break things.</descr>
<maintainer>jimp@pfsense.org</maintainer>
- <version>0.99.20.1 v0.1.1</version>
+ <version>0.99.20.1 v0.2</version>
<category>Routing</category>
<status>BETA</status>
<depends_on_package_base_url>http://files.pfsense.org/packages/amd64/8/All/</depends_on_package_base_url>