Browse Source

Install scuttlebot on mesh

This should better enable nat traversal between the internet and the mesh
Bob Mottram 7 years ago
parent
commit
073ad0f888

+ 40
- 0
src/freedombone-app-scuttlebot View File

197
     sed -i '/scuttlebot /d' $COMPLETION_FILE
197
     sed -i '/scuttlebot /d' $COMPLETION_FILE
198
 }
198
 }
199
 
199
 
200
+function mesh_install_scuttlebot {
201
+    cat <<EOF > $rootdir/usr/bin/install_scuttlebot
202
+#!/bin/bash
203
+npm install -g scuttlebot@${SCUTTLEBOT_VERSION}
204
+EOF
205
+    chroot "$rootdir" /bin/chmod +x /usr/bin/install_scuttlebot
206
+    chroot "$rootdir" /usr/bin/install_scuttlebot
207
+    rm $rootdir/usr/bin/install_scuttlebot
208
+
209
+    if [ ! -f $rootdir/usr/local/bin/sbot ]; then
210
+        echo $'Scuttlebot was not installed'
211
+        exit 528253
212
+    fi
213
+
214
+    if [ ! -d $rootdir/etc/scuttlebot ]; then
215
+        mkdir -p $rootdir/etc/scuttlebot
216
+    fi
217
+
218
+    # an unprivileged user to run as
219
+    chroot "$rootdir" useradd -d /etc/scuttlebot/ scuttlebot
220
+
221
+    # daemon
222
+    echo '[Unit]' > $rootdir/etc/systemd/system/scuttlebot.service
223
+    echo 'Description=Scuttlebot (messaging system)' >> $rootdir/etc/systemd/system/scuttlebot.service
224
+    echo 'After=syslog.target' >> $rootdir/etc/systemd/system/scuttlebot.service
225
+    echo 'After=network.target' >> $rootdir/etc/systemd/system/scuttlebot.service
226
+    echo '' >> $rootdir/etc/systemd/system/scuttlebot.service
227
+    echo '[Service]' >> $rootdir/etc/systemd/system/scuttlebot.service
228
+    echo 'Type=simple' >> $rootdir/etc/systemd/system/scuttlebot.service
229
+    echo 'User=scuttlebot' >> $rootdir/etc/systemd/system/scuttlebot.service
230
+    echo 'Group=scuttlebot' >> $rootdir/etc/systemd/system/scuttlebot.service
231
+    echo "WorkingDirectory=/etc/scuttlebot" >> $rootdir/etc/systemd/system/scuttlebot.service
232
+    echo 'ExecStart=/usr/local/bin/sbot server' >> $rootdir/etc/systemd/system/scuttlebot.service
233
+    echo 'Restart=always' >> $rootdir/etc/systemd/system/scuttlebot.service
234
+    echo 'Environment="USER=scuttlebot"' >> $rootdir/etc/systemd/system/scuttlebot.service
235
+    echo '' >> $rootdir/etc/systemd/system/scuttlebot.service
236
+    echo '[Install]' >> $rootdir/etc/systemd/system/scuttlebot.service
237
+    echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/scuttlebot.service
238
+}
239
+
200
 function install_scuttlebot {
240
 function install_scuttlebot {
201
     function_check install_nodejs
241
     function_check install_nodejs
202
     install_nodejs scuttlebot
242
     install_nodejs scuttlebot

+ 1
- 0
src/freedombone-image-customise View File

701
     #install_tahoelafs
701
     #install_tahoelafs
702
     #install_librevault
702
     #install_librevault
703
     install_patchwork
703
     install_patchwork
704
+    mesh_install_scuttlebot
704
     install_ferment
705
     install_ferment
705
     install_ipfs
706
     install_ipfs
706
     install_tox
707
     install_tox

+ 36
- 0
src/freedombone-image-mesh View File

756
     systemctl restart openvpn
756
     systemctl restart openvpn
757
 }
757
 }
758
 
758
 
759
+function initialise_scuttlebot_pub {
760
+    chown -R scuttlebot:scuttlebot /etc/scuttlebot
761
+
762
+    systemctl enable scuttlebot.service
763
+    systemctl daemon-reload
764
+    systemctl start scuttlebot.service
765
+
766
+    sleep 3
767
+
768
+    if [ ! -d /etc/scuttlebot/.ssb ]; then
769
+        echo $'Scuttlebot config not generated' >> /var/log/${PROJECT_NAME}.log
770
+        exit 73528
771
+    fi
772
+
773
+    echo '{' > /etc/scuttlebot/.ssb/config
774
+    echo "  \"host\": \"${HOSTNAME}\"," >> /etc/scuttlebot/.ssb/config
775
+    echo "  \"port\": 8008," >> /etc/scuttlebot/.ssb/config
776
+    echo '  "timeout": 30000,' >> /etc/scuttlebot/.ssb/config
777
+    echo '  "pub": true,' >> /etc/scuttlebot/.ssb/config
778
+    echo '  "local": true,' >> /etc/scuttlebot/.ssb/config
779
+    echo '  "friends": {' >> /etc/scuttlebot/.ssb/config
780
+    echo '    "dunbar": 150,' >> /etc/scuttlebot/.ssb/config
781
+    echo '    "hops": 3' >> /etc/scuttlebot/.ssb/config
782
+    echo '  },' >> /etc/scuttlebot/.ssb/config
783
+    echo '  "gossip": {' >> /etc/scuttlebot/.ssb/config
784
+    echo '    "connections": 2' >> /etc/scuttlebot/.ssb/config
785
+    echo '  },' >> /etc/scuttlebot/.ssb/config
786
+    echo '  "master": [],' >> /etc/scuttlebot/.ssb/config
787
+    echo '  "logging": {' >> /etc/scuttlebot/.ssb/config
788
+    echo '    "level": "error"' >> /etc/scuttlebot/.ssb/config
789
+    echo '  }' >> /etc/scuttlebot/.ssb/config
790
+    echo '}' >> /etc/scuttlebot/.ssb/config
791
+    chown scuttlebot:scuttlebot /etc/scuttlebot/.ssb/config
792
+    systemctl restart scuttlebot.service
793
+}
759
 
794
 
760
 # whether to reset the identity
795
 # whether to reset the identity
761
 set_new_identity=
796
 set_new_identity=
819
     create_tox_user
854
     create_tox_user
820
     #setup_tahoelafs
855
     #setup_tahoelafs
821
     mesh_setup_vpn
856
     mesh_setup_vpn
857
+    initialise_scuttlebot_pub
822
     setup_ipfs
858
     setup_ipfs
823
     mesh_amnesic
859
     mesh_amnesic
824
     make_root_read_only
860
     make_root_read_only

+ 2
- 2
src/freedombone-mesh-batman View File

155
     iptables -D INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT
155
     iptables -D INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT
156
     iptables -D INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT
156
     iptables -D INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT
157
     iptables -D INPUT -p tcp --dport $TAHOELAFS_PORT -j ACCEPT
157
     iptables -D INPUT -p tcp --dport $TAHOELAFS_PORT -j ACCEPT
158
-    # SSB/Patchwork
158
+    # SSB/Scuttlebot/Patchwork
159
     iptables -D INPUT -p udp --dport 8008 -j ACCEPT
159
     iptables -D INPUT -p udp --dport 8008 -j ACCEPT
160
     iptables -D INPUT -p tcp --dport 8008 -j ACCEPT
160
     iptables -D INPUT -p tcp --dport 8008 -j ACCEPT
161
     # vpn over the internet
161
     # vpn over the internet
325
     iptables -A INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT
325
     iptables -A INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT
326
     iptables -A INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT
326
     iptables -A INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT
327
     iptables -A INPUT -p tcp --dport $TAHOELAFS_PORT -j ACCEPT
327
     iptables -A INPUT -p tcp --dport $TAHOELAFS_PORT -j ACCEPT
328
-    # SSB/Patchwork
328
+    # SSB/Scuttlebot/Patchwork
329
     iptables -A INPUT -p udp --dport 8008 -j ACCEPT
329
     iptables -A INPUT -p udp --dport 8008 -j ACCEPT
330
     iptables -A INPUT -p tcp --dport 8008 -j ACCEPT
330
     iptables -A INPUT -p tcp --dport 8008 -j ACCEPT
331
     # vpn over the internet
331
     # vpn over the internet