forked from axiom-team/astroport
131 lines
3.9 KiB
Bash
Executable File
131 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
scuttlebutt() {
|
|
echo -e "${c_yellow}Onboarding SCUTTLEBUTT...$c_"
|
|
where_is_ssb_installed=$(which ssb-server)
|
|
where_is_oasis_installed=$(which oasis)
|
|
mkdir -p ~/.zen
|
|
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
if [[ ! $where_is_ssb_installed ]]; then
|
|
# KILL the BRUTAL WAY...
|
|
kill -9 $(ps auxf --sort=+utime | grep -w ssb-server| grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
|
|
# Install dependencies
|
|
sudo apt-get install -y socat python3-dev libtool python3-setuptools autoconf automake
|
|
|
|
# Install nvm
|
|
if [[ ! $(which nvm) ]]; then
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
|
|
source ~/.bashrc
|
|
export NVM_DIR="$HOME/.nvm"
|
|
nvm install --lts
|
|
fi
|
|
|
|
cd ~/.ssb
|
|
|
|
### Install module
|
|
npm install -g sodium-native ssb-backlinks ssb-ws ssb-links ssb-query ssb-secret-blob ssb-private
|
|
npm install -g ssb-server
|
|
|
|
# TODO plugin activation !??
|
|
# sbot plugins.enable
|
|
|
|
### Install oasis & ssb-cli (could replace ssb-server?? TODO: try it)
|
|
npm -g install fraction/oasis#semver:
|
|
npm install -g fraction/ssb-daemon
|
|
# npm install -g ssb-cli
|
|
|
|
# INSTALL sbotc
|
|
if [[ ! $(which sbotc) ]]; then
|
|
sudo apt install libsodium-dev jq -y
|
|
git submodule add https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc
|
|
cd sbotc
|
|
make
|
|
sudo make install
|
|
fi
|
|
|
|
fi
|
|
|
|
# TEST ssb-server Install
|
|
ssbSERVER=$(which ssb-server)
|
|
[[ $ssbSERVER == "" ]] && echo "Check your ssb-server install... Cannot find it !!" && exit 1
|
|
# If exists backup ~/.ssb to ~/.ssb_$USER SSB (one time only !)
|
|
[[ -d ~/.ssb_$USER ]] && echo "BACKUP already existing... ~/.ssb_$USER !!! Manual check please..." && exit 1
|
|
[[ -d ~/.ssb ]] && [[ ! -d ~/.ssb_$USER ]] && mv ~/.ssb ~/.ssb_$USER
|
|
# CREATE ~/.ssb_astroport
|
|
[[ ! -d ~/.ssb_astroport ]] && mkdir -p ~/.ssb_astroport && cd ~/.ssb_astroport
|
|
# if exists, keep ~/.ssb_$USER/secret*
|
|
[[ ! -f ~/.ssb_astroport/secret ]] && [[ -f ~/.ssb_$USER/secret ]] && cp -f ~/.ssb_$USER/secret* ~/.ssb_astroport/
|
|
|
|
# Symlink ~/.ssb -> ~/.ssb_astroport
|
|
[[ -L ~/.ssb ]] && rm ~/.ssb
|
|
[[ -d ~/.ssb_astroport ]] && ln -s ~/.ssb_astroport ~/.ssb
|
|
## #TODO get ~/.ssb/manifest.json from template
|
|
cp ./templates/ssb/manifest.json ~/.ssb/manifest.json
|
|
|
|
# Create config (TODO: adapt if public Pub or Local Node)
|
|
# TODO: Create unique hostname in swarm !! uidna
|
|
|
|
nodename=$(cat /etc/hostname)
|
|
extension=$(echo $nodename | cut -d '.' -f 2)
|
|
if [[ $extension == $nodename ]]; then
|
|
PUB="false"
|
|
nodename=$nodename.local
|
|
else
|
|
PUB="true"
|
|
fi
|
|
|
|
cat > ~/.ssb/config <<EOF
|
|
{
|
|
"connections": {
|
|
"incoming": {
|
|
"net": [
|
|
{ "scope": "public", "host": "0.0.0.0", "external": ["$nodename"], "transform": "shs", "port": 8008 }
|
|
],
|
|
"ws": [
|
|
{ "scope": ["public", "local", "device"], "host": "0.0.0.0", "port": 8989, "transform": "shs", "http": true }
|
|
]
|
|
},
|
|
"outgoing": {
|
|
"net": [{ "transform": "shs" }]
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
cat > ~/.zen/launch-oasis.sh <<EOF
|
|
#!/bin/bash
|
|
oasis --allow-host $nodename --host $nodename
|
|
EOF
|
|
|
|
echo "
|
|
_ __ __ _
|
|
_ _ .__|_o _ (_ (_ |_)
|
|
(_(_)| || |(_| __)__)|_)
|
|
_|
|
|
$nodename
|
|
|
|
"
|
|
echo '
|
|
__ _ _ _ _
|
|
(_ |_|_)\ /|_|_) o._ o_|_
|
|
__)|_| \ \/ |_| \ || || |_ ... SCUTTLEBUTT ... OK?
|
|
|
|
'
|
|
echo "Launching oasis"
|
|
oasis --allow-host $nodename --host $nodename &
|
|
echo " http://$nodename:3000 "
|
|
echo
|
|
echo "ADD ~/.zen/launch-oasis.sh TO YOUR '/etc/rc.local' !!! Or use patchwork. "
|
|
sleep $((1 + RANDOM % 5))
|
|
echo "LAUNCHING OASIS NODE MANAGER http://$nodename:3000"
|
|
|
|
echo "IF YOU ARE A PUB consider protect it behind password nginx redirect !!!"
|
|
|
|
echo "3 seconds before ssb_INIT.sh..."
|
|
sleep 3
|
|
$MY_PATH/zen/ssb_INIT.sh
|
|
|
|
}
|
|
|
|
$@
|