summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /net-misc/nstx/files/nstxcd.init
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'net-misc/nstx/files/nstxcd.init')
-rw-r--r--net-misc/nstx/files/nstxcd.init104
1 files changed, 104 insertions, 0 deletions
diff --git a/net-misc/nstx/files/nstxcd.init b/net-misc/nstx/files/nstxcd.init
new file mode 100644
index 000000000000..7315c72f4b93
--- /dev/null
+++ b/net-misc/nstx/files/nstxcd.init
@@ -0,0 +1,104 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# (Written by Phillip Berndt <phillip.berndt at gmail dot com>)
+# (Modified by Steven Brudenell <steven dot brudenell at gmail>)
+# $Id$
+
+depend() {
+ local iface
+
+ for iface in ${NEED_INTERFACES} ; do
+ need net.${iface}
+ done
+
+ # If the user set TUNTAP_INTERFACE, they probably have a net script
+ # configuring that interface. nstxcd is responsible for actually creating
+ # the stupid thing, so we need to run before the config.
+ if [ ! -z ${TUNTAP_INTERFACE} ] ; then
+ if [ -x /etc/init.d/net.${TUNTAP_INTERFACE} ] ; then
+ before net.${TUNTAP_INTERFACE}
+ fi
+ fi
+}
+
+loadtun() {
+ if [ ! -e /dev/net/tun ]
+ then
+ ebegin "Loading TUN/TAP kernel module"
+ modprobe -q tun
+ eend $?
+ fi
+
+ if [ ! -e /dev/net/tun ]
+ then
+ eend 1 "Failed to load TUN driver! (did you compile your kernel with TUN/TAP support?)"
+ return 1
+ fi
+
+ return 0
+}
+
+checkconfig() {
+ if [ -z "${DOMAIN}" ] ; then
+ eerror "DOMAIN must be set"
+ return 1
+ fi
+
+ [ -z "${TUNTAP_INTERFACE}" ] || NSTXCD_OPTS="${NSTXCD_OPTS} -I ${TUNTAP_INTERFACE}"
+ [ -z "${TUNTAP_DEVICE}" ] || NSTXCD_OPTS="${NSTXCD_OPTS} -d ${TUNTAP_DEVICE}"
+
+ case "${MODE}" in
+ TUN)
+ NSTXCD_OPTS="${NSTXCD_OPTS} -t"
+ ;;
+ TAP)
+ NSTXCD_OPTS="${NSTXCD_OPTS} -T"
+ ;;
+ *)
+ eerror "MODE must be either TUN or TAP"
+ return 1
+ ;;
+ esac
+
+ if [ -z "${DNS_SERVER}" ] ; then
+ DNS_SERVER=`awk '/^nameserver/{ print $2; exit; }' /etc/resolv.conf`
+
+ if [ -z "${DNS_SERVER}" ] ; then
+ eerror "DNS_SERVER not set, and couldn't determine a nameserver from /etc/resolv.conf"
+ return 1
+ fi
+ export DNS_SERVER
+ fi
+
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+
+ loadtun || return 1
+
+ ebegin "Starting nstxcd"
+
+ start-stop-daemon \
+ --start \
+ --background \
+ --make-pidfile \
+ --exec /usr/sbin/nstxcd \
+ --pidfile "/var/run/nstxcd.pid" \
+ -- ${NSTXCD_OPTS} ${DOMAIN} ${DNS_SERVER}
+
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping nstxcd"
+
+ start-stop-daemon \
+ --stop \
+ --exec /usr/sbin/nstxcd \
+ --pidfile "/var/run/nstxcd.pid"
+
+ eend $?
+}