From 7a45c938413ae2b636f3caf05298b5538ecf1f66 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Wed, 17 Feb 2010 23:51:00 +0000 Subject: New Anytun 0.3.3 gentoo package --- gentoo-linux/net-misc/anytun/anytun-0.3.3.ebuild | 79 +++++++++++ .../net-misc/anytun/files/anytun-0.3.3.init | 155 +++++++++++++++++++++ .../net-misc/uanytun/files/uanytun-0.3.3.init | 88 ++++++++++++ gentoo-linux/net-misc/uanytun/uanytun-0.3.3.ebuild | 71 ++++++++++ 4 files changed, 393 insertions(+) create mode 100644 gentoo-linux/net-misc/anytun/anytun-0.3.3.ebuild create mode 100755 gentoo-linux/net-misc/anytun/files/anytun-0.3.3.init create mode 100755 gentoo-linux/net-misc/uanytun/files/uanytun-0.3.3.init create mode 100644 gentoo-linux/net-misc/uanytun/uanytun-0.3.3.ebuild diff --git a/gentoo-linux/net-misc/anytun/anytun-0.3.3.ebuild b/gentoo-linux/net-misc/anytun/anytun-0.3.3.ebuild new file mode 100644 index 0000000..80ab9d3 --- /dev/null +++ b/gentoo-linux/net-misc/anytun/anytun-0.3.3.ebuild @@ -0,0 +1,79 @@ +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +inherit eutils + +DESCRIPTION="VPN daemon using Secure Anycast Tunneling" +HOMEPAGE="http://anytun.org/" +SRC_URI="http://anytun.org/download/${P}.tar.gz" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="examples gcrypt" + +RDEPEND=">=dev-libs/boost-1.35 + gcrypt? ( dev-libs/libgcrypt ) + !gcrypt? ( dev-libs/openssl )" +DEPEND="${RDEPEND} + app-text/asciidoc" + +S=${S}/src + +src_compile() { + local myconf + use gcrypt || myconf="--use-ssl-crypto" + use examples\ + && myconf="${myconf} --examplesdir=/usr/share/doc/${PF}/examples/etc" \ + || myconf="${myconf} --no-examples" + econf --ebuild-compat ${myconf} + + einfo "Building executables" + emake || die "make failed" + + einfo "Building manpages" + emake manpage || die "failed building manpages" +} + +src_install() { + emake DESTDIR="${D}" install || die "make install failed" + rm -Rf "${D}"/etc/init.d + #as long as README just contains path to examples, only install it with examples + use examples || rm -f "${D}"/etc/${PN}/README + keepdir /var/run/anytun || die "failed to mkdir" + keepdir /var/run/anytun-controld || die "failed to mkdir" + + newinitd "${FILESDIR}/${PN}-0.3.3.init" ${PN} || die "failed to copy/install initrd script" + + cd ../ + dodoc AUTHORS ChangeLog README || die "failed to install docs" + + #forgotten in current upstream package + #insinto /usr/share/${P}/wireshark-lua/ + #doins wireshark-lua/satp.lua || die "failed to install wireshark-lua contrib script" +} + +pkg_config() { + [ ! -d "${ROOT}"/usr/share/doc/${PF}/examples/etc/${PN} ] && \ + die "can't copy example configs since examples were not installed (reemerge with USE='examples')" + for example in autostart server client1 client2 client3 p2p-a p2p-b; do + [ -e "${ROOT}"/etc/${PN}/${example} ] && die "${ROOT}/etc/${PN}/${example} already present, rm -R it first" + done + cp -rv "${ROOT}"/usr/share/doc/${PF}/examples/etc/${PN} "${ROOT}"/etc/ || die "failed to copy examples" +} + +pkg_postinst() { + enewgroup anytun + enewuser anytun -1 -1 /var/run/anytun anytun + elog "Please refer to the README file regarding the syntax of the /etc/${PN}/" + elog "configuration files or see examples provided with the package" + elog "You can use gentoo-style ${PN}.{VPN} initrd scripts to start " + elog "VPNs separately. Just symlink to the initscript, e.g.:" + elog "# ln -s /etc/init.d/${PN} /etc/init.d/${PN}.client1" + elog + elog "You can disect anytun traffic using wireshark by plugging the script" + elog "satp.lua into wireshark. Get it here:" + elog " http://svn.anytun.org/anytun-common/trunk/wireshark-lua/satp.lua" + #elog " /usr/share/${P}/wireshark-lua/satp.lua into wireshark" +} diff --git a/gentoo-linux/net-misc/anytun/files/anytun-0.3.3.init b/gentoo-linux/net-misc/anytun/files/anytun-0.3.3.init new file mode 100755 index 0000000..7a61b11 --- /dev/null +++ b/gentoo-linux/net-misc/anytun/files/anytun-0.3.3.init @@ -0,0 +1,155 @@ +#!/sbin/runscript +# Distributed under the terms of the GNU General Public License v3 +# Written by Bernhard Tittelbach based on examples from Gentoo, openvpn and anytun debian init.rd script + +opts="${opts} reload" +depend() { + need net + use dns + after bootmisc +} + +DAEMON=/usr/sbin/anytun +ANYTUNCONFIG=/usr/bin/anytun-config +CONTROLDAEMON=/usr/bin/anytun-controld +NAME=anytun +DESC=anytun +CONFIG_DIR=/etc/anytun +VARCONFIG_DIR=/var/run/anytun-controld +VARRUN_DIR=/var/run/anytun + +VPN=${SVCNAME#*.} +[ "$VPN" = "$SVCNAME" ] && VPN="" + +# Include anytun defaults if available +if [ -f /etc/conf.d/anytun ] ; then + . /etc/conf.d/anytun +fi + +test -x $DAEMON || exit 1 + + +start_vpn () { + if [ -f $CONFIG_DIR/$NAME/config ] ; then + POSTUP='' + test -f $CONFIG_DIR/$NAME/post-up.sh && POSTUP="-x $CONFIG_DIR/$NAME/post-up.sh" + CHROOTDIR=`grep '^chroot' < $CONFIG_DIR/$NAME/config | sed 's/chroot\s*//'` + if [ -n "$CHROOTDIR" ] ; then + test -d $CHROOTDIR || mkdir -p $CHROOTDIR + fi + test -d $VARRUN_DIR || mkdir -p $VARRUN_DIR + DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e '\w' | sed 's/^/--/' | tr '\n' ' '` + start-stop-daemon --start --pidfile $VARRUN_DIR/${NAME}.pid --exec $DAEMON -- --write-pid $VARRUN_DIR/${NAME}.pid $POSTUP \ + $DAEMONOPTS $DAEMONARG || return 1 + else + eerror "no config found" + return 1 + fi + start_configd + return 0 +} +stop_vpn () { + start-stop-daemon --stop --pidfile $PIDFILE --exec $DAEMON --oknodo + rm -f $PIDFILE + stop_configd +} + +start_configd () { + if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then + test -d $VARCONFIG_DIR || mkdir -p $VARCONFIG_DIR + chmod 700 $VARCONFIG_DIR + rm -f $VARCONFIG_DIR/$NAME 2>/dev/null + KDPRF=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'kd-prf' | sed 's/^/ --/' | xargs echo` + for CLIENTNAME in `ls $CONFIG_DIR/$NAME/conf.d`; do + DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/conf.d/$CLIENTNAME | grep -e '\w' | sed 's/^/ --/' | xargs echo` + $ANYTUNCONFIG $DAEMONARG $CIPHER $AUTHALGO $KDPRF >> $VARCONFIG_DIR/$NAME + done + CONTROLHOST=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'control-host' | sed 's/^/ --/'i | xargs echo` + start-stop-daemon --start --pidfile $VARCONFIG_DIR/${NAME}.pid --exec $CONTROLDAEMON \ + -- -f $VARCONFIG_DIR/$NAME $DAEMONOPTS $CONTROLHOST --write-pid $VARCONFIG_DIR/${NAME}.pid + fi +} +stop_configd () { + if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then + start-stop-daemon --stop --pidfile $VARCONFIG_DIR/${NAME}.pid --exec $CONTROLDAEMON --oknodo + rm -f $VARCONFIG_DIR/${NAME}.pid + fi +} + +start () { + if test -z "$VPN" ; then + if [ -f $CONFIG_DIR/autostart ] ; then + for NAME in `sed 's/#.*//' < $CONFIG_DIR/autostart | grep -e '\w'`; do + ebegin "Starting ${DESC} VPN: ${NAME}" + start_vpn + eend $? + done + else + eerror "no config found" + return 1; + fi + else + NAME="$VPN" + ebegin "Starting ${DESC} VPN: ${NAME}" + start_vpn + eend $? + fi +} + +stop () { + if test -z "$VPN" ; then + for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do + NAME=`basename $PIDFILE .pid` + ebegin "Stopping ${DESC} VPN: ${NAME}" + stop_vpn + eend $? + done + else + if test -e $VARRUN_DIR/${VPN}.pid ; then + PIDFILE=`ls $VARRUN_DIR/${VPN}.pid 2> /dev/null` + NAME=`basename $PIDFILE .pid` + ebegin "Stopping ${DESC} VPN: ${NAME}" + stop_vpn + eend $? + else + eerror " failure: No such tunnel is running: $VPN" + fi + fi +} + +reload () { + if test -z "$VPN" ; then + for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do + NAME=`basename $PIDFILE .pid` + if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then + ebegin "Reloading ${DESC} VPN: ${NAME}" + stop_vpn + start_vpn + eend $? + else + ebegin "Reloading ${DESC} VPN: ${NAME}" + stop_configd + start_configd + eend $? + fi + done + else + if test -e $VARRUN_DIR/${VPN}.pid ; then + PIDFILE=`ls $VARRUN_DIR/${VPN}.pid 2> /dev/null` + NAME=`basename $PIDFILE .pid` + if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then + ebegin "Reloading ${DESC} VPN: ${NAME}" + stop_vpn + start_vpn + eend $? + else + ebegin "Reloading ${DESC} VPN: ${NAME}" + stop_configd + start_configd + eend $? + fi + else + eerror "failure: No such tunnel is running: $VPN" + fi + fi +} diff --git a/gentoo-linux/net-misc/uanytun/files/uanytun-0.3.3.init b/gentoo-linux/net-misc/uanytun/files/uanytun-0.3.3.init new file mode 100755 index 0000000..31d9dc1 --- /dev/null +++ b/gentoo-linux/net-misc/uanytun/files/uanytun-0.3.3.init @@ -0,0 +1,88 @@ +#!/sbin/runscript +# Distributed under the terms of the GNU General Public License v3 +# Written by Bernhard Tittelbach based on examples from Gentoo, openvpn and uanytun debian initrd script + +depend() { + need net + use dns + after bootmisc +} + +DAEMON=/usr/sbin/uanytun +CONFIG_DIR=/etc/uanytun +NAME=uanytun +DESC=uanytun +VARRUN_PREFIX=/var/run/$NAME + +VPN=${SVCNAME#*.} +[ "$VPN" = "$SVCNAME" ] && VPN="" + +test -x $DAEMON || exit 1 + +# Include uanytun defaults if available +if [ -f /etc/conf.d/uanytun ] ; then + . /etc/conf.d/uanytun +fi + +start_vpn () { + if [ -f $CONFIG_DIR/$VPNNAME/config ] ; then + POSTUP='' + test -f $CONFIG_DIR/$VPNNAME/post-up.sh && POSTUP="-x $CONFIG_DIR/$VPNNAME/post-up.sh" + CHROOTDIR=`grep '^chroot' < $CONFIG_DIR/$VPNNAME/config | sed 's/chroot\s*//'` + if [ -n "$CHROOTDIR" ] ; then + test -d $CHROOTDIR || mkdir -p $CHROOTDIR + fi + DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$VPNNAME/config | grep -e '\w' | sed 's/^/--/' | tr '\n' ' '` + start-stop-daemon --start --pidfile $VARRUN_PREFIX.${VPNNAME}.pid --exec \ + $DAEMON -- --write-pid $VARRUN_PREFIX.${VPNNAME}.pid $POSTUP $DAEMONOPTS $DAEMONARG || return 1 + else + eerror "no config found" + return 1 + fi + return 0 +} +stop_vpn () { + start-stop-daemon --stop --pidfile $PIDFILE --exec $DAEMON --oknodo + rm -f $PIDFILE +} + +start () { + if test -z "$VPN" ; then + if [ -f $CONFIG_DIR/autostart ] ; then + for VPNNAME in `sed 's/#.*//' < $CONFIG_DIR/autostart | grep -e '\w'`; do + ebegin "Starting ${DESC} VPN: ${VPNNAME}" + start_vpn + eend $? + done + else + eerror "no config found" + return 1 + fi + else + VPNNAME="$VPN" + ebegin "Starting ${DESC} VPN: ${VPNNAME}" + start_vpn + eend $? + fi +} + +stop () { + if test -z "$VPN" ; then + for PIDFILE in `ls $VARRUN_PREFIX.*.pid 2> /dev/null`; do + VPNNAME=`basename $PIDFILE .pid` + ebegin "Stopping ${NAME} VPN: ${VPNNAME}" + stop_vpn + eend $? + done + else + if test -e $VARRUN_PREFIX.${VPN}.pid ; then + PIDFILE=`ls $VARRUN_PREFIX.${VPN}.pid 2> /dev/null` + VPNNAME=`basename $PIDFILE .pid` + ebegin "Stopping ${NAME} VPN: ${VPNNAME}" + stop_vpn + eend $? + else + eerror " failure: No such tunnel is running: $VPN" + fi + fi +} diff --git a/gentoo-linux/net-misc/uanytun/uanytun-0.3.3.ebuild b/gentoo-linux/net-misc/uanytun/uanytun-0.3.3.ebuild new file mode 100644 index 0000000..0d910cc --- /dev/null +++ b/gentoo-linux/net-misc/uanytun/uanytun-0.3.3.ebuild @@ -0,0 +1,71 @@ +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +inherit eutils + +DESCRIPTION="Tiny VPN daemon using Secure Anycast Tunneling" +HOMEPAGE="http://anytun.org/" +SRC_URI="http://anytun.org/download/${P}.tar.gz" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="examples gcrypt" + +RDEPEND="gcrypt? ( dev-libs/libgcrypt ) + !gcrypt? ( dev-libs/openssl )" +DEPEND="${RDEPEND} + app-text/asciidoc" + +S=${S}/src + +src_compile() { + local myconf + use gcrypt || myconf="--use-ssl-crypto" + use examples\ + && myconf="${myconf} --examplesdir=/usr/share/doc/${PF}/examples/etc" \ + || myconf="${myconf} --no-examples" + econf --ebuild-compat ${myconf} + + einfo "Building executables" + emake || die "make failed" + + einfo "Building manpages" + emake manpage || die "failed building manpages" +} + +src_install() { + emake DESTDIR="${D}" install || die "make install failed" + rm -Rf "${D}"/etc/init.d + #as long as README just contains path to examples, only install it with examples + use examples || rm -f "${D}"/etc/${PN}/README + + newinitd "${FILESDIR}/${PN}-0.3.1.init" ${PN} || die "failed to copy/install initrd script" + + cd ../ + dodoc AUTHORS ChangeLog README || die "failed to install docs" + + #patch any examples to use user "antun" instad of "uanytun" + find "${D}"/usr/share/doc/${PF}/examples/etc/ -name "config" \ + -exec sed -i 's/\(username\|groupname\) uanytun$/\1 anytun/' {} \; +} + +pkg_config() { + [ ! -d "${ROOT}"/usr/share/doc/${PF}/examples/etc/${PN} ] && \ + die "can't copy example configs since examples were not installed (reemerge with USE='examples')" + for example in autostart client1 client2 client3 p2p-a p2p-b; do + [ -e "${ROOT}"/etc/${PN}/${example} ] && die "${ROOT}/etc/${PN}/${example} already present, rm -R it first" + done + cp -rv "${ROOT}"/usr/share/doc/${PF}/examples/etc/${PN} "${ROOT}"/etc/ || die "failed to copy examples" +} + +pkg_postinst() { + enewgroup anytun + enewuser anytun -1 -1 /var/run/ anytun + elog "Note that each VPN gets its own directory under /etc/${PN}/" + elog "(see examples provided with the package)" + elog "Use the following command to create gentoo-style" + elog "uanytun.{VPN} initrd scripts for each VPN" + elog "# ln -s /etc/init.d/${PN} /etc/init.d/${PN}.client1" +} -- cgit v1.2.3