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 install -> Install i2pd"
echo "blitz.i2pd.sh on -> Switch on i2pd" echo "blitz.i2pd.sh on -> Switch on i2pd"
echo "blitz.i2pd.sh off -> Uninstall 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" echo "blitz.i2pd.sh status -> I2P related logs from bitcoind, bitcoin-cli -netinfo 4 and webconsole access"
exit 1 exit 1
fi fi
@ -38,44 +38,44 @@ function add_repo {
source /etc/os-release source /etc/os-release
DIST=$ID DIST=$ID
case $ID in case $ID in
debian|ubuntu|raspbian) debian | ubuntu | raspbian)
if [[ -n $DEBIAN_CODENAME ]]; then if [[ -n $DEBIAN_CODENAME ]]; then
VERSION_CODENAME=$DEBIAN_CODENAME VERSION_CODENAME=$DEBIAN_CODENAME
fi fi
if [[ -n $UBUNTU_CODENAME ]]; then if [[ -n $UBUNTU_CODENAME ]]; then
VERSION_CODENAME=$UBUNTU_CODENAME VERSION_CODENAME=$UBUNTU_CODENAME
fi fi
if [[ -z $VERSION_CODENAME ]]; then 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'" 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 exit 1
fi fi
RELEASE=$VERSION_CODENAME RELEASE=$VERSION_CODENAME
;; ;;
*) *)
if [[ -z $ID_LIKE || "$ID_LIKE" != "debian" && "$ID_LIKE" != "ubuntu" ]]; then 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." echo "Your system is not supported by this script. Currently it supports debian-like and ubuntu-like systems."
exit 1 exit 1
else else
DIST=$ID_LIKE DIST=$ID_LIKE
case $ID_LIKE in case $ID_LIKE in
debian) debian)
if [[ "$ID" == "kali" ]]; then if [[ "$ID" == "kali" ]]; then
if [[ "$VERSION" == "2019"* || "$VERSION" == "2020"* ]]; then if [[ "$VERSION" == "2019"* || "$VERSION" == "2020"* ]]; then
RELEASE="buster" RELEASE="buster"
elif [[ "$VERSION" == "2021"* || "$VERSION" == "2022"* ]]; then elif [[ "$VERSION" == "2021"* || "$VERSION" == "2022"* ]]; then
RELEASE="bullseye" RELEASE="bullseye"
fi fi
else else
RELEASE=$DEBIAN_CODENAME RELEASE=$DEBIAN_CODENAME
fi fi
;; ;;
ubuntu) ubuntu)
RELEASE=$UBUNTU_CODENAME RELEASE=$UBUNTU_CODENAME
;; ;;
esac esac
fi fi
;; ;;
esac esac
if [[ -z $RELEASE ]]; then if [[ -z $RELEASE ]]; then
echo "Couldn't detect your system release. Please report issue to me by writing to email: 'r4sas <at> i2pd.xyz'" echo "Couldn't detect your system release. Please report issue to me by writing to email: 'r4sas <at> i2pd.xyz'"
exit 1 exit 1
@ -111,7 +111,7 @@ echo "# Running: 'blitz.i2pd.sh $*'"
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# make sure to be present in PATH # 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 export PATH=$PATH:/usr/sbin
echo "PATH=\$PATH:/usr/sbin" | sudo tee -a /etc/profile echo "PATH=\$PATH:/usr/sbin" | sudo tee -a /etc/profile
fi fi
@ -222,20 +222,30 @@ fi
if [ "$1" = "addseednodes" ]; then 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) 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"
done
echo # Shuffle the list and pick the first 21 nodes
echo "# Display sudo tail -n 100 /mnt/hdd/bitcoin/debug.log | grep i2p" selectedNodes=$(echo "$i2pSeedNodeList" | shuf | head -n 21)
sudo tail -n 100 /mnt/hdd/bitcoin/debug.log | grep i2p
# 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
echo "# Display bitcoin-cli -netinfo 4" echo "# Display bitcoin-cli -netinfo 4"
bitcoin-cli -netinfo 4 sudo -u bitcoin bitcoin-cli -netinfo 4
exit 0 exit 0
fi fi