aboutsummaryrefslogtreecommitdiffstats
path: root/config/tinc/tinc.inc
diff options
context:
space:
mode:
authorapnar <jlukens@botch.com>2012-09-04 00:14:37 +0000
committerapnar <jlukens@botch.com>2012-09-04 00:14:37 +0000
commite732b03ead7f7e57b82738fb432f2f4b5dc8254a (patch)
treecb93e6727a2defeaaaa45649b248854bb9bfe373 /config/tinc/tinc.inc
parent4126868d030416f81720259b60c2b5cf5e8cb945 (diff)
downloadpfsense-packages-e732b03ead7f7e57b82738fb432f2f4b5dc8254a.tar.gz
pfsense-packages-e732b03ead7f7e57b82738fb432f2f4b5dc8254a.tar.bz2
pfsense-packages-e732b03ead7f7e57b82738fb432f2f4b5dc8254a.zip
Add interface group on install, remove it on uninstall, and add interfaces to it.
Diffstat (limited to 'config/tinc/tinc.inc')
-rw-r--r--config/tinc/tinc.inc46
1 files changed, 46 insertions, 0 deletions
diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc
index c191de5a..0881eeac 100644
--- a/config/tinc/tinc.inc
+++ b/config/tinc/tinc.inc
@@ -68,6 +68,7 @@ function tinc_save() {
else
{
$_output = "ifconfig \$INTERFACE " . $tincconf['localip'] . " netmask " . $tincconf['vpnnetmask'] . "\n";
+ $_output .= "ifconfig \$INTERFACE group tinc\n";
}
file_put_contents('/usr/local/etc/tinc/tinc-up',$_output);
chmod("/usr/local/etc/tinc/tinc-up", 0744);
@@ -155,6 +156,17 @@ function tinc_install() {
$GLOBALS['config']['interfaces'][$newifname]['if'] = "tun0";
*/
+ /* Create Interface Group */
+ if (!is_array($GLOBALS['config']['ifgroups']['ifgroupentry']))
+ $GLOBALS['config']['ifgroups']['ifgroupentry'] = array();
+
+ $a_ifgroups = &$GLOBALS['config']['ifgroups']['ifgroupentry'];
+ $ifgroupentry = array();
+ $ifgroupentry['members'] = '';
+ $ifgroupentry['descr'] = 'tinc mesh VPN interface group';
+ $ifgroupentry['ifname'] = 'tinc';
+ $a_ifgroups[] = $ifgroupentry;
+
/* XXX: Do not remove this. */
mwexec("/bin/rm -f /tmp/config.cache");
@@ -165,6 +177,40 @@ function tinc_install() {
}
function tinc_deinstall() {
+ /* Remove Interface Group */
+ conf_mount_rw();
+ config_lock();
+ if (!is_array($GLOBALS['config']['ifgroups']['ifgroupentry']))
+ $GLOBALS['config']['ifgroups']['ifgroupentry'] = array();
+
+ $a_ifgroups = &$GLOBALS['config']['ifgroups']['ifgroupentry'];
+
+ $myid=-1;
+ $i = 0;
+ foreach ($a_ifgroups as $ifgroupentry)
+ {
+ if($ifgroupentry['ifname']=='tinc')
+ {
+ $myid=$i;
+ break;
+ }
+ $i++;
+ }
+
+ if ($myid >= 0 && $a_ifgroups[$myid])
+ {
+ $members = explode(" ", $a_ifgroups[$_GET['id']]['members']);
+ foreach ($members as $ifs)
+ {
+ $realif = get_real_interface($ifs);
+ if ($realif)
+ mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$_GET['id']]['ifname']);
+ }
+ unset($a_ifgroups[$myid]);
+ mwexec("/bin/rm -f /tmp/config.cache");
+ write_config();
+ }
+
rmdir_recursive("/var/tmp/tinc");
rmdir_recursive("/usr/local/etc/tinc*");
unlink_if_exists("/usr/local/etc/rc.d/tinc.sh");