Astroport.ONE/tools/ipfs_config.sh

66 lines
2.8 KiB
Bash
Raw Normal View History

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
# 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
#~ }
#~ }'
2022-11-16 06:11:07 +01:00
ipfs config --json Swarm.ConnMgr.LowWater 20
ipfs config --json Swarm.ConnMgr.HighWater 40
2024-02-29 02:57:24 +01:00
[[ ! $isLAN ]] && ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://'$(hostname)'.localhost:8080", "http://ipfs.localhost:8080", "http://127.0.0.1:8080", "http://127.0.1.1:8080", "https://ipfs.'$(hostname)'", "https://ipfs.copylaradio.com" ]' \
|| ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://'$(hostname)'.local:8080","http://'$(hostname)':8080", "http://'$(hostname)'.localhost: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 BOOSTRAP ADD Astroport.ONE Officials ###########
2022-11-16 06:11:07 +01:00
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