commit 561a9c34da09fb783b53cc2dd9100b855febcad3 Author: zzz Date: Sun May 10 17:21:00 2020 -0400 0.1 diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..eca1d97 --- /dev/null +++ b/README.txt @@ -0,0 +1,63 @@ +i2psnark-launcher +ALPHA version 0.1 2020-05-10 +============================== + +This is a simple file and URL handler script that stuffs the magnet URL +or torrent file path into i2psnark. + +It also checks to see if i2p is running first, and starts it if not. + + + +SUPPORTED PLATFORMS +------------------- + +Linux Debian/Ubuntu type systems only. +I2P must be installed either as a debian package, +or as a manual install in $HOME/i2p. + +For best results, I2P dev build 0.9.45-18 or higher required. + +I2P dev build 0.9.45-18 or higher required for clicking on files. +magnet links will still work, but you have to click on the +'Add Torrent' header in i2psnark to get it to open up. + +Browser: It tries first the routerconsole.browser configuration in i2p, +then sensible-browser (it's a debian wrapper script), then firefox. + + +INSTALLATION +------------ + +Don't trust me, read the install.sh and i2psnark scripts before +installing them. + +If you want to test before running install.sh, +try './i2psnark foo' to see what it does. + +To install it, run './install.sh' +It will ask for your sudo password to put it in /usr/bin + + +USAGE +----- + +After installing it, clicking on a .torrent file in nautilus +will ask you if you want to open the file with i2psnark. + +In your browser, when you click on a magnet link or torrent file link, +it will ask you what application to open it with. +Browse to /usr/bin and select i2psnark. + +All the script does is copy the magnet link or path +to i2psnark "Add Torrent" form. + + +BUGS +---- + +Please report bugs and patches on zzz.i2p. + +If things go well maybe we'll add this to our installers and packages. + +zzz diff --git a/i2psnark b/i2psnark new file mode 100755 index 0000000..0bae9d0 --- /dev/null +++ b/i2psnark @@ -0,0 +1,79 @@ +#!/bin/sh +# +# handler for i2psnark torrent files and magnet links +# +# version 0.1 +# +# zzz 2020-05-10 +# +if [ $# -ne 1 ] +then + echo "usage: $0 link" + exit 1 +fi + +ARG="$1" +I2PURL=http://localhost:7657/ + +wget "$I2PURL" -o /dev/null -O /dev/null +if [ $? -ne 0 ] +then + # check local install + I2PROUTER="$HOME/i2p/i2prouter" + if [ ! -x "$I2PROUTER" ] + then + # check system install + I2PROUTER=i2prouter + type "$I2PROUTER" > /dev/null 2>&1 + if [ $? -ne 0 ] + then + echo "i2prouter is not installed" + exit 1 + fi + fi + "$I2PROUTER" status > /dev/null 2>&1 + if [ $? -ne 0 ] + then + echo "Starting I2P..." + "$I2PROUTER" start + # wait up to 5 minutes + i=0 + while [ $i -lt 60 ] + do + wget "$I2PURL" -o /dev/null -O /dev/null + if [ $? -ne 0 ] + then + echo "waiting for i2psnark..." + sleep 10 + break; + fi + echo "waiting for i2p..." + sleep 5 + true $((i++)) + done + else + echo "I2P running but console not up?" + exit 1 + fi +fi + +BROWSER=`grep '^routerconsole.browser=' "$HOME/.i2p/router.config" 2> /dev/null | cut -d '=' -f 2` +if [ "x$BROWSER" = "x" ] +then + BROWSER=sensible-browser + type "$BROWSER" > /dev/null 2>&1 + if [ $? -ne 0 ] + then + BROWSER=firefox + fi +fi + +wget "${I2PURL}i2psnark/" -o /dev/null -O /dev/null +if [ $? -ne 0 ] +then + echo "I2P is running but i2psnark is not, start it first" + "$BROWSER" "${I2PURL}configwebapps" + exit 1 +fi + +"$BROWSER" "${I2PURL}i2psnark/?nofilter_newURL=$ARG#add" diff --git a/i2psnark.desktop b/i2psnark.desktop new file mode 100644 index 0000000..dc7169b --- /dev/null +++ b/i2psnark.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Name=i2psnark +GenericName=BitTorrent Client +X-GNOME-FullName=i2psnark BitTorrent Client +Comment=Download and share files with i2psnark +Exec=i2psnark %u +Icon=i2psnark +Terminal=false +Type=Application +MimeType=application/x-bittorrent;x-scheme-handler/magnet; +Categories=Network;FileTransfer;P2P;GTK; +X-Ubuntu-Gettext-Domain=i2p +X-AppInstall-Keywords=torrent diff --git a/i2psnark.png b/i2psnark.png new file mode 100644 index 0000000..e8d7fb5 Binary files /dev/null and b/i2psnark.png differ diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..ca8da00 --- /dev/null +++ b/install.sh @@ -0,0 +1,11 @@ +#!/bin/sh -x +# +# install the i2psnark launcher +# + +# these are for the .torrent file association +cp i2psnark.desktop "$HOME/.local/share/applications/" +cp i2psnark.png "$HOME/.local/share/icons/hicolor/48x48/apps/" + +# this is the launcher script +sudo cp i2psnark /usr/bin