From a21009e049861c565df948a0436d9d08d5bdb701 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 30 Nov 2020 17:33:17 +0000 Subject: [PATCH] Remove networking dhcp config (deprecated) --- ajax/networking/gen_int_config.php | 48 ----------------- ajax/networking/get_int_config.php | 23 -------- ajax/networking/save_int_config.php | 35 ------------ app/js/custom.js | 83 +++++------------------------ templates/networking.php | 6 --- 5 files changed, 14 insertions(+), 181 deletions(-) delete mode 100644 ajax/networking/gen_int_config.php delete mode 100644 ajax/networking/get_int_config.php delete mode 100644 ajax/networking/save_int_config.php diff --git a/ajax/networking/gen_int_config.php b/ajax/networking/gen_int_config.php deleted file mode 100644 index 4b3be680..00000000 --- a/ajax/networking/gen_int_config.php +++ /dev/null @@ -1,48 +0,0 @@ - $file) { - if ($index != "defaults") { - $cnfFile = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$file, false, INI_SCANNER_RAW); - if ($cnfFile['static'] === 'true') { - $strConfFile .= "#Static IP configured for ".$cnfFile['interface']."\n"; - $strConfFile .= "interface ".$cnfFile['interface']."\n"; - if (isset($cnfFile['metric'])) { - $strConfFile .= "metric ".$cnfFile['metric']."\n"; - } - $strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n"; - $strConfFile .= "static routers=".$cnfFile['routers']."\n"; - $strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n\n"; - } elseif ($cnfFile['static'] === 'false' && $cnfFile['failover'] === 'true') { - $strConfFile .= "#Failover static IP configured for ".$cnfFile['interface']."\n"; - $strConfFile .= "profile static_".$cnfFile['interface']."\n"; - $strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n"; - $strConfFile .= "static routers=".$cnfFile['routers']."\n"; - $strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n\n"; - $strConfFile .= "interface ".$cnfFile['interface']."\n"; - if (isset($cnfFile['metric'])) { - $strConfFile .= "metric ".$cnfFile['metric']."\n"; - } - $strConfFile .= "fallback static_".$cnfFile['interface']."\n\n"; - } else { - $strConfFile .= "#DHCP configured for ".pathinfo($file, PATHINFO_FILENAME)."\n\n"; - } - } - } - - if (file_put_contents(RASPI_CONFIG_NETWORKING.'/dhcpcd.conf', $strConfFile)) { - exec('sudo /bin/cp '.RASPI_CONFIG_NETWORKING.'/dhcpcd.conf '.RASPI_DHCPCD_CONFIG); - $output = ['return'=>0,'output'=>'Settings successfully applied']; - } else { - $output = ['return'=>2,'output'=>'Unable to write to apply settings']; - } - echo json_encode($output); -} diff --git a/ajax/networking/get_int_config.php b/ajax/networking/get_int_config.php deleted file mode 100644 index 70be083a..00000000 --- a/ajax/networking/get_int_config.php +++ /dev/null @@ -1,23 +0,0 @@ -1,'output'=>['intConfig'=>$intConfig]]; - echo json_encode($jsonData); - - // Todo - get dhcp lease information from `dhcpcd -U eth0` ? maybe ? -} else { - $jsonData = ['return'=>2,'output'=>['Error getting data']]; - echo json_encode($jsonData); -} diff --git a/ajax/networking/save_int_config.php b/ajax/networking/save_int_config.php deleted file mode 100644 index f2a3f7b4..00000000 --- a/ajax/networking/save_int_config.php +++ /dev/null @@ -1,35 +0,0 @@ -0,'output'=>['Successfully Updated Network Configuration']]; - } else { - $jsonData = ['return'=>1,'output'=>['Error saving network configuration to file']]; - } -} else { - $jsonData = ['return'=>2,'output'=>'Unable to detect interface']; -} - -echo json_encode($jsonData); diff --git a/app/js/custom.js b/app/js/custom.js index a7eaa3cc..ba394f9d 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -49,74 +49,6 @@ function setupTabs() { }); } -function loadCurrentSettings(strInterface) { - $.post('ajax/networking/get_int_config.php',{interface:strInterface},function(data){ - jsonData = JSON.parse(data); - $.each(jsonData['output'],function(i,v) { - var int = v['interface']; - $.each(v,function(i2,v2) { - switch(i2) { - case "static": - if(v2 == 'true') { - $('#'+int+'-static').click(); - $('#'+int+'-nofailover').click(); - } else { - $('#'+int+'-dhcp').click(); - } - break; - case "failover": - if(v2 === 'true') { - $('#'+int+'-failover').click(); - } else { - $('#'+int+'-nofailover').click(); - } - break; - case "ip_address": - var arrIPNetmask = v2.split('/'); - $('#'+int+'-ipaddress').val(arrIPNetmask[0]); - $('#'+int+'-netmask').val(createNetmaskAddr(arrIPNetmask[1])); - break; - case "routers": - $('#'+int+'-gateway').val(v2); - break; - case "domain_name_server": - svrsDNS = v2.split(" "); - $('#'+int+'-dnssvr').val(svrsDNS[0]); - $('#'+int+'-dnssvralt').val(svrsDNS[1]); - break; - } - }); - }); - }); -} - -function saveNetworkSettings(int) { - var frmInt = $('#frm-'+int).find(':input'); - var arrFormData = {}; - $.each(frmInt,function(i3,v3){ - if($(v3).attr('type') == 'radio') { - arrFormData[$(v3).attr('id')] = $(v3).prop('checked'); - } else { - arrFormData[$(v3).attr('id')] = $(v3).val(); - } - }); - arrFormData['interface'] = int; - $.post('ajax/networking/save_int_config.php',arrFormData,function(data){ - var jsonData = JSON.parse(data); - $('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output'])); - }); -} - -function applyNetworkSettings() { - var int = $(this).data('int'); - arrFormData = {}; - arrFormData['generate'] = ''; - $.post('ajax/networking/gen_int_config.php',arrFormData,function(data){ - var jsonData = JSON.parse(data); - $('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output'])); - }); -} - $(document).on("click", ".js-add-dhcp-static-lease", function(e) { e.preventDefault(); var container = $(".js-new-dhcp-static-lease"); @@ -240,6 +172,10 @@ function loadWifiStations(refresh) { } $(".js-reload-wifi-stations").on("click", loadWifiStations(true)); +/* +Populates the DHCP server form fields +Option toggles are set dynamically depending on the loaded configuration +*/ function loadInterfaceDHCPSelect() { var iface = $('#cbxdhcpiface').val(); $.get('ajax/networking/get_netcfg.php?iface='+iface,function(data){ @@ -258,6 +194,7 @@ function loadInterfaceDHCPSelect() { $('#no-resolv')[0].checked = jsonData.upstreamServersEnabled; $('#cbxdhcpupstreamserver').val(jsonData.upstreamServers[0]); $('#txtmetric').val(jsonData.Metric); + if (jsonData.StaticIP !== null && jsonData.StaticIP !== '' && !jsonData.FallbackEnabled) { $('#chkstatic').closest('.btn').button('toggle'); $('#chkstatic').closest('.btn').button('toggle').blur(); @@ -269,15 +206,23 @@ function loadInterfaceDHCPSelect() { $('#chkdhcp').blur(); $('#chkfallback').prop('disabled', false); } - if (jsonData.FallbackEnabled) { + if (jsonData.FallbackEnabled || $('#chkdhcp').is(':checked')) { $('#dhcp-iface').prop('disabled', true); } }); } function setDHCPToggles(state) { + if ($('#chkfallback').is(':checked') && state) { + $('#chkfallback').prop('checked', state); + } + if ($('#dhcp-iface').is(':checked') && !state) { + $('#dhcp-iface').prop('checked', state); + } + $('#chkfallback').prop('disabled', state); $('#dhcp-iface').prop('disabled', !state); + //$('#dhcp-iface').prop('checked', state); } function loadChannel() { diff --git a/templates/networking.php b/templates/networking.php index 3d229c9e..bbcb84c5 100755 --- a/templates/networking.php +++ b/templates/networking.php @@ -18,12 +18,6 @@ // defaults to false $bridgedEnabled = $arrHostapdConf['BridgedEnable']; ?> - - - - - -