2022-11-16 06:11:07 +01:00
|
|
|
#!/bin/bash
|
2022-12-15 02:35:59 +01:00
|
|
|
# Version: 0.1
|
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
################################################################################
|
2022-11-16 06:11:07 +01:00
|
|
|
myIP=$(hostname -I | awk '{print $1}')
|
2022-12-18 20:45:43 +01:00
|
|
|
isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
2022-11-16 06:11:07 +01:00
|
|
|
|
2023-01-30 17:54:41 +01:00
|
|
|
|
|
|
|
sudo systemctl stop ipfs
|
|
|
|
|
2022-11-16 06:11:07 +01:00
|
|
|
###########################################
|
|
|
|
### IMPORTANT !!!!!!! IMPORTANT !!!!!!
|
|
|
|
###########################################
|
|
|
|
# DHT PUBSUB mode
|
2023-09-13 18:02:38 +02:00
|
|
|
# ipfs config Pubsub.Router gossipsub ## DEPRECATED
|
|
|
|
ipfs config --json Ipns.UsePubsub true
|
2022-11-16 06:11:07 +01:00
|
|
|
|
2023-01-17 15:23:45 +01:00
|
|
|
# MAXSTORAGE = 1/2 full
|
2022-11-16 06:11:07 +01:00
|
|
|
availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}')
|
2023-01-17 15:23:45 +01:00
|
|
|
fullDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$2}END{print sum}')
|
|
|
|
diskSize="$((fullDiskSize / 2))"
|
2022-11-16 06:11:07 +01:00
|
|
|
ipfs config Datastore.StorageMax $diskSize
|
|
|
|
|
|
|
|
## Activate Rapid "ipfs p2p"
|
|
|
|
ipfs config --json Experimental.Libp2pStreamMounting true
|
|
|
|
ipfs config --json Experimental.P2pHttpProxy true
|
|
|
|
|
2023-01-17 15:23:45 +01:00
|
|
|
#~ ## Activate Experimental.AcceleratedDHTClient
|
|
|
|
#~ ipfs config Reprovider.Interval '42s'
|
|
|
|
#~ ipfs config Reprovider.Strategy "roots"
|
|
|
|
#~ ipfs config Routing.Routers.WanDHT --json '{
|
|
|
|
#~ "Type": "dht",
|
|
|
|
#~ "Parameters": {
|
|
|
|
#~ "Mode": "auto",
|
|
|
|
#~ "PublicIPNetwork": true,
|
|
|
|
#~ "AcceleratedDHTClient": true
|
|
|
|
#~ }
|
|
|
|
#~ }'
|
2023-01-13 19:41:48 +01:00
|
|
|
|
2022-11-16 06:11:07 +01:00
|
|
|
ipfs config --json Swarm.ConnMgr.LowWater 20
|
|
|
|
ipfs config --json Swarm.ConnMgr.HighWater 40
|
|
|
|
|
2023-07-03 12:13:10 +02:00
|
|
|
[[ ! $isLAN ]] && ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://ipfs.localhost:8080", "http://127.0.0.1:8080", "http://127.0.1.1:8080", "https://ipfs.'$(hostname)'.copylaradio.com", "https://ipfs.copylaradio.com" ]' \
|
2023-03-04 16:42:01 +01:00
|
|
|
|| ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://'$(hostname)'.local:8080","http://'$(hostname)':8080", "http://127.0.0.1:8080", "http://ipfs.localhost:8080", "http://127.0.1.1:8080" ]'
|
2022-11-16 06:11:07 +01:00
|
|
|
|
|
|
|
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
|
|
|
|
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
|
|
|
|
|
|
|
|
## For ipfs.js = https://github.com/ipfs/js-ipfs/blob/master/docs/DELEGATE_ROUTERS.md
|
2023-01-17 15:23:45 +01:00
|
|
|
#~ ipfs config --json Addresses.Swarm | jq '. += ["/ip4/0.0.0.0/tcp/30215/ws"]' > /tmp/30215.ws
|
|
|
|
#~ ipfs config --json Addresses.Swarm "$(cat /tmp/30215.ws)"
|
2022-11-16 06:11:07 +01:00
|
|
|
|
|
|
|
ipfs config Addresses.API "/ip4/0.0.0.0/tcp/5001"
|
|
|
|
ipfs config Addresses.Gateway "/ip4/0.0.0.0/tcp/8080"
|
|
|
|
|
|
|
|
######### CLEAN DEFAULT BOOTSTRAP ADD Astroport.ONE Officials ###########
|
|
|
|
ipfs bootstrap rm --all
|
|
|
|
|
2023-10-26 11:09:19 +02:00
|
|
|
for bootnode in $(cat ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
|
2022-11-16 06:11:07 +01:00
|
|
|
do
|
|
|
|
ipfsnodeid=${bootnode##*/}
|
|
|
|
ipfs bootstrap add $bootnode
|
|
|
|
done
|
|
|
|
|
2023-01-30 17:54:41 +01:00
|
|
|
sudo systemctl start ipfs
|