2020-06-05 23:47:11 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-06 00:14:13 +02:00
|
|
|
# CHECK node IP isLAN?
|
|
|
|
myIP=$(hostname -I | awk '{print $1}')
|
|
|
|
isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
|
|
|
|
2020-06-05 23:47:11 +02:00
|
|
|
# INIT ipfs
|
|
|
|
[[ $isLAN ]] && ipfs init -p lowpower \
|
|
|
|
|| ipfs init -p server
|
|
|
|
# TODO try ipfs init --profile=badgerds (for better performance)
|
|
|
|
# https://discuss.ipfs.io/t/adding-content-to-ipfs-is-quite-slow-any-ideas-on-why-and-how-to-speed-things-up/8135/3
|
|
|
|
|
|
|
|
sudo chown -R $USER:$USER ~/.ipfs || exit 1
|
|
|
|
|
|
|
|
###########################################
|
|
|
|
# ACTIVATE IPFS OPTIONS: #swarm0 INIT
|
|
|
|
###########################################
|
|
|
|
### IMPORTANT !!!!!!! IMPORTANT !!!!!!
|
|
|
|
###########################################
|
|
|
|
# DHT PUBSUB mode
|
|
|
|
ipfs config Pubsub.Router gossipsub
|
|
|
|
# MAXSTORAGE = 1/2 available
|
|
|
|
availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}')
|
|
|
|
diskSize="$((availableDiskSize / 2))"
|
|
|
|
ipfs config Datastore.StorageMax $diskSize
|
|
|
|
## Activate Rapid "ipfs p2p"
|
|
|
|
ipfs config --json Experimental.Libp2pStreamMounting true
|
|
|
|
|
|
|
|
######### UPDATE BOOTSTRAP LIST ###########
|
|
|
|
ipfs bootstrap rm --all
|
|
|
|
ipfs bootstrap add /dnsaddr/oasis.astroport.com/tcp/4001/ipfs/Qmf98yiZja5yrVctp5x4FicUe3Dubzbm5TiUHqJQwwT5Rj
|
|
|
|
ipfs bootstrap add /ip4/51.15.166.54/tcp/4001/p2p/Qmf98yiZja5yrVctp5x4FicUe3Dubzbm5TiUHqJQwwT5Rj
|
|
|
|
ipfs bootstrap add /ip6/fe80::208:a2ff:fe0c:20d8/tcp/4001/p2p/Qmf98yiZja5yrVctp5x4FicUe3Dubzbm5TiUHqJQwwT5Rj
|
|
|
|
###########################################
|
|
|
|
# TODO: ADD some other bootstrap NODES
|
|
|
|
###########################################
|
|
|
|
|
|
|
|
sudo systemctl start ipfs || err "Start IPFS daemon"
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
echo "Peers: " && ipfs swarm peers && sleep 0.3
|
|
|
|
#[[ ! $(ipfs swarm peers) =~ "/ip4/" ]] && err "No peers found in swarm. Please open issue :https://git.p2p.legal/axiom-team/astroport/issues"
|