<packagegui>
	<name>freeradiussettings</name>
	<title>FreeRADIUS: Settings</title>
	<aftersaveredirect>pkg_edit.php?xml=freeradiussettings.xml&amp;id=0</aftersaveredirect>
	<tabs>
                <tab>
                        <text>Users</text>
                        <url>/pkg.php?xml=freeradius.xml</url>
                </tab>
                <tab>
                        <text>Clients</text>
                        <url>/pkg.php?xml=freeradiusclients.xml</url>
                </tab>
                <tab>
                        <text>Settings</text>
                        <url>/pkg_edit.php?xml=freeradiussettings.xml&amp;id=0</url>
			<active/>
                </tab>
        </tabs>
	<configpath>installedpackages->package->$packagename->configuration->settings</configpath>
	<fields>
		<field>
			<fielddescr>Listening Interface(s)</fielddescr>
			<fieldname>interface</fieldname>
			<description>Enter the desired listening interface here</description>
			<type>interfaces_selection</type>
		</field>
		<field>
			<fielddescr>Port</fielddescr>
			<fieldname>port</fieldname>
			<description>Enter the desired port here (default 1812)</description>
			<type>input</type>
		</field>
	</fields>
	<custom_php_command_before_form>
	function sync_package()	{
		global $config;
		$fout = fopen("/usr/local/etc/raddb/radiusd.conf.dynamic","w");
		$int = $config['installedpackages']['freeradiussettings']['config']['0']['interface'];
		$int_ip = find_interface_ip($int);
		$port = $config['installedpackages']['freeradiussettings']['config'][0]['port'];
		fwrite($fout, "{\nipaddr = " . $int_ip);
		if($port != "") {
		fwrite($fout, "port = " . $port . "\n");
		} else {
		fwrite($fout, "port = 0\n");
		}
		fwrite($fout, "type = auth\n}\n\n");
		fwrite($fout, "{\nipaddr = 127.0.0.1\nport = 0\ntype = auth\n}\n\n");
		fclose($fout);
		}
	mwexec("killall -HUP radiusd");
	mwexec("/usr/local/etc/rc.d/radiusd");
	sync_package();
	</custom_php_command_before_form>
	<custom_add_php_command>
		sync_package();
	</custom_add_php_command>
</packagegui>