/dev/null"); rmdir_recursive("/usr/local/etc/tinc.old"); conf_mount_ro(); config_unlock(); } function tinc_status_1() { list($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizeb,$atime,$mtimeb,$ctime,$blksize,$blocks)=stat("/var/log/tinc.log"); exec("/usr/local/sbin/tincd --config=/usr/local/etc/tinc -kUSR1"); exec("tail -c +" . $sizeb . " /var/log/tinc.log | sed -e 's/.*tinc\[.*\]: //'",$result); $output=""; foreach($result as $line) { $output .= $line . "\n"; } return $output; } function tinc_status_2() { list($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizeb,$atime,$mtimeb,$ctime,$blksize,$blocks)=stat("/var/log/tinc.log"); exec("/usr/local/sbin/tincd --config=/usr/local/etc/tinc -kUSR2"); exec("tail -c +" . $sizeb . " /var/log/tinc.log | sed -e 's/.*tinc\[.*\]: //'",$result); $output=""; foreach($result as $line) { $output .= $line . "\n"; } return $output; } function tinc_install() { safe_mkdir("/usr/local/etc/tinc"); safe_mkdir("/usr/local/etc/tinc/hosts"); $_rcfile['file']='tinc.sh'; $_rcfile['start'].="/usr/local/sbin/tincd --config=/usr/local/etc/tinc\n\t"; $_rcfile['stop'].="/usr/local/sbin/tincd --kill \n\t"; write_rcfile($_rcfile); unlink_if_exists("/usr/local/etc/rc.d/tincd"); clear_log_file("/var/log/tinc.log"); conf_mount_rw(); config_lock(); /* 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"); write_config(); conf_mount_ro(); config_unlock(); } 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"); } ?>