correct "ipfs id" hang up
This commit is contained in:
parent
0bf9352ca3
commit
b2e2c85860
|
@ -21,32 +21,26 @@ err() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
# 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])/")
|
||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
||||
|
||||
MACHINE_TYPE=`uname -m`
|
||||
|
||||
# CHECK if daemon is already running
|
||||
if [[ $(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) ]]; then
|
||||
ipfs id && echo "ipfs swarm peers: " && ipfs swarm peers
|
||||
echo "ipfs bootstrap list: " && ipfs bootstrap list
|
||||
echo "ipfs daemon already running...!"
|
||||
exit 0
|
||||
if [[ $YOU ]]; then
|
||||
echo "ipfs daemon already running...! Run by $YOU $MACHINE_TYPE"
|
||||
else
|
||||
# INIT ipfs
|
||||
if [[ ! -d ~/.ipfs ]]; then
|
||||
[[ $isLAN ]] && ipfs init -p lowpower \
|
||||
|| ipfs init -p server
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "Astroport activate IPFS Layer installation..."
|
||||
|
||||
# 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])/")
|
||||
|
||||
MACHINE_TYPE=`uname -m`
|
||||
|
||||
# INIT ipfs
|
||||
[[ $isLAN ]] && ipfs init -p lowpower \
|
||||
|| ipfs init -p server
|
||||
|
||||
## Special Xbian init.d config
|
||||
if [[ "$USER" == "xbian" ]]; then
|
||||
sudo cp ~/.zen/astrXbian/.install/templates/ipfs/ipfs-initV.sh /etc/init.d/ipfs
|
||||
sudo chmod 755 /etc/init.d/ipfs
|
||||
sudo touch /var/log/ipfs.log && sudo chown xbian /var/log/ipfs.log
|
||||
else
|
||||
## DEBIAN
|
||||
echo "CREATE SYSTEMD ipfs SERVICE >>>>>>>>>>>>>>>>>>"
|
||||
cat > /tmp/ipfs.service <<EOF
|
||||
|
@ -65,14 +59,11 @@ CPUQuota=60%
|
|||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
sudo cp -f /tmp/ipfs.service /etc/systemd/system/
|
||||
sudo sed -i "s/_USER_/$USER/g" /etc/systemd/system/ipfs.service
|
||||
|
||||
[[ -d ~/.ipfs ]] && sudo chown -R $USER:$USER ~/.ipfs
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ipfs
|
||||
fi
|
||||
sudo cp -f /tmp/ipfs.service /etc/systemd/system/
|
||||
sudo sed -i "s/_USER_/$USER/g" /etc/systemd/system/ipfs.service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ipfs
|
||||
|
||||
###########################################
|
||||
# ACTIVATE IPFS OPTIONS: #swarm0 INIT
|
||||
|
@ -81,34 +72,37 @@ fi
|
|||
###########################################
|
||||
# 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
|
||||
ipfs config --json Experimental.P2pHttpProxy true
|
||||
ipfs config --json Swarm.ConnMgr.LowWater 0
|
||||
ipfs config --json Swarm.ConnMgr.HighWater 0
|
||||
myIP=$(hostname -I | awk '{print $1}' | head -n 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])/")
|
||||
|
||||
[[ ! $isLAN ]] && ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://127.0.0.1:8080", "http://127.0.1.1:8080" ]' \
|
||||
|| ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://127.0.0.1:8080", "http://127.0.1.1:8080" ]'
|
||||
|
||||
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
|
||||
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
|
||||
|
||||
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 TO STAY INVISIBLE ###########
|
||||
######### CLEAN DEFAULT BOOTSTRAP ADD Astroport.ONE Officials ###########
|
||||
ipfs bootstrap rm --all
|
||||
###########################################
|
||||
# BOOTSTRAP NODES ARE ADDED LATER
|
||||
###########################################
|
||||
# AVOID CONFLICT WITH KODI ./.install/.kodi/userdata/guisettings.xml
|
||||
ipfs config Addresses.Gateway "/ip4/0.0.0.0/tcp/8080"
|
||||
|
||||
[[ "$USER" != "xbian" ]] && sudo systemctl restart ipfs
|
||||
for bootnode in $(cat ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
|
||||
do
|
||||
ipfsnodeid=${bootnode##*/}
|
||||
ipfs bootstrap add $bootnode
|
||||
done
|
||||
|
||||
sudo systemctl restart ipfs
|
||||
|
||||
} # this ensures the entire script is downloaded #
|
||||
# IPFS CONFIG documentation: https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#addressesswarm
|
||||
|
|
Loading…
Reference in New Issue