Browse Source

Scuttlebot onion address

Bob Mottram 7 years ago
parent
commit
805f5e24c0
1 changed files with 64 additions and 3 deletions
  1. 64
    3
      src/freedombone-app-scuttlebot

+ 64
- 3
src/freedombone-app-scuttlebot View File

@@ -36,14 +36,42 @@ SHOW_ON_ABOUT=0
36 36
 SHOW_ICANN_ADDRESS_ON_ABOUT=0
37 37
 
38 38
 SCUTTLEBOT_VERSION='9.8.0'
39
+SCUTTLEBOT_PORT=8008
40
+SCUTTLEBOT_ONION_PORT=8118
39 41
 
40 42
 scuttlebot_variables=(MY_USERNAME
43
+                      DEFAULT_DOMAIN_NAME
41 44
                       SYSTEM_TYPE)
42 45
 
46
+function scuttlebot_create_invite {
47
+    invite_string=$(su -c "sbot invite.create 1" - scuttlebot | sed 's/"//g')
43 48
 
44
-#function configure_interactive_scuttlebot {
45
-#    echo -n ''
46
-#}
49
+    clear
50
+    echo -e '\n\nYour Scuttlebot invite code is:\n\n'${invite_string}'\n\n'
51
+    read -n1 -r -p $"Press any key to continue..." key
52
+}
53
+
54
+function configure_interactive_scuttlebot {
55
+    while true
56
+    do
57
+        data=$(tempfile 2>/dev/null)
58
+        trap "rm -f $data" 0 1 2 5 15
59
+        dialog --backtitle $"Freedombone Control Panel" \
60
+               --title $"Scuttlebot" \
61
+               --radiolist $"Choose an operation:" 10 50 2 \
62
+               1 $"Create an invite" off \
63
+               2 $"Exit" on 2> $data
64
+        sel=$?
65
+        case $sel in
66
+            1) return;;
67
+            255) return;;
68
+        esac
69
+        case $(cat $data) in
70
+            1) scuttlebot_create_invite;;
71
+            2) break;;
72
+        esac
73
+    done
74
+}
47 75
 
48 76
 function remove_user_scuttlebot {
49 77
     remove_username="$1"
@@ -138,6 +166,9 @@ function remove_scuttlebot {
138 166
     systemctl disable scuttlebot
139 167
     rm /etc/systemd/system/scuttlebot.service
140 168
 
169
+    function_check remove_onion_service
170
+    remove_onion_service scuttlebot ${SCUTTLEBOT_ONION_PORT}
171
+
141 172
     userdel -r scuttlebot
142 173
 
143 174
     if [ -d /etc/scuttlebot ]; then
@@ -192,6 +223,36 @@ function install_scuttlebot {
192 223
     systemctl daemon-reload
193 224
     systemctl start scuttlebot.service
194 225
 
226
+    sleep 3
227
+
228
+    SCUTTLEBOT_ONION_HOSTNAME=$(add_onion_service scuttlebot ${SCUTTLEBOT_PORT} ${SCUTTLEBOT_ONION_PORT})
229
+
230
+    if [ ! -d /etc/scuttlebot/.ssb ]; then
231
+        echo $'Scuttlebot config not generated'
232
+        exit 73528
233
+    fi
234
+
235
+    echo '{' > /etc/scuttlebot/.ssb/config
236
+    echo "  \"host\": \"${SCUTTLEBOT_ONION_HOSTNAME}\"," >> /etc/scuttlebot/.ssb/config
237
+    echo "  \"port\": ${SCUTTLEBOT_PORT}," >> /etc/scuttlebot/.ssb/config
238
+    echo '  "timeout": 30000,' >> /etc/scuttlebot/.ssb/config
239
+    echo '  "pub": true,' >> /etc/scuttlebot/.ssb/config
240
+    echo '  "local": true,' >> /etc/scuttlebot/.ssb/config
241
+    echo '  "friends": {' >> /etc/scuttlebot/.ssb/config
242
+    echo '    "dunbar": 150,' >> /etc/scuttlebot/.ssb/config
243
+    echo '    "hops": 3' >> /etc/scuttlebot/.ssb/config
244
+    echo '  },' >> /etc/scuttlebot/.ssb/config
245
+    echo '  "gossip": {' >> /etc/scuttlebot/.ssb/config
246
+    echo '    "connections": 2' >> /etc/scuttlebot/.ssb/config
247
+    echo '  },' >> /etc/scuttlebot/.ssb/config
248
+    echo '  "master": [],' >> /etc/scuttlebot/.ssb/config
249
+    echo '  "logging": {' >> /etc/scuttlebot/.ssb/config
250
+    echo '    "level": "error"' >> /etc/scuttlebot/.ssb/config
251
+    echo '  }' >> /etc/scuttlebot/.ssb/config
252
+    echo '}' >> /etc/scuttlebot/.ssb/config
253
+    chown scuttlebot:scuttlebot /etc/scuttlebot/.ssb/config
254
+    systemctl restart scuttlebot.service
255
+
195 256
     if ! grep -q "scuttlebot version:" ${COMPLETION_FILE}; then
196 257
         echo "scuttlebot version:${SCUTTLEBOT_VERSION}" >> ${COMPLETION_FILE}
197 258
     else