summaryrefslogtreecommitdiff
path: root/security/hamachi/files/hamachi.in
diff options
context:
space:
mode:
Diffstat (limited to 'security/hamachi/files/hamachi.in')
-rw-r--r--security/hamachi/files/hamachi.in65
1 files changed, 65 insertions, 0 deletions
diff --git a/security/hamachi/files/hamachi.in b/security/hamachi/files/hamachi.in
new file mode 100644
index 000000000000..99e6877c70bd
--- /dev/null
+++ b/security/hamachi/files/hamachi.in
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# hamachi.sh - load tap driver and start Hamachi's tuncfg daemon
+#
+# (C) Copyright 2007 by Lapo Luchini
+# (loosely based on ports/security/openvpn/files/openvpn.sh.in 1.9 by Matthias Andree)
+#
+# $FreeBSD$
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
+# Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# PROVIDE: hamachi
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+#TODO: serve la KEYWORD:shutdown? che fa?
+
+# Note that we deliberately refrain from unloading drivers.
+
+. /etc/rc.subr
+
+name="hamachi"
+rcvar=hamachi_enable
+
+load_rc_config $name
+
+: ${hamachi_enable="NO"}
+
+command="%%PREFIX%%/sbin/hamachi-tuncfg"
+start_precmd="hamachi_precmd"
+
+hamachi_precmd() {
+ # FreeBSD <= 5.4 does not know kldstat's -m option
+ # FreeBSD >= 6.0 does not add debug.* sysctl information
+ # in the default build - we check both to keep things simple
+ if ! sysctl debug.if_tap_debug >/dev/null 2>&1 \
+ && ! kldstat -m if_tap >/dev/null 2>&1 ; then
+ if ! kldload if_tap ; then
+ warn "Could not load tap module."
+ return 1
+ fi
+ fi
+ if ! sysctl compat.linux >/dev/null 2>&1 \
+ && ! kldstat -m linuxelf >/dev/null 2>&1 ; then
+ if ! kldload linux ; then
+ warn "Could not load linux module."
+ return 1
+ fi
+ fi
+ return 0
+}
+
+run_rc_command "$1"