gtk-gnutella-upnp now runs as daemon to ensure connection stability
authorHarvie <tomas@mudrunka.cz>
Mon, 12 Jul 2010 03:28:49 +0000 (05:28 +0200)
committerHarvie <tomas@mudrunka.cz>
Mon, 12 Jul 2010 03:28:49 +0000 (05:28 +0200)
bash/gtk-gnutella-upnp/PKGBUILD
bash/gtk-gnutella-upnp/gtk-gnutella-upnp.sh

index a298cbd5715e0de5ee7b34ddf5ca802cb996869b..35d60e70cb3742903b861df95e3e81416f7ccd9d 100644 (file)
@@ -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() {
index d3e83470dd70041a1ed302e8089f5e9010f040cc..abf7e551ae4903f843f620790f178334b19595a5 100755 (executable)
@@ -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 $!;
This page took 0.147086 seconds and 4 git commands to generate.