Project

General

Profile

Actions

Feature #8240

closed

code source bouton "Save" et "Apply change "

Added by Mehdi BENLAKHAL over 7 years ago. Updated over 7 years ago.

Status:
Bogus
Priority:
Very Low
Assignee:
-
Category:
Interfaces
Target version:
-
Start date:
12/27/2017
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:

Description

Bonjour,

je suis en train de modifier le fichier config.xml de pfsense depuis un script python pour ajouter des vlan's, interfaces, des rules ... etc. après la mise en place du nouveau fichier config.xml dans /cf/conf/ je supprime le /tmp/config.cache pour appliquer la modification. la seule chose manquante l'état de l'interface, il est toujours Down, après une clic sur le bouton "Save" dans le Gui de l'interface crée après sur "Apply change", je trouve son état est UP.
je demande si c'est possible de m'indiquer comment je puisse lancer le script ou le code php qui fait le sauvegarde et applique les changements effectuer, je trouve déjà une fonction dans le fichier interfaces.php :

+++++++++++++++++++++++++++++++++++++++++++++++++++++
$changes_applied = false;

if ($_POST['apply']) {
unset($input_errors);
if (!is_subsystem_dirty('interfaces')) {
$input_errors[] = gettext("The settings have already been applied!");
} else {
$retval = 0;
unlink_if_exists("{$g['tmp_path']}/config.cache");
clear_subsystem_dirty('interfaces');

if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
foreach ($toapplylist as $ifapply => $ifcfgo) {
if (isset($config['interfaces'][$ifapply]['enable'])) {
interface_bring_down($ifapply, false, $ifcfgo);
interface_configure($ifapply, true);
if ($config['interfaces'][$ifapply]['ipaddrv6'] == "track6") {
/* call interface_track6_configure with linkup true so
IPv6 IPs are added back. dhcp6c needs a HUP. Can't
just call interface_configure with linkup true as
that skips bridge membership addition.
/
$wancfg = $config['interfaces'][$ifapply];
interface_track6_configure($ifapply, $wancfg, true);
}
} else {
interface_bring_down($ifapply, true, $ifcfgo);
if (isset($config['dhcpd'][$ifapply]['enable']) ||
isset($config['dhcpdv6'][$ifapply]['enable'])) {
services_dhcpd_configure();
}
}
}
}
/
restart snmp so that it binds to correct address */
$retval |= services_snmpd_configure();
/* sync filter configuration */
setup_gateways_monitor();
clear_subsystem_dirty('interfaces');
$retval |= filter_configure();
enable_rrd_graphing();
$changes_applied = true;
if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) {
clear_subsystem_dirty('staticroutes');
}
}
@unlink("{$g['tmp_path']}/.interfaces.apply");
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

je ne sais pas si c'est la bonne fonction ou pas, malgré ça je ne connais pas la façon d'exécutions de ce code là.

J'attends vos conseils ou propositions ;)
Merci

Actions #1

Updated by Jim Pingle over 7 years ago

  • Status changed from New to Bogus
  • Priority changed from High to Very Low
  • Target version deleted (2.4.3)

Please post support or development questions on the forum, mailing list, or reddit.

The forum has a French board which is probably best suited for your question.

Actions #2

Updated by Mehdi BENLAKHAL over 7 years ago

Hey Jim,

Thanks for your quick answer, ok i will post my ask in the forum.

Have a nice day for all

Actions

Also available in: Atom PDF