WIP
This commit is contained in:
59
README.md
Normal file
59
README.md
Normal file
@ -0,0 +1,59 @@
|
||||
su3-launcher
|
||||
ALPHA version
|
||||
==============================
|
||||
|
||||
This is a simple file and URL handler script that stuffs the su3 URL
|
||||
or file path into the i2p console.
|
||||
|
||||
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 TBD or higher required.
|
||||
|
||||
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 i2psu3 scripts before
|
||||
installing them.
|
||||
|
||||
If you want to test before running install.sh,
|
||||
try './i2psu3 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 .su3 file in nautilus
|
||||
will ask you if you want to open the file with i2p.
|
||||
|
||||
In your browser, when you click on a .su3 file link,
|
||||
it will ask you what application to open it with.
|
||||
Browse to /usr/bin and select i2psu3.
|
||||
|
||||
All the script does is copy the link or path
|
||||
to a console form.
|
||||
|
||||
|
||||
BUGS
|
||||
----
|
||||
|
||||
Please report bugs and patches on zzz.i2p or http://git.idk.i2p/zzz/su3-launcher
|
||||
|
||||
If things go well maybe we'll add this to our installers and packages.
|
||||
|
||||
zzz
|
131
i2psu3
Executable file
131
i2psu3
Executable file
@ -0,0 +1,131 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# handler for i2p su3 files and links
|
||||
#
|
||||
# version
|
||||
#
|
||||
# zzz
|
||||
#
|
||||
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
|
||||
|
||||
if [ "${ARG##http://}" != "$ARG" -o "${ARG##https://}" != "$ARG" ]
|
||||
then
|
||||
#plugin?
|
||||
# TODO need generic su3 handler page
|
||||
PAGE="configplugin?pluginFile=$ARG#TODO"
|
||||
|
||||
else
|
||||
if [ ! \( -f "$ARG" -a -r "$ARG" \) ]
|
||||
then
|
||||
echo "Cannot open file $ARG"
|
||||
exit 1
|
||||
fi
|
||||
if [ "${ARG%%.su3}" = "$ARG" ]
|
||||
then
|
||||
echo "Not a .su3 file: $ARG"
|
||||
exit 1
|
||||
fi
|
||||
# get file type
|
||||
TYPE=`head -c 28 "$ARG" | tail -c 1 | hd | head -n 1 | cut -c11-12`
|
||||
if [ "x$TYPE" = "x" ]
|
||||
then
|
||||
echo "Not a .su3 file: $ARG"
|
||||
exit 1
|
||||
fi
|
||||
case "$TYPE" in
|
||||
01)
|
||||
#update
|
||||
PAGE=TODO
|
||||
;;
|
||||
|
||||
02)
|
||||
#plugin
|
||||
PAGE="configplugins?pluginFile=$ARG#TODO"
|
||||
;;
|
||||
|
||||
03)
|
||||
#reseed
|
||||
PAGE="configreseed?file=$ARG#TODO"
|
||||
;;
|
||||
|
||||
04)
|
||||
#news
|
||||
PAGE=TODO
|
||||
;;
|
||||
|
||||
05)
|
||||
#blocklist
|
||||
PAGE=TODO
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown su3 file type: $TYPE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
# escape URI params
|
||||
ARG=`echo "$ARG" | sed -e 's/?/%3F/g' | sed -e 's/&/%26/g'`
|
||||
"$BROWSER" "${I2PURL}${PAGE}"
|
12
i2psu3.desktop
Normal file
12
i2psu3.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Name=i2psu3
|
||||
GenericName=I2P su3 file handler
|
||||
X-GNOME-FullName=I2P su3 file handler
|
||||
Comment=Install update, reseed, and plugin files
|
||||
Exec=i2psu3 %u
|
||||
Icon=i2psu3
|
||||
Terminal=false
|
||||
Type=Application
|
||||
MimeType=application/x-i2p-su3;application/x-i2p-su3-update;application/x-i2p-su3-plugin;application/x-i2p-su3-reseed;application/x-i2p-su3-news;application/x-i2p-su3-blocklist;
|
||||
Categories=Network;
|
||||
X-Ubuntu-Gettext-Domain=i2p
|
BIN
i2psu3.png
Normal file
BIN
i2psu3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
47
i2psu3.xml
Normal file
47
i2psu3.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="application/x-i2p-su3">
|
||||
<sub-class-of type="application/x-i2p-su3"/>
|
||||
<comment>I2P router update file</comment>
|
||||
<glob pattern="*.su3"/>
|
||||
<magic priority="60">
|
||||
<match value="I2Psu3" type="string" offset="0"/>
|
||||
</magic>
|
||||
</mime-type>
|
||||
<!-- content-type is at offset 27; skip 21 bytes -->
|
||||
<mime-type type="application/x-i2p-su3-update">
|
||||
<sub-class-of type="application/x-i2p-su3"/>
|
||||
<comment>I2P router update file</comment>
|
||||
<magic priority="75">
|
||||
<match value="I2Psu3.....................\x01;" type="string" offset="0" mask="0xffffffffffff000000000000000000000000000000000000000000ff"/>
|
||||
</magic>
|
||||
</mime-type>
|
||||
<mime-type type="application/x-i2p-su3-plugin">
|
||||
<sub-class-of type="application/x-i2p-su3"/>
|
||||
<comment>I2P plugin install file</comment>
|
||||
<magic priority="75">
|
||||
<match value="I2Psu3.....................\x02;" type="string" offset="0" mask="0xffffffffffff000000000000000000000000000000000000000000ff"/>
|
||||
</magic>
|
||||
</mime-type>
|
||||
<mime-type type="application/x-i2p-su3-reseed">
|
||||
<sub-class-of type="application/x-i2p-su3"/>
|
||||
<comment>I2P reseed file</comment>
|
||||
<magic priority="75">
|
||||
<match value="I2Psu3.....................\x03;" type="string" offset="0" mask="0xffffffffffff000000000000000000000000000000000000000000ff"/>
|
||||
</magic>
|
||||
</mime-type>
|
||||
<mime-type type="application/x-i2p-su3-news">
|
||||
<sub-class-of type="application/x-i2p-su3"/>
|
||||
<comment>I2P news feed</comment>
|
||||
<magic priority="75">
|
||||
<match value="I2Psu3.....................\x04;" type="string" offset="0" mask="0xffffffffffff000000000000000000000000000000000000000000ff"/>
|
||||
</magic>
|
||||
</mime-type>
|
||||
<mime-type type="application/x-i2p-su3-blocklist">
|
||||
<sub-class-of type="application/x-i2p-su3"/>
|
||||
<comment>I2P blocklist feed</comment>
|
||||
<magic priority="75">
|
||||
<match value="I2Psu3.....................\x05;" type="string" offset="0" mask="0xffffffffffff000000000000000000000000000000000000000000ff"/>
|
||||
</magic>
|
||||
</mime-type>
|
||||
</mime-info>
|
12
install.sh
Executable file
12
install.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh -x
|
||||
#
|
||||
# install the i2psu3 launcher
|
||||
#
|
||||
|
||||
# these are for the .su3 file association
|
||||
cp i2psu3.desktop "$HOME/.local/share/applications/"
|
||||
cp i2psu3.png "$HOME/.local/share/icons/hicolor/48x48/apps/"
|
||||
cp i2psu3.xml "$HOME/.local/share/mime/packages/"
|
||||
|
||||
# this is the launcher script
|
||||
sudo cp i2psu3 /usr/bin
|
Reference in New Issue
Block a user