From: Harvie Date: Mon, 12 Jul 2010 03:28:49 +0000 (+0200) Subject: gtk-gnutella-upnp now runs as daemon to ensure connection stability X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=0730b8e51643958087a9e3bf9730a11ad217c7f3;p=mirrors%2FPrograms.git gtk-gnutella-upnp now runs as daemon to ensure connection stability --- diff --git a/bash/gtk-gnutella-upnp/PKGBUILD b/bash/gtk-gnutella-upnp/PKGBUILD index a298cbd..35d60e7 100644 --- a/bash/gtk-gnutella-upnp/PKGBUILD +++ b/bash/gtk-gnutella-upnp/PKGBUILD @@ -3,7 +3,7 @@ # You can also contact me on http://blog.harvie.cz/ pkgname=gtk-gnutella-upnp -pkgver=1.0 +pkgver=1.1 pkgrel=1 pkgdesc="Small wrapper to automatically enable upnp port-forwarding for gtk-gnutella (doesn't work with port randomizing)" arch=('any') @@ -11,7 +11,7 @@ license=('GPL') url="http://gtk-gnutella.sourceforge.net/" depends=(gtk-gnutella miniupnpc) source=("gtk-gnutella-upnp.sh" "gtk-gnutella-upnp.desktop") -md5sums=('943e64632715b699b23c149787ead1a3' +md5sums=('a6c682400f582def99e99e0834d004d9' 'a80c6de2b89bd3f2d13dca3869c81c27') build() { diff --git a/bash/gtk-gnutella-upnp/gtk-gnutella-upnp.sh b/bash/gtk-gnutella-upnp/gtk-gnutella-upnp.sh index d3e8347..abf7e55 100755 --- a/bash/gtk-gnutella-upnp/gtk-gnutella-upnp.sh +++ b/bash/gtk-gnutella-upnp/gtk-gnutella-upnp.sh @@ -1,11 +1,29 @@ #!/bin/bash -upnpc="$(which upnpc)"; -gnet_port="$(grep listen_port ~/.gtk-gnutella/config_gnet | grep -o [0-9]* | head -n 1)"; -test "$gnet_port" -gt 1 || upnpc=true; -"$upnpc" -r "$gnet_port" TCP "$gnet_port" TCP; -"$upnpc" -r "$gnet_port" UDP "$gnet_port" UDP; -echo -e '\n======================= GTK-GNUTELLA =======================\n' -echo "listen_port=$gnet_port" -gtk-gnutella $@; -echo -e '\n===================== GTK-GNUTELLA-END =====================\n' -"$upnpc" -d "$gnet_port" TCP "$gnet_port" UDP; +gtk-gnutella-listen-port() { + grep listen_port ~/.gtk-gnutella/config_gnet | grep -o [0-9]* | head -n 1; +} + +gtk-gnutella-upnpc() { + upnpc="$(which upnpc)"; + test "$(echo $@ | grep -o [0-9]* | head -n 1)" -gt 1 || upnpc=true; + "$upnpc" $@ > ~/.gtk-gnutella/upnpc.log; +} + +gtk-gnutella-upnp-daemon() { + sleep 1; + echo ======= gtk-gnutella-upnp-daemon started ======== + while pgrep -x gtk-gnutella -u "$UID" >/dev/null; do + gnet_port="$(gtk-gnutella-listen-port)"; + gtk-gnutella-upnpc -r "$gnet_port" TCP "$gnet_port" UDP; + sleep 60; + done; + echo Shutting down gtk-gnutella-upnp-daemon... + gnet_port="$(gtk-gnutella-listen-port)"; + gtk-gnutella-upnpc -d "$gnet_port" TCP "$gnet_port" UDP; + echo ======= gtk-gnutella-upnp-daemon exited ======== +} + +gtk-gnutella-upnp-daemon & +gtk-gnutella $@; echo; +pkill -x sleep -P $!; +wait $!;