i2p: limit addseednodes to 21 new peers, format script (#4641)

* i2p: limit addseednodes to 21 new peers, format script
This commit is contained in:
openoms 2024-07-06 15:58:38 +02:00 committed by GitHub
parent 9a2de6cad5
commit 40e970d828
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "blitz.i2pd.sh install -> Install i2pd"
echo "blitz.i2pd.sh on -> Switch on i2pd"
echo "blitz.i2pd.sh off -> Uninstall i2pd"
echo "blitz.i2pd.sh addseednodes -> Add all I2P seed nodes from: https://github.com/bitcoin/bitcoin/blob/master/contrib/seeds/nodes_main.txt"
echo "blitz.i2pd.sh addseednodes -> Add 21 randonly selected I2P seed nodes from: https://github.com/bitcoin/bitcoin/blob/master/contrib/seeds/nodes_main.txt"
echo "blitz.i2pd.sh status -> I2P related logs from bitcoind, bitcoin-cli -netinfo 4 and webconsole access"
exit 1
fi
@ -38,44 +38,44 @@ function add_repo {
source /etc/os-release
DIST=$ID
case $ID in
debian|ubuntu|raspbian)
if [[ -n $DEBIAN_CODENAME ]]; then
VERSION_CODENAME=$DEBIAN_CODENAME
fi
if [[ -n $UBUNTU_CODENAME ]]; then
VERSION_CODENAME=$UBUNTU_CODENAME
fi
if [[ -z $VERSION_CODENAME ]]; then
echo "Couldn't find VERSION_CODENAME in your /etc/os-release file. Did your system supported? Please report issue to me by writing to email: 'r4sas <at> i2pd.xyz'"
exit 1
fi
RELEASE=$VERSION_CODENAME
debian | ubuntu | raspbian)
if [[ -n $DEBIAN_CODENAME ]]; then
VERSION_CODENAME=$DEBIAN_CODENAME
fi
if [[ -n $UBUNTU_CODENAME ]]; then
VERSION_CODENAME=$UBUNTU_CODENAME
fi
if [[ -z $VERSION_CODENAME ]]; then
echo "Couldn't find VERSION_CODENAME in your /etc/os-release file. Did your system supported? Please report issue to me by writing to email: 'r4sas <at> i2pd.xyz'"
exit 1
fi
RELEASE=$VERSION_CODENAME
;;
*)
if [[ -z $ID_LIKE || "$ID_LIKE" != "debian" && "$ID_LIKE" != "ubuntu" ]]; then
echo "Your system is not supported by this script. Currently it supports debian-like and ubuntu-like systems."
exit 1
else
DIST=$ID_LIKE
case $ID_LIKE in
debian)
if [[ "$ID" == "kali" ]]; then
if [[ "$VERSION" == "2019"* || "$VERSION" == "2020"* ]]; then
RELEASE="buster"
elif [[ "$VERSION" == "2021"* || "$VERSION" == "2022"* ]]; then
RELEASE="bullseye"
fi
else
RELEASE=$DEBIAN_CODENAME
fi
;;
ubuntu)
RELEASE=$UBUNTU_CODENAME
;;
esac
fi
;;
esac
*)
if [[ -z $ID_LIKE || "$ID_LIKE" != "debian" && "$ID_LIKE" != "ubuntu" ]]; then
echo "Your system is not supported by this script. Currently it supports debian-like and ubuntu-like systems."
exit 1
else
DIST=$ID_LIKE
case $ID_LIKE in
debian)
if [[ "$ID" == "kali" ]]; then
if [[ "$VERSION" == "2019"* || "$VERSION" == "2020"* ]]; then
RELEASE="buster"
elif [[ "$VERSION" == "2021"* || "$VERSION" == "2022"* ]]; then
RELEASE="bullseye"
fi
else
RELEASE=$DEBIAN_CODENAME
fi
;;
ubuntu)
RELEASE=$UBUNTU_CODENAME
;;
esac
fi
;;
esac
if [[ -z $RELEASE ]]; then
echo "Couldn't detect your system release. Please report issue to me by writing to email: 'r4sas <at> i2pd.xyz'"
exit 1
@ -111,7 +111,7 @@ echo "# Running: 'blitz.i2pd.sh $*'"
source /mnt/hdd/raspiblitz.conf
# make sure to be present in PATH
if ! echo "$PATH" | grep "/usr/sbin"; then
if ! echo "$PATH" | grep "/usr/sbin" >/dev/null; then
export PATH=$PATH:/usr/sbin
echo "PATH=\$PATH:/usr/sbin" | sudo tee -a /etc/profile
fi
@ -222,20 +222,30 @@ fi
if [ "$1" = "addseednodes" ]; then
/home/admin/config.scripts/blitz.i2pd.sh on
if ! sudo -u bitcoin bitcoin-cli -netinfo 4 | grep i2p; then
/home/admin/config.scripts/blitz.i2pd.sh on
fi
echo "Add 21 randomly selected I2P seed nodes from: https://github.com/bitcoin/bitcoin/blob/master/contrib/seeds/nodes_main.txt"
echo "Monitor in a new terminal with:"
echo "watch sudo -u bitcoin bitcoin-cli -netinfo 4"
echo "This will take some time ..."
echo "Add all I2P seed nodes from: https://github.com/bitcoin/bitcoin/blob/master/contrib/seeds/nodes_main.txt"
# Fetch and filter the list of seed nodes
i2pSeedNodeList=$(curl -sS https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/seeds/nodes_main.txt | grep .b32.i2p:0)
for i2pSeedNode in ${i2pSeedNodeList}; do
bitcoin-cli addnode "$i2pSeedNode" "onetry"
# Shuffle the list and pick the first 21 nodes
selectedNodes=$(echo "$i2pSeedNodeList" | shuf | head -n 21)
# Add each selected node
for i2pSeedNode in ${selectedNodes}; do
echo "# Add i2p seed node: ${i2pSeedNode} by running:"
echo "bitcoin-cli addnode $i2pSeedNode onetry"
sudo -u bitcoin bitcoin-cli addnode "$i2pSeedNode" "onetry"
done
echo
echo "# Display sudo tail -n 100 /mnt/hdd/bitcoin/debug.log | grep i2p"
sudo tail -n 100 /mnt/hdd/bitcoin/debug.log | grep i2p
echo
echo "# Display bitcoin-cli -netinfo 4"
bitcoin-cli -netinfo 4
sudo -u bitcoin bitcoin-cli -netinfo 4
exit 0
fi