diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/openbgpd/openbgpd.inc | 40 | ||||
-rw-r--r-- | packages/openbgpd/openbgpd_neighbors.xml | 36 |
2 files changed, 42 insertions, 34 deletions
diff --git a/packages/openbgpd/openbgpd.inc b/packages/openbgpd/openbgpd.inc index 14a9a28d..70b725c6 100644 --- a/packages/openbgpd/openbgpd.inc +++ b/packages/openbgpd/openbgpd.inc @@ -34,11 +34,13 @@ function openbgpd_install_conf() { conf_mount_rw(); - $openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0]; - $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row']; - $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config']; - $openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config']; - + if($config['installedpackages']['openbgpd']['config']) { + $openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0]; + $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row']; + $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config']; + $openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config']; + } + $fd = fopen("/usr/local/etc/bgpd.conf", "w"); $conffile = ""; @@ -70,14 +72,16 @@ function openbgpd_install_conf() { foreach($openbgpd_groups as $group) { $conffile .= "group \"{$group['name']}\" {\n"; $conffile .= " remote-as {$group['remoteas']}\n"; - foreach($openbgpd_neighbors as $neighbor) { - if($neighbor['groupname'] == $group['name']) { - $conffile .= " neighbor {$neighbor['neighbor']} {\n"; - $conffile .= " descr \"{$neighbor['descr']}\"\n"; - foreach($neighbor['row'] as $row) { - $conffile .= " {$row['paramaters']} {$row['parmvalue']} \n"; - } - $conffile .= " }\n"; + if(is_array($openbgpd_neighbors)) { + foreach($openbgpd_neighbors as $neighbor) { + if($neighbor['groupname'] == $group['name']) { + $conffile .= " neighbor {$neighbor['neighbor']} {\n"; + $conffile .= " descr \"{$neighbor['descr']}\"\n"; + foreach($neighbor['row'] as $row) { + $conffile .= " {$row['paramaters']} {$row['parmvalue']} \n"; + } + $conffile .= " }\n"; + } } } $conffile .= "}\n"; @@ -148,10 +152,12 @@ function deinstall_openbgpd() { function check_group_usage($groupname) { global $config, $g; - $openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0]; - $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row']; - $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config']; - $openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config']; + if($config['installedpackages']['openbgpd']['config']) { + $openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0]; + $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row']; + $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config']; + $openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config']; + } if(is_array($openbgpd_groups)) { foreach($openbgpd_groups as $group) { foreach($openbgpd_neighbors as $neighbor) { diff --git a/packages/openbgpd/openbgpd_neighbors.xml b/packages/openbgpd/openbgpd_neighbors.xml index c25d3b03..cc170c0b 100644 --- a/packages/openbgpd/openbgpd_neighbors.xml +++ b/packages/openbgpd/openbgpd_neighbors.xml @@ -146,24 +146,26 @@ <custom_php_command_before_form> $newoptions = array(); $new_groups = array(); - foreach($config['installedpackages']['openbgpdgroups']['config'] as $item) - $new_groups[] = $item['name']; - $counter = 0; - foreach($new_groups as $group) { - $newoptions['option'][$counter]['name'] = $group; - $newoptions['option'][$counter]['value'] = $group; - $counter++; - } - $newoptions['option'][$counter]['name'] = ""; - $newoptions['option'][$counter]['value'] = ""; - $pkg['fields']['field'][2]['options'] = $newoptions; - $counter = 0; - foreach($pkg['fields']['field'] as $field) { - if($field['name'] == "group") { - $foundgroupid = $counter; - echo "found it: $counter"; + if($config['installedpackages']['openbgpdgroups']['config']) { + foreach($config['installedpackages']['openbgpdgroups']['config'] as $item) + $new_groups[] = $item['name']; + $counter = 0; + foreach($new_groups as $group) { + $newoptions['option'][$counter]['name'] = $group; + $newoptions['option'][$counter]['value'] = $group; + $counter++; + } + $newoptions['option'][$counter]['name'] = ""; + $newoptions['option'][$counter]['value'] = ""; + $pkg['fields']['field'][2]['options'] = $newoptions; + $counter = 0; + foreach($pkg['fields']['field'] as $field) { + if($field['name'] == "group") { + $foundgroupid = $counter; + echo "found it: $counter"; + } + $counter++; } - $counter++; } </custom_php_command_before_form> <custom_php_deinstall_command> |