Project

General

Profile

« Previous | Next » 

Revision 3b010c68

Added by NOYB NOYB over 8 years ago

Vendor MAC Retention - Update

Only write if changed or missing.

Vast majority of reboots will not have a change so don't hit the file system with a needless write. RAM disk enabled systems will always write due to missing the file on boot up.

View differences:

src/etc/rc.bootup
190 190
if (mwexec("/bin/kenv -q pfSense.boot 2>/dev/null") != 0) {
191 191
	/* Collect vendor MAC address for all interfaces */
192 192
	$ifs = pfSense_interface_listget();
193
	unlink_if_exists("{$g['vardb_path']}/vendor_mac");
194 193
	foreach ($ifs as $if) {
195 194
		$if_details = pfSense_get_interface_addresses($if);
196 195
		if (isset($if_details['iftype']) &&
......
205 204

  
206 205
		$vendor_mac_arr[$if] = $if_details['macaddr'];
207 206
	}
208
	@file_put_contents("{$g['vardb_path']}/vendor_mac", json_encode($vendor_mac_arr));
209
	unset($ifs, $if, $vendor_mac_arr);
207
	$vendor_mac_arr_json = json_encode($vendor_mac_arr);
208
	if (@file_get_contents("{$g['vardb_path']}/vendor_mac") !== $vendor_mac_arr_json) {
209
		@file_put_contents("{$g['vardb_path']}/vendor_mac", $vendor_mac_arr_json);
210
	}
211
	unset($ifs, $if, $vendor_mac_arr, $vendor_mac_arr_json);
210 212
	mwexec("/bin/kenv pfSense.boot=1");
211 213
}
212 214

  

Also available in: Unified diff