summaryrefslogtreecommitdiffstats
path: root/net-p2p/uhub
diff options
context:
space:
mode:
authoramdmi3 <amdmi3@FreeBSD.org>2009-11-11 16:43:59 +0000
committeramdmi3 <amdmi3@FreeBSD.org>2009-11-11 16:43:59 +0000
commitabf0d438032d7509655ce5cb5b8746774fc52fcd (patch)
tree3679b4ac6ba3fea14584c65cc56d8baeb8724e90 /net-p2p/uhub
parent083e28ce54285d7e79999ffc5ae9714a096d12b0 (diff)
downloadFreeBSD-ports-abf0d438032d7509655ce5cb5b8746774fc52fcd.zip
FreeBSD-ports-abf0d438032d7509655ce5cb5b8746774fc52fcd.tar.gz
uHub is a high performance peer-to-peer hub for the ADC network.
Its low memory footprint allows it to handle several thousand users on high-end servers, or a small private hub on embedded hardware. WWW: http://www.extatic.org/uhub/ PR: 139670 Submitted by: Dmitry Yashin <yashin.dm@gmail.com>
Diffstat (limited to 'net-p2p/uhub')
-rw-r--r--net-p2p/uhub/Makefile37
-rw-r--r--net-p2p/uhub/distinfo3
-rw-r--r--net-p2p/uhub/files/patch-GNUmakefile35
-rw-r--r--net-p2p/uhub/files/patch-main.c_add_pid91
-rw-r--r--net-p2p/uhub/files/uhub.sh.in55
-rw-r--r--net-p2p/uhub/pkg-descr5
-rw-r--r--net-p2p/uhub/pkg-plist11
7 files changed, 237 insertions, 0 deletions
diff --git a/net-p2p/uhub/Makefile b/net-p2p/uhub/Makefile
new file mode 100644
index 0000000..a7139bb
--- /dev/null
+++ b/net-p2p/uhub/Makefile
@@ -0,0 +1,37 @@
+# New ports collection makefile for: uhub
+# Date created: 16 Oct 2009
+# Whom: Yashin Dmitry <yashin.dm@gmail.com>
+#
+# $FreeBSD$
+#
+
+PORTNAME= uhub
+PORTVERSION= 0.2.8
+CATEGORIES= net-p2p
+MASTER_SITES= http://www.extatic.org/downloads/uhub/
+DISTNAME= ${PORTNAME}-${PORTVERSION}-src
+
+MAINTAINER= yashin.dm@gmail.com
+COMMENT= High performance peer-to-peer hub for the ADC network
+
+LIB_DEPENDS= event-1.4:${PORTSDIR}/devel/libevent
+
+USE_PERL5= yes
+USE_GMAKE= yes
+
+USE_RC_SUBR= uhub.sh
+
+WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}
+MAKEFILE= ${WRKSRC}/GNUmakefile
+
+post-patch:
+ @${REINPLACE_CMD} -e 's|/etc/uhub/|${PREFIX}&|' ${WRKSRC}/doc/uhub.conf
+
+post-install:
+ @${INSTALL_DATA} ${WRKSRC}/doc/uhub.conf ${PREFIX}/etc/uhub/uhub.conf.sample
+ @${INSTALL_DATA} ${WRKSRC}/doc/users.conf ${PREFIX}/etc/uhub/users.conf.sample
+ @if [ -f ${PREFIX}/etc/uhub/motd.txt ]; then \
+ ${TOUCH} ${PREFIX}/etc/uhub/motd.txt.sample ; \
+ fi
+
+.include <bsd.port.mk>
diff --git a/net-p2p/uhub/distinfo b/net-p2p/uhub/distinfo
new file mode 100644
index 0000000..8dbc729
--- /dev/null
+++ b/net-p2p/uhub/distinfo
@@ -0,0 +1,3 @@
+MD5 (uhub-0.2.8-src.tar.gz) = 45d35d9757bc0a84297dec51520f725b
+SHA256 (uhub-0.2.8-src.tar.gz) = 4f205653a2c08b1a3e8dbd5ccee512c42d4b86825f2ee7cd21c53b5283256d2d
+SIZE (uhub-0.2.8-src.tar.gz) = 121873
diff --git a/net-p2p/uhub/files/patch-GNUmakefile b/net-p2p/uhub/files/patch-GNUmakefile
new file mode 100644
index 0000000..4dfcf84
--- /dev/null
+++ b/net-p2p/uhub/files/patch-GNUmakefile
@@ -0,0 +1,35 @@
+--- GNUmakefile.orig 2009-03-24 02:21:38.000000000 +0300
++++ GNUmakefile 2009-11-07 04:35:56.000000000 +0300
+@@ -3,7 +3,7 @@
+ ## Copyright (C) 2007-2008, Jan Vidar Krey <janvidar@extatic.org>
+ #
+
+-CC = gcc
++CC ?= gcc
+ LD := $(CC)
+ MV := mv
+ RANLIB := ranlib
+@@ -31,10 +31,10 @@
+ BIN_EXT ?= .exe
+ else
+ DESTDIR ?= /
+-UHUB_CONF_DIR ?= $(DESTDIR)/etc/uhub
+-UHUB_PREFIX ?= $(DESTDIR)/usr/local
+-CFLAGS += -I/usr/local/include
+-LDFLAGS += -L/usr/local/lib
++UHUB_PREFIX ?= $(PREFIX)
++UHUB_CONF_DIR ?= $(UHUB_PREFIX)/etc/uhub
++CFLAGS += -I$(LOCALBASE)/include
++LDFLAGS += -L$(LOCALBASE)/lib
+ BIN_EXT ?=
+ endif
+
+@@ -252,7 +252,7 @@
+ @if [ ! -d $(UHUB_CONF_DIR) ]; then echo Creating $(UHUB_CONF_DIR); mkdir -p $(UHUB_CONF_DIR); fi
+ @if [ ! -f $(UHUB_CONF_DIR)/uhub.conf ]; then cp doc/uhub.conf $(UHUB_CONF_DIR); fi
+ @if [ ! -f $(UHUB_CONF_DIR)/users.conf ]; then cp doc/users.conf $(UHUB_CONF_DIR); fi
+- @touch $(UHUB_CONF_DIR)/motd.txt
++ @if [ ! -f $(UHUB_CONF_DIR)/motd.txt ]; then touch $(UHUB_CONF_DIR)/motd.txt; fi
+ @echo done.
+ endif
+
diff --git a/net-p2p/uhub/files/patch-main.c_add_pid b/net-p2p/uhub/files/patch-main.c_add_pid
new file mode 100644
index 0000000..835256e
--- /dev/null
+++ b/net-p2p/uhub/files/patch-main.c_add_pid
@@ -0,0 +1,91 @@
+--- src/main.c.orig 2009-11-06 11:02:57.000000000 +0300
++++ src/main.c 2009-11-06 11:15:45.000000000 +0300
+@@ -29,6 +29,7 @@
+ static const char* arg_gid = 0;
+ static const char* arg_config = 0;
+ static const char* arg_log = 0;
++static const char* arg_pid = 0;
+ static int arg_log_syslog = 0;
+
+
+@@ -214,6 +215,7 @@
+ #ifndef WIN32
+ " -u <user> Run as given user\n"
+ " -g <group> Run with given group permissions\n"
++ " -p <file> Store pid in file (process id)\n"
+ #endif
+ " -V Show version number.\n"
+ );
+@@ -225,7 +227,7 @@
+ void parse_command_line(int argc, char** argv)
+ {
+ int opt;
+- while ((opt = getopt(argc, argv, "vqfc:l:hu:g:VCsSL")) != -1)
++ while ((opt = getopt(argc, argv, "vqfc:l:hu:g:VCsSLp:")) != -1)
+ {
+ switch (opt)
+ {
+@@ -285,6 +287,10 @@
+ arg_gid = optarg;
+ break;
+
++ case 'p':
++ arg_pid = optarg;
++ break;
++
+ default:
+ print_usage(argv[0]);
+ break;
+@@ -386,6 +392,32 @@
+
+ return 0;
+ }
++
++int pidfile_create()
++{
++ if (arg_pid)
++ {
++ FILE* pidfile = fopen(arg_pid, "w");
++ if (!pidfile)
++ {
++ hub_log(log_fatal, "Unable to write pid file: %s\n", arg_pid);
++ return -1;
++ }
++ fprintf(pidfile, "%d", (int) getpid());
++ fclose(pidfile);
++ }
++ return 0;
++}
++
++int pidfile_destroy()
++{
++ if (arg_pid)
++ {
++ return unlink(arg_pid);
++ }
++ return 0;
++}
++
+ #endif /* WIN32 */
+
+
+@@ -421,11 +453,19 @@
+ }
+ }
+
++ if (pidfile_create() == -1)
++ return -1;
++
+ if (drop_privileges() == -1)
+ return -1;
+ #endif /* WIN32 */
+
+ ret = main_loop();
++
++#ifndef WIN32
++ pidfile_destroy();
++#endif
++
+ return ret;
+ }
+
diff --git a/net-p2p/uhub/files/uhub.sh.in b/net-p2p/uhub/files/uhub.sh.in
new file mode 100644
index 0000000..cdea6fd
--- /dev/null
+++ b/net-p2p/uhub/files/uhub.sh.in
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# PROVIDE: uhub
+# REQUIRE: DAEMON
+# BEFORE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf to enable uhub:
+#
+# uhub_enable (bool): Set it to "YES" to enable uhub
+# Default is "NO".
+# uhub_conf (path): Set full path to config file.
+# Default is "%%PREFIX%%/etc/uhub/uhub.conf".
+# uhub_pidfile (path): Set full path to pid file.
+# Default is "/var/run/uhub.pid".
+#
+
+. %%RC_SUBR%%
+
+name="uhub"
+rcvar=`set_rcvar`
+
+load_rc_config $name
+
+: ${uhub_enable="NO"}
+: ${uhub_conf="%%PREFIX%%/etc/uhub/uhub.conf"}
+: ${uhub_pidfile="/var/run/${name}.pid"}
+
+command=%%PREFIX%%/bin/uhub
+command_args="-fq -c ${uhub_conf} -p ${uhub_pidfile}"
+pidfile=${uhub_pidfile}
+required_files=${uhub_conf}
+stop_postcmd=stop_postcmd
+reload_precmd=reload_precmd
+reload_postcmd=reload_postcmd
+extra_commands="reload"
+
+stop_postcmd()
+{
+ rm -f ${pidfile}
+}
+
+reload_precmd()
+{
+ echo "Reload ${name} configuration."
+}
+
+reload_postcmd()
+{
+ kill -HUP `cat ${pidfile}`
+}
+
+run_rc_command "$1"
diff --git a/net-p2p/uhub/pkg-descr b/net-p2p/uhub/pkg-descr
new file mode 100644
index 0000000..5ae0846
--- /dev/null
+++ b/net-p2p/uhub/pkg-descr
@@ -0,0 +1,5 @@
+uHub is a high performance peer-to-peer hub for the ADC network.
+Its low memory footprint allows it to handle several thousand users
+on high-end servers, or a small private hub on embedded hardware.
+
+WWW: http://www.extatic.org/uhub/
diff --git a/net-p2p/uhub/pkg-plist b/net-p2p/uhub/pkg-plist
new file mode 100644
index 0000000..cd32cbd
--- /dev/null
+++ b/net-p2p/uhub/pkg-plist
@@ -0,0 +1,11 @@
+bin/uhub
+@unexec if cmp -s %D/etc/uhub/uhub.conf.sample %D/etc/uhub/uhub.conf; then rm -f %D/etc/uhub/uhub.conf; fi
+etc/uhub/uhub.conf.sample
+@exec if [ ! -f %D/etc/uhub/uhub.conf ] ; then cp -p %D/%F %B/uhub/uhub.conf; fi
+@unexec if cmp -s %D/etc/uhub/users.conf.sample %D/etc/uhub/users.conf; then rm -f %D/etc/uhub/users.conf; fi
+etc/uhub/users.conf.sample
+@exec if [ ! -f %D/etc/uhub/users.conf ] ; then cp -p %D/%F %B/uhub/users.conf; fi
+@unexec if cmp -s %D/etc/uhub/motd.txt.sample %D/etc/uhub/motd.txt; then rm -f %D/etc/uhub/motd.txt; fi
+etc/uhub/motd.txt.sample
+@exec if [ ! -f %D/etc/uhub/motd.txt ] ; then cp -p %D/%F %B/uhub/motd.txt; fi
+@dirrmtry etc/uhub
OpenPOWER on IntegriCloud