Install scuttlebot on mesh

This should better enable nat traversal between the internet and the mesh
This commit is contained in:
Bob Mottram 2017-10-01 19:46:02 +01:00
parent 278bffa7ee
commit 073ad0f888
4 changed files with 79 additions and 2 deletions

View File

@ -197,6 +197,46 @@ function remove_scuttlebot {
sed -i '/scuttlebot /d' $COMPLETION_FILE sed -i '/scuttlebot /d' $COMPLETION_FILE
} }
function mesh_install_scuttlebot {
cat <<EOF > $rootdir/usr/bin/install_scuttlebot
#!/bin/bash
npm install -g scuttlebot@${SCUTTLEBOT_VERSION}
EOF
chroot "$rootdir" /bin/chmod +x /usr/bin/install_scuttlebot
chroot "$rootdir" /usr/bin/install_scuttlebot
rm $rootdir/usr/bin/install_scuttlebot
if [ ! -f $rootdir/usr/local/bin/sbot ]; then
echo $'Scuttlebot was not installed'
exit 528253
fi
if [ ! -d $rootdir/etc/scuttlebot ]; then
mkdir -p $rootdir/etc/scuttlebot
fi
# an unprivileged user to run as
chroot "$rootdir" useradd -d /etc/scuttlebot/ scuttlebot
# daemon
echo '[Unit]' > $rootdir/etc/systemd/system/scuttlebot.service
echo 'Description=Scuttlebot (messaging system)' >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'After=syslog.target' >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'After=network.target' >> $rootdir/etc/systemd/system/scuttlebot.service
echo '' >> $rootdir/etc/systemd/system/scuttlebot.service
echo '[Service]' >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'Type=simple' >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'User=scuttlebot' >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'Group=scuttlebot' >> $rootdir/etc/systemd/system/scuttlebot.service
echo "WorkingDirectory=/etc/scuttlebot" >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'ExecStart=/usr/local/bin/sbot server' >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'Restart=always' >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'Environment="USER=scuttlebot"' >> $rootdir/etc/systemd/system/scuttlebot.service
echo '' >> $rootdir/etc/systemd/system/scuttlebot.service
echo '[Install]' >> $rootdir/etc/systemd/system/scuttlebot.service
echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/scuttlebot.service
}
function install_scuttlebot { function install_scuttlebot {
function_check install_nodejs function_check install_nodejs
install_nodejs scuttlebot install_nodejs scuttlebot

View File

@ -701,6 +701,7 @@ initialise_mesh() {
#install_tahoelafs #install_tahoelafs
#install_librevault #install_librevault
install_patchwork install_patchwork
mesh_install_scuttlebot
install_ferment install_ferment
install_ipfs install_ipfs
install_tox install_tox

View File

@ -756,6 +756,41 @@ function mesh_setup_vpn {
systemctl restart openvpn systemctl restart openvpn
} }
function initialise_scuttlebot_pub {
chown -R scuttlebot:scuttlebot /etc/scuttlebot
systemctl enable scuttlebot.service
systemctl daemon-reload
systemctl start scuttlebot.service
sleep 3
if [ ! -d /etc/scuttlebot/.ssb ]; then
echo $'Scuttlebot config not generated' >> /var/log/${PROJECT_NAME}.log
exit 73528
fi
echo '{' > /etc/scuttlebot/.ssb/config
echo " \"host\": \"${HOSTNAME}\"," >> /etc/scuttlebot/.ssb/config
echo " \"port\": 8008," >> /etc/scuttlebot/.ssb/config
echo ' "timeout": 30000,' >> /etc/scuttlebot/.ssb/config
echo ' "pub": true,' >> /etc/scuttlebot/.ssb/config
echo ' "local": true,' >> /etc/scuttlebot/.ssb/config
echo ' "friends": {' >> /etc/scuttlebot/.ssb/config
echo ' "dunbar": 150,' >> /etc/scuttlebot/.ssb/config
echo ' "hops": 3' >> /etc/scuttlebot/.ssb/config
echo ' },' >> /etc/scuttlebot/.ssb/config
echo ' "gossip": {' >> /etc/scuttlebot/.ssb/config
echo ' "connections": 2' >> /etc/scuttlebot/.ssb/config
echo ' },' >> /etc/scuttlebot/.ssb/config
echo ' "master": [],' >> /etc/scuttlebot/.ssb/config
echo ' "logging": {' >> /etc/scuttlebot/.ssb/config
echo ' "level": "error"' >> /etc/scuttlebot/.ssb/config
echo ' }' >> /etc/scuttlebot/.ssb/config
echo '}' >> /etc/scuttlebot/.ssb/config
chown scuttlebot:scuttlebot /etc/scuttlebot/.ssb/config
systemctl restart scuttlebot.service
}
# whether to reset the identity # whether to reset the identity
set_new_identity= set_new_identity=
@ -819,6 +854,7 @@ if [ -f $MESH_INSTALL_SETUP ]; then
create_tox_user create_tox_user
#setup_tahoelafs #setup_tahoelafs
mesh_setup_vpn mesh_setup_vpn
initialise_scuttlebot_pub
setup_ipfs setup_ipfs
mesh_amnesic mesh_amnesic
make_root_read_only make_root_read_only

View File

@ -155,7 +155,7 @@ function stop {
iptables -D INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT iptables -D INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT
iptables -D INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT iptables -D INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT
iptables -D INPUT -p tcp --dport $TAHOELAFS_PORT -j ACCEPT iptables -D INPUT -p tcp --dport $TAHOELAFS_PORT -j ACCEPT
# SSB/Patchwork # SSB/Scuttlebot/Patchwork
iptables -D INPUT -p udp --dport 8008 -j ACCEPT iptables -D INPUT -p udp --dport 8008 -j ACCEPT
iptables -D INPUT -p tcp --dport 8008 -j ACCEPT iptables -D INPUT -p tcp --dport 8008 -j ACCEPT
# vpn over the internet # vpn over the internet
@ -325,7 +325,7 @@ function start {
iptables -A INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT iptables -A INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT
iptables -A INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT iptables -A INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT
iptables -A INPUT -p tcp --dport $TAHOELAFS_PORT -j ACCEPT iptables -A INPUT -p tcp --dport $TAHOELAFS_PORT -j ACCEPT
# SSB/Patchwork # SSB/Scuttlebot/Patchwork
iptables -A INPUT -p udp --dport 8008 -j ACCEPT iptables -A INPUT -p udp --dport 8008 -j ACCEPT
iptables -A INPUT -p tcp --dport 8008 -j ACCEPT iptables -A INPUT -p tcp --dport 8008 -j ACCEPT
# vpn over the internet # vpn over the internet