|
@@ -0,0 +1,79 @@
|
|
1
|
+#!/bin/bash
|
|
2
|
+#
|
|
3
|
+# .---. . .
|
|
4
|
+# | | |
|
|
5
|
+# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
6
|
+# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
7
|
+# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
8
|
+#
|
|
9
|
+# Freedom in the Cloud
|
|
10
|
+#
|
|
11
|
+# Visit ipfs sites by entering a username
|
|
12
|
+#
|
|
13
|
+# License
|
|
14
|
+# =======
|
|
15
|
+#
|
|
16
|
+# This program is free software: you can redistribute it and/or modify
|
|
17
|
+# it under the terms of the GNU Affero General Public License as published by
|
|
18
|
+# the Free Software Foundation, either version 3 of the License, or
|
|
19
|
+# (at your option) any later version.
|
|
20
|
+#
|
|
21
|
+# This program is distributed in the hope that it will be useful,
|
|
22
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
24
|
+# GNU Affero General Public License for more details.
|
|
25
|
+#
|
|
26
|
+# You should have received a copy of the GNU Affero General Public License
|
|
27
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
28
|
+
|
|
29
|
+PROJECT_NAME='freedombone'
|
|
30
|
+
|
|
31
|
+export TEXTDOMAIN=${PROJECT_NAME}-mesh-visit-site
|
|
32
|
+export TEXTDOMAINDIR="/usr/share/locale"
|
|
33
|
+
|
|
34
|
+IPFS_URL='http://127.0.0.1:8080/ipns'
|
|
35
|
+
|
|
36
|
+# The browser application to use
|
|
37
|
+BROWSER=iceweasel
|
|
38
|
+
|
|
39
|
+IPFS_USERS_FILE=/home/$USER/.ipfs-users
|
|
40
|
+if [ ! -f $IPFS_USERS_FILE ]; then
|
|
41
|
+ exit 0
|
|
42
|
+fi
|
|
43
|
+USERS_FILE=/home/$USER/Users.txt
|
|
44
|
+if [ ! -f $USERS_FILE ]; then
|
|
45
|
+ exit 0
|
|
46
|
+fi
|
|
47
|
+
|
|
48
|
+data=$(tempfile 2>/dev/null)
|
|
49
|
+trap "rm -f $data" 0 1 2 5 15
|
|
50
|
+dialog --title $"Visit IPFS site" \
|
|
51
|
+ --backtitle $"Freedombone mesh" \
|
|
52
|
+ --inputbox $"Enter the username for the site you wish to visit" 8 60 2>$data
|
|
53
|
+sel=$?
|
|
54
|
+case $sel in
|
|
55
|
+ 0)
|
|
56
|
+ TOX_USERNAME=$(<$data)
|
|
57
|
+ if [ ${#TOX_USERNAME} -gt 0 ]; then
|
|
58
|
+ if ! grep -q "$TOX_USERNAME" $USERS_FILE; then
|
|
59
|
+ dialog --title $"Visit IPFS site" \
|
|
60
|
+ --backtitle $"Freedombone mesh" \
|
|
61
|
+ --msgbox $"The user '$TOX_USERNAME' was not found on the mesh" 8 60
|
|
62
|
+ exit 2
|
|
63
|
+ fi
|
|
64
|
+ TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME" | head -n 1 | awk -F ' ' '{print $2}')
|
|
65
|
+ if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
|
|
66
|
+ dialog --title $"Visit IPFS site" \
|
|
67
|
+ --backtitle $"Freedombone mesh" \
|
|
68
|
+ --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME'" 8 60
|
|
69
|
+ exit 3
|
|
70
|
+ fi
|
|
71
|
+ IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
|
|
72
|
+ $BROWSER $IPFS_FULL_URL
|
|
73
|
+ else
|
|
74
|
+ exit 1
|
|
75
|
+ fi
|
|
76
|
+ ;;
|
|
77
|
+esac
|
|
78
|
+
|
|
79
|
+exit 0
|