Browse Source
Updated sudoers to accomodate restarting dhcpcd to apply network settings.
Updated sudoers to accomodate restarting dhcpcd to apply network settings.
Updated installer to insert new lines Created files to generate / modify / save dhcpcd files and networking configurationpull/131/head
7 changed files with 125 additions and 44 deletions
-
42ajax/networking/gen_int_config.php
-
15ajax/networking/get_int_config.php
-
35ajax/networking/save_int_config.php
-
1includes/networking.php
-
14index.php
-
1installers/common.sh
-
61js/custom.js
@ -0,0 +1,42 @@ |
|||
<?php |
|||
session_start(); |
|||
include_once('../../includes/config.php'); |
|||
include_once('../../includes/functions.php'); |
|||
|
|||
if(isset($_POST['generate']) && isset($_POST['csrf_token']) && CSRFValidate()) { |
|||
$cnfNetworking = array_diff(scandir(RASPI_CONFIG_NETWORKING, 1),array('..','.')); |
|||
$cnfNetworking = array_combine($cnfNetworking,$cnfNetworking); |
|||
$strConfFile = ""; |
|||
foreach($cnfNetworking as $index=>$file) { |
|||
if($index != "defaults") { |
|||
$cnfFile = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$file); |
|||
if($cnfFile['static'] === 'true') { |
|||
$strConfFile .= "interface ".$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"; |
|||
} elseif($cnfFile['static'] === 'false' && $cnfFile['failover'] === 'true') { |
|||
$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"; |
|||
$strConfFile .= "fallback static_".$cnfFile['interface']."\n\n"; |
|||
} else { |
|||
$strConfFile .= "#DHCP configured for ".$cnfFile['interface']."\n\n"; |
|||
} |
|||
} else { |
|||
$strConfFile .= file_get_contents(RASPI_CONFIG_NETWORKING.'/'.$index)."\n\n"; |
|||
} |
|||
} |
|||
|
|||
if(file_put_contents(RASPI_CONFIG_NETWORKING.'/dhcpcd.conf',$strConfFile)) { |
|||
exec('sudo /bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf'); |
|||
$output = ['return'=>0,'output'=>'Settings successfully applied']; |
|||
} else { |
|||
$output = ['return'=>2,'output'=>'Unable to write to apply settings']; |
|||
} |
|||
echo json_encode($output); |
|||
} |
|||
|
|||
?>
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue