~/.ipfs/config.new Peering.Peers & ipfs daemon restart

This commit is contained in:
fred 2021-09-11 01:35:24 +02:00
parent 57f1ba826a
commit d74b7528b5
2 changed files with 15 additions and 11 deletions

View File

@ -27,8 +27,8 @@ IPFSNODEID=$(ipfs --timeout=10s id -f='<id>\n')
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
if [[ ! ${YOU} ]]; then
# reduice water levels for swarm
ipfs config --json Swarm.ConnMgr.LowWater 200
ipfs config --json Swarm.ConnMgr.HighWater 400
ipfs config --json Swarm.ConnMgr.LowWater 50
ipfs config --json Swarm.ConnMgr.HighWater 100
[[ "${USER}" == "xbian" ]] && sudo service ipfs restart || sudo systemctl restart ipfs
echo "ERROR! ipfs daemon was not running. RELAUNCHING."
exit 1
@ -36,7 +36,7 @@ fi
########################################################################
# CORRECT VSTREAM ASTROPORT SITE/ART REMOVED AFTER PLUGIN UPDATE
[[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py ]] && [[ -f ~/.zen/astroport.py ]] && cp -f ~/.zen/astroport.py ~/.kodi/addons/plugin.video.vstream/resources/sites/
[[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ]] && cp ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ~/.kodi/addons/plugin.video.vstream/resources/art/
[[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ]] && cp ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ~/.kodi/addons/plugin.video.vstream/resources/art/ 2>/dev/null
########################################################################
### NO IP GATEWAY : EXIT
@ -228,9 +228,6 @@ fi
#
# REFRESHing MEDIAKEY / ZenTAG nano DHTs => Zen File ECONOMY wallet cycle
if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || "$timebar" == "03:03" || $(($runtime % 720)) == 0 || $runtime == 12 ]]; then
# At 03:03 and every 12h runtime restarting IPFS daemon
[[ "$timebar" == "03:03" || $(($runtime % 360)) == 0 ]] && [[ -f /etc/sudoers.d/systemctl ]] && sudo systemctl restart ipfs && exit 0
[[ "$timebar" == "03:03" || $(($runtime % 720)) == 0 ]] && [[ ${YOU} == "xbian" ]] && sudo service ipfs restart && exit 0
#### Refresh & publish MEDIAKEYs
$MY_PATH/zen/ipns_TAG_refresh.sh
@ -239,6 +236,11 @@ if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || "$timebar" == "03:03" ||
rm -f ~/.zen/A_dead_swarm.txt
fi
# At 03:03 and every 6h runtime restarting IPFS daemon
[[ "$timebar" == "03:03" || $(($runtime % 360)) == 0 ]] && [[ -f ~/.ipfs/config.new ]] && cp ~/.ipfs/config.new ~/.ipfs/config
[[ "$timebar" == "03:03" || $(($runtime % 360)) == 0 ]] && [[ -f /etc/sudoers.d/systemctl ]] && sudo systemctl restart ipfs && exit 0
[[ "$timebar" == "03:03" || $(($runtime % 360)) == 0 ]] && [[ ${YOU} == "xbian" ]] && sudo service ipfs restart && exit 0
##################################################################
##################################################################
# 5 mn / 24h REBOOT & MIDNIGHT:01 : CLEANING & UPDATE

View File

@ -56,8 +56,8 @@ ipfs bootstrap > /tmp/ipfs_swarm_peers
ipfs swarm peers >> /tmp/ipfs_swarm_peers
rm ~/.zen/A_peering_peers.txt
# [[ -f ~/.ipfs/config.bak ]] && cp ~/.ipfs/config.bak ~/.ipfs/config
cp ~/.ipfs/config ~/.ipfs/config.new
[[ ! -f ~/.ipfs/config.bak ]] && cp ~/.ipfs/config ~/.ipfs/config.bak ## Backup previous original
cp ~/.ipfs/config ~/.ipfs/config.new ## Prepare Peering.Peers changes
# for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq); ## TODO ACTIVATE IN DEFCON 4
for ipfsnodeid in $(cat ~/.zen/ipfs_swarm/.*/tryme.addr | grep -o '[^/]*$' | sort | uniq);
@ -114,13 +114,15 @@ do
fi
fi
################################################################
echo "## CREATING Peering.Peer entries"
echo "@@ CREATING Peering.Peer @@"
echo "jq '.Peering.Peers? += { \"Addrs\": [], \"ID\": \"'$ipfsnodeid'\" }'"
################################################################
Addr=$(echo "$peerline" | rev | cut -d '/' -f 2- | rev )
IsAlreadythere=$(cat ~/.ipfs/config.new | grep $ipfsnodeid)
IsAlreadythere=$(cat ~/.ipfs/config.new | grep '"$ipfsnodeid"') && echo $IsAlreadythere
if [[ ! $IsAlreadythere ]]; then
echo '{ "ID": "'$ipfsnodeid'", "Addrs": [] }' >> ~/.zen/A_peering_peers.txt
jq '.Peering.Peers? += { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
#jq '.Peering.Peers? += { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
jq '.Peering.Peers[.Peering.Peers| length] |= . + { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
fi
################################################################
## Refresh bootstrap if XID exists