Skip to content

Commit

Permalink
FRR Copy Running to Saved option for the raw config page. Issue #9003
Browse files Browse the repository at this point in the history
  • Loading branch information
vktg committed Feb 23, 2020
1 parent 73c6840 commit 2a73135
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 6 deletions.
2 changes: 1 addition & 1 deletion net/pfSense-pkg-frr/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$

PORTNAME= pfSense-pkg-frr
PORTVERSION= 0.6.4
PORTVERSION= 0.6.5
CATEGORIES= net
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
154 changes: 149 additions & 5 deletions net/pfSense-pkg-frr/files/usr/local/pkg/frr/frr_global_raw.xml
Expand Up @@ -129,7 +129,7 @@
<type>info</type>
</field>
<field>
<fielddescr>zebra.conf</fielddescr>
<fielddescr>SAVED zebra.conf</fielddescr>
<fieldname>zebra</fieldname>
<description>
<![CDATA[
Expand All @@ -143,7 +143,38 @@
<cols>65</cols>
</field>
<field>
<fielddescr>staticd.conf</fielddescr>
<fielddescr>RUNNING zebra.conf</fielddescr>
<fieldname>zebrarunning</fieldname>
<description>
<![CDATA[
<script>
var zebra = document.getElementById('zebra');
var zebrarunning = document.getElementById('zebrarunning');
function onCopyClick(elem1, elem2) {
elem1.value = elem2.value;
configCheck(elem1, elem2);
}
window.onload = configCheck(zebra, zebrarunning);
ospfd.addEventListener('keyup', function() { configCheck(zebra, zebrarunning)});
ospfdrunning.addEventListener('keyup', function() { configCheck(zebra, zebrarunning) });
</script>
]]>
<![CDATA[
<p><b>Note: This is the CURRENT RUNNING CONFIG from "/var/etc/frr/zebra.conf".<br />
Copy this text block to the "SAVED" block above to ensure configuration is saved.<br />
When finished copying, click "Save" at the bottom of the form.<br />
</b>
<button onclick='onCopyClick(zebra, zebrarunning); return false'>Copy Zebra Running to Saved</button>
</p>
]]>
</description>
<type>textarea</type>
<encoding>base64</encoding>
<rows>30</rows>
<cols>65</cols>
</field>
<field>
<fielddescr>SAVED staticd.conf</fielddescr>
<fieldname>staticd</fieldname>
<description>
<![CDATA[
Expand All @@ -157,7 +188,34 @@
<cols>65</cols>
</field>
<field>
<fielddescr>bgpd.conf</fielddescr>
<fielddescr>RUNNING staticd.conf</fielddescr>
<fieldname>staticdrunning</fieldname>
<description>
<![CDATA[
<script>
var staticd = document.getElementById('staticd');
var staticdrunning = document.getElementById('staticdrunning');
window.onload = configCheck(staticd, staticdrunning);
zebra.addEventListener('keyup', function() { configCheck(staticd, staticdrunning)});
zebrarunning.addEventListener('keyup', function() { configCheck(staticd, staticdrunning) });
</script>
]]>
<![CDATA[
<p><b>Note: This is the CURRENT RUNNING CONFIG from "/var/etc/frr/staticd.conf".<br />
Copy this text block to the "SAVED" block above to ensure configuration is saved.<br />
When finished copying, click "Save" at the bottom of the form.<br />
</b>
<button onclick='onCopyClick(staticd, staticdrunning); return false'>Copy STATICd Running to Saved</button>
</p>
]]>
</description>
<type>textarea</type>
<encoding>base64</encoding>
<rows>30</rows>
<cols>65</cols>
</field>
<field>
<fielddescr>SAVED bgpd.conf</fielddescr>
<fieldname>bgpd</fieldname>
<description>
<![CDATA[
Expand All @@ -171,7 +229,34 @@
<cols>65</cols>
</field>
<field>
<fielddescr>ospfd.conf</fielddescr>
<fielddescr>RUNNING bgpd.conf</fielddescr>
<fieldname>bgpdrunning</fieldname>
<description>
<![CDATA[
<script>
var bgpd = document.getElementById('bgpd');
var bgpdrunning = document.getElementById('bgpdrunning');
window.onload = configCheck(bgpd, bgpdrunning);
zebra.addEventListener('keyup', function() { configCheck(bgpd, bgpdrunning)});
zebrarunning.addEventListener('keyup', function() { configCheck(bgpd, bgpdrunning) });
</script>
]]>
<![CDATA[
<p><b>Note: This is the CURRENT RUNNING CONFIG from "/var/etc/frr/bgpd.conf".<br />
Copy this text block to the "SAVED" block above to ensure configuration is saved.<br />
When finished copying, click "Save" at the bottom of the form.<br />
</b>
<button onclick='onCopyClick(bgpd, bgpdrunning); return false'>Copy BGPd Running to Saved</button>
</p>
]]>
</description>
<type>textarea</type>
<encoding>base64</encoding>
<rows>30</rows>
<cols>65</cols>
</field>
<field>
<fielddescr>SAVED ospfd.conf</fielddescr>
<fieldname>ospfd</fieldname>
<description>
<![CDATA[
Expand All @@ -185,7 +270,34 @@
<cols>65</cols>
</field>
<field>
<fielddescr>ospf6d.conf</fielddescr>
<fielddescr>RUNNING ospfd.conf</fielddescr>
<fieldname>ospfdrunning</fieldname>
<description>
<![CDATA[
<script>
var ospfd = document.getElementById('ospfd');
var ospfdrunning = document.getElementById('ospfdrunning');
window.onload = configCheck(ospfd, ospfdrunning);
zebra.addEventListener('keyup', function() { configCheck(ospfd, ospfdrunning)});
zebrarunning.addEventListener('keyup', function() { configCheck(ospfd, ospfdrunning) });
</script>
]]>
<![CDATA[
<p><b>Note: This is the CURRENT RUNNING CONFIG from "/var/etc/frr/ospfd.conf".<br />
Copy this text block to the "SAVED" block above to ensure configuration is saved.<br />
When finished copying, click "Save" at the bottom of the form.<br />
</b>
<button onclick='onCopyClick(ospfd, ospfdrunning); return false'>Copy OSPFd Running to Saved</button>
</p>
]]>
</description>
<type>textarea</type>
<encoding>base64</encoding>
<rows>30</rows>
<cols>65</cols>
</field>
<field>
<fielddescr>SAVED ospf6d.conf</fielddescr>
<fieldname>ospf6d</fieldname>
<description>
<![CDATA[
Expand All @@ -198,6 +310,38 @@
<rows>30</rows>
<cols>65</cols>
</field>
<field>
<fielddescr>RUNNING ospf6d.conf</fielddescr>
<fieldname>ospf6drunning</fieldname>
<description>
<![CDATA[
<script>
var ospf6d = document.getElementById('ospf6d');
var ospf6drunning = document.getElementById('ospf6drunning');
window.onload = configCheck(ospf6d, ospf6drunning);
zebra.addEventListener('keyup', function() { configCheck(ospf6d, ospf6drunning)});
zebrarunning.addEventListener('keyup', function() { configCheck(ospf6d, ospf6drunning) });
</script>
]]>
<![CDATA[
<p><b>Note: This is the CURRENT RUNNING CONFIG from "/var/etc/frr/ospf6d.conf".<br />
Copy this text block to the "SAVED" block above to ensure configuration is saved.<br />
When finished copying, click "Save" at the bottom of the form.<br />
</b>
<button onclick='onCopyClick(ospf6d, ospf6drunning); return false'>Copy OSPF6d Running to Saved</button>
</p>
<p>
<button onclick='onCopyClick(zebra, zebrarunning); onCopyClick(staticd, staticdrunning);
onCopyClick(bgpd, bgpdrunning); onCopyClick(ospfd, ospfdrunning);
onCopyClick(ospf6d, ospf6drunning); return false'>Copy All Running to Saved</button>
</p>
]]>
</description>
<type>textarea</type>
<encoding>base64</encoding>
<rows>30</rows>
<cols>65</cols>
</field>
</fields>
<custom_php_resync_config_command>
frr_generate_config();
Expand Down
Expand Up @@ -871,4 +871,5 @@ function frr_generate_config_bgp() {
$bgpdconffile .= frr_zebra_generate_routemaps();
}
file_put_contents("{$frr_config_base}/bgpd.conf", $bgpdconffile);
write_frr_running_config('bgpd');
}
Expand Up @@ -410,4 +410,5 @@ function frr_generate_config_ospf() {
}
safe_mkdir($frr_config_base);
file_put_contents("{$frr_config_base}/ospfd.conf", $conffile);
write_frr_running_config('ospfd');
}
Expand Up @@ -231,4 +231,5 @@ function frr_generate_config_ospf6() {
}
safe_mkdir($frr_config_base);
file_put_contents("{$frr_config_base}/ospf6d.conf", $conffile);
write_frr_running_config('ospf6d');
}
17 changes: 17 additions & 0 deletions net/pfSense-pkg-frr/files/usr/local/pkg/frr/inc/frr_zebra.inc
Expand Up @@ -620,6 +620,21 @@ function frr_zebra_generate_acceptfilters() {
return $noaccept;
}

/* The following function checks for the presence of and writes the contents of "/var/etc/frr/$module.conf" into the $module . "running" field within the config.xml file */
function write_frr_running_config($module) {
global $config, $frr_config_base;

$moduleRunningFile = "{$frr_config_base}/{$module}.conf";

if ( file_exists( $moduleRunningFile ) && ( filesize( $moduleRunningFile ) > 0 ) ) {
$moduleRunning = fopen( "$moduleRunningFile", "r" );
$config['installedpackages']['frrglobalraw']['config'][0][$module . "running"] = base64_encode( fread( $moduleRunning, filesize($moduleRunningFile) ));
} else {
$config['installedpackages']['frrglobalraw']['config'][0][$module . "running"] = base64_encode("!!!!! {$module}.conf does not exist or is empty.");
}
write_config( $desc = gettext("FRR: Wrote {$module}.conf startup-config to pfSense config file."), $backup = false, $write_config_only = true );
}

/* Make zebra config */
function frr_generate_config_zebra() {
global $config, $frr_config_base, $frr_auto_config_warning;
Expand Down Expand Up @@ -665,6 +680,7 @@ function frr_generate_config_zebra() {
$zebraconffile .= frr_zebra_generate_acceptfilters();
}
file_put_contents("{$frr_config_base}/zebra.conf", $zebraconffile);
write_frr_running_config('zebra');

if (isset($config['installedpackages']['frrglobalraw']['config'][0]['staticd']) &&
!empty($config['installedpackages']['frrglobalraw']['config'][0]['staticd'])) {
Expand All @@ -689,5 +705,6 @@ function frr_generate_config_zebra() {
}
if (!empty($staticdconffile) && ($staticdconffile != $frr_auto_config_warning)) {
file_put_contents("{$frr_config_base}/staticd.conf", $staticdconffile);
write_frr_running_config('staticd');
}
}

0 comments on commit 2a73135

Please sign in to comment.