2022-12-07 19:26:10 +00:00
#!/bin/bash
# https://i2pd.readthedocs.io
if [ $# -eq 0 ] || [ " $1 " = "-h" ] || [ " $1 " = "-help" ] ; then
echo "I2P Daemon install script"
echo "More info at https://i2pd.readthedocs.io"
echo "Usage:"
echo "blitz.i2pd.sh install -> Install i2pd"
echo "blitz.i2pd.sh on -> Switch on i2pd"
echo "blitz.i2pd.sh off -> Uninstall i2pd"
2024-07-06 15:58:38 +02:00
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"
2022-12-07 19:26:10 +00:00
echo "blitz.i2pd.sh status -> I2P related logs from bitcoind, bitcoin-cli -netinfo 4 and webconsole access"
exit 1
fi
function confAdd {
# get parameters
keystr = " $1 "
valuestr = $( echo " $2 " | sed 's/\//\\\//g' )
configFile = " $3 "
# check if key needs to be added (prepare new entry)
entryExists = $( grep -c " ^ ${ keystr } = " ${ configFile } )
if [ ${ entryExists } -eq 0 ] ; then
echo " ${ keystr } = " | sudo tee -a ${ configFile } 1>/dev/null
fi
# add an extra key=value line (needs sudo to operate when user is not root)
echo " ${ keystr } = ${ valuestr } " | sudo tee -a ${ configFile }
}
function add_repo {
# Add repo for the latest version
# i2pd — https://repo.i2pd.xyz/.help/readme.txt
# https://repo.i2pd.xyz/.help/add_repo
source /etc/os-release
DIST = $ID
case $ID in
2024-07-06 15:58:38 +02:00
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
2022-12-07 19:26:10 +00:00
; ;
2024-07-06 15:58:38 +02:00
*)
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
2022-12-07 19:26:10 +00:00
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
fi
echo "Importing signing key"
wget -q -O - https://repo.i2pd.xyz/r4sas.gpg | sudo apt-key --keyring /etc/apt/trusted.gpg.d/i2pd.gpg add -
echo "Adding APT repository"
echo " deb https://repo.i2pd.xyz/ $DIST $RELEASE main " | sudo tee /etc/apt/sources.list.d/i2pd.list
echo " deb-src https://repo.i2pd.xyz/ $DIST $RELEASE main " | sudo tee -a /etc/apt/sources.list.d/i2pd.list
}
function bitcoinI2Pstatus {
echo "# I2P related logs from the bitcoin debug log"
echo "# Follow live with the command:"
echo "sudo tail -n 1000 -f /mnt/hdd/bitcoin/debug.log | grep i2p"
echo
2023-11-22 13:03:07 +01:00
sudo cat /mnt/hdd/bitcoin/debug.log | grep i2p
2022-12-07 19:26:10 +00:00
echo
echo "# Running the command:"
echo "bitcoin-cli -netinfo 4"
echo
bitcoin-cli -netinfo 4
echo
echo "# i2pd webconsole:"
localip = $( hostname -I | awk '{print $1}' )
echo " http:// ${ localip } :7070 "
echo "# Username: i2pd"
echo "# Password: your passwordB"
echo
}
echo " # Running: 'blitz.i2pd.sh $* ' "
source /mnt/hdd/raspiblitz.conf
Add automated image builds for VM, bare metal (amd64) and RPi (arm64-rpi) (#3486)
* add amd64 image build with lean and fatpack option
* use the pi user for setup
* add notes to ci readme
* add gnome desktop to fatpack image, reduce to 30GB
* documentation updates
* install gnome with --force-yes
* install gnome desktop non-interactively
* change links to rootzoll dev
* pass user and branch to build_sdcard.sh from PR
* add user and branch to Makefile
* Add arm64 rpi image build (#74)
ci:
* add arm64-rpi image build
* rename to raspiblitz-amd64-debian-11.5-lean/fatpack
* use rm -f to not exit with error
* place amd64 images under ci/amd64/builds/
* make /dev/shm world writable for fatpack
* fix vlc remove and --var syntax
* remove sudo-s
* leave update and upgrade to the build_sdcard.sh
* increase image size to 16GB, rename build dir
build_sdcard.sh:
* detect raspios_arm64 with raspi.list
* switch ssmtp to msmtp
related: https://github.com/rootzoll/raspiblitz/pull/2232
Co-authored-by: rootzoll <johndoe@example.com>
* i2pd: unified install from repo, /usr/sbin to PATH
related: #2413, fixes amd64 build
* update CHANGES.md
* fix amd64 path in Makefile
* use only qemu image, run on ubuntu-22.04
* use file_checksum for the arm64-rpi base image
* Fix the local arm64-rpi image generation (#75)
* add selfrun script
* ubuntu: add universe repo and qemu-user-static
* test on ubuntu live (jammy)
* build from branches: [ "dev", "v1.8", "v1.9" ]
* correct Makefile paths for the local run
* make the local run non-interactive
* improve readme and Makefile
* increase disk image sizes to 32GB
* set image sizes to 30 GB for amd64 and arm64-rpi
* add network-manager for amd64
* add to readme
* skip Code&Compile for VM builds
* add to readme
* amd64 base image update to debian 11.6.0
* remove debian version from filenames
* skip Code&Compile for amd64 builds
* Merge branch 'dev' into add-amd64-image-build
* amd64: increase cpu and RAM, compile mempool last
* trigger workflows only on scripts used or called
* Update ci/arm64-rpi/packer.build.arm64-rpi.sh
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
* arm64 remove setup-qemu-action, leave npm last
* set only manual trigger for fatpack, edit triggers
Co-authored-by: rootzoll <johndoe@example.com>
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
2022-12-20 15:31:51 +01:00
# make sure to be present in PATH
2024-07-06 15:58:38 +02:00
if ! echo " $PATH " | grep "/usr/sbin" >/dev/null; then
Add automated image builds for VM, bare metal (amd64) and RPi (arm64-rpi) (#3486)
* add amd64 image build with lean and fatpack option
* use the pi user for setup
* add notes to ci readme
* add gnome desktop to fatpack image, reduce to 30GB
* documentation updates
* install gnome with --force-yes
* install gnome desktop non-interactively
* change links to rootzoll dev
* pass user and branch to build_sdcard.sh from PR
* add user and branch to Makefile
* Add arm64 rpi image build (#74)
ci:
* add arm64-rpi image build
* rename to raspiblitz-amd64-debian-11.5-lean/fatpack
* use rm -f to not exit with error
* place amd64 images under ci/amd64/builds/
* make /dev/shm world writable for fatpack
* fix vlc remove and --var syntax
* remove sudo-s
* leave update and upgrade to the build_sdcard.sh
* increase image size to 16GB, rename build dir
build_sdcard.sh:
* detect raspios_arm64 with raspi.list
* switch ssmtp to msmtp
related: https://github.com/rootzoll/raspiblitz/pull/2232
Co-authored-by: rootzoll <johndoe@example.com>
* i2pd: unified install from repo, /usr/sbin to PATH
related: #2413, fixes amd64 build
* update CHANGES.md
* fix amd64 path in Makefile
* use only qemu image, run on ubuntu-22.04
* use file_checksum for the arm64-rpi base image
* Fix the local arm64-rpi image generation (#75)
* add selfrun script
* ubuntu: add universe repo and qemu-user-static
* test on ubuntu live (jammy)
* build from branches: [ "dev", "v1.8", "v1.9" ]
* correct Makefile paths for the local run
* make the local run non-interactive
* improve readme and Makefile
* increase disk image sizes to 32GB
* set image sizes to 30 GB for amd64 and arm64-rpi
* add network-manager for amd64
* add to readme
* skip Code&Compile for VM builds
* add to readme
* amd64 base image update to debian 11.6.0
* remove debian version from filenames
* skip Code&Compile for amd64 builds
* Merge branch 'dev' into add-amd64-image-build
* amd64: increase cpu and RAM, compile mempool last
* trigger workflows only on scripts used or called
* Update ci/arm64-rpi/packer.build.arm64-rpi.sh
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
* arm64 remove setup-qemu-action, leave npm last
* set only manual trigger for fatpack, edit triggers
Co-authored-by: rootzoll <johndoe@example.com>
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
2022-12-20 15:31:51 +01:00
export PATH = $PATH :/usr/sbin
echo "PATH=\$PATH:/usr/sbin" | sudo tee -a /etc/profile
fi
2022-12-07 19:26:10 +00:00
if [ " $1 " = "install" ] ; then
isInstalled = $( sudo systemctl list-unit-files | grep -c i2pd)
if [ " ${ isInstalled } " != "0" ] ; then
echo "# i2pd is already installed."
else
echo "# Installing i2pd ..."
Add automated image builds for VM, bare metal (amd64) and RPi (arm64-rpi) (#3486)
* add amd64 image build with lean and fatpack option
* use the pi user for setup
* add notes to ci readme
* add gnome desktop to fatpack image, reduce to 30GB
* documentation updates
* install gnome with --force-yes
* install gnome desktop non-interactively
* change links to rootzoll dev
* pass user and branch to build_sdcard.sh from PR
* add user and branch to Makefile
* Add arm64 rpi image build (#74)
ci:
* add arm64-rpi image build
* rename to raspiblitz-amd64-debian-11.5-lean/fatpack
* use rm -f to not exit with error
* place amd64 images under ci/amd64/builds/
* make /dev/shm world writable for fatpack
* fix vlc remove and --var syntax
* remove sudo-s
* leave update and upgrade to the build_sdcard.sh
* increase image size to 16GB, rename build dir
build_sdcard.sh:
* detect raspios_arm64 with raspi.list
* switch ssmtp to msmtp
related: https://github.com/rootzoll/raspiblitz/pull/2232
Co-authored-by: rootzoll <johndoe@example.com>
* i2pd: unified install from repo, /usr/sbin to PATH
related: #2413, fixes amd64 build
* update CHANGES.md
* fix amd64 path in Makefile
* use only qemu image, run on ubuntu-22.04
* use file_checksum for the arm64-rpi base image
* Fix the local arm64-rpi image generation (#75)
* add selfrun script
* ubuntu: add universe repo and qemu-user-static
* test on ubuntu live (jammy)
* build from branches: [ "dev", "v1.8", "v1.9" ]
* correct Makefile paths for the local run
* make the local run non-interactive
* improve readme and Makefile
* increase disk image sizes to 32GB
* set image sizes to 30 GB for amd64 and arm64-rpi
* add network-manager for amd64
* add to readme
* skip Code&Compile for VM builds
* add to readme
* amd64 base image update to debian 11.6.0
* remove debian version from filenames
* skip Code&Compile for amd64 builds
* Merge branch 'dev' into add-amd64-image-build
* amd64: increase cpu and RAM, compile mempool last
* trigger workflows only on scripts used or called
* Update ci/arm64-rpi/packer.build.arm64-rpi.sh
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
* arm64 remove setup-qemu-action, leave npm last
* set only manual trigger for fatpack, edit triggers
Co-authored-by: rootzoll <johndoe@example.com>
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
2022-12-20 15:31:51 +01:00
add_repo
sudo apt-get update
sudo apt-get install -y i2pd
2022-12-07 19:26:10 +00:00
fi
exit 0
fi
if [ " $1 " = "1" ] || [ " $1 " = "on" ] ; then
isInstalled = $( sudo systemctl list-unit-files | grep -c i2pd)
if [ " ${ isInstalled } " != "0" ] ; then
echo "# i2pd is installed."
else
/home/admin/config.scripts/blitz.i2pd.sh install
fi
if systemctl is-active --quiet i2pd.service; then
echo "# i2pd.service is already active."
2023-11-22 13:03:07 +01:00
else
echo "# sudo systemctl enable i2pd"
sudo systemctl enable i2pd
2022-12-07 19:26:10 +00:00
fi
2022-12-16 14:07:04 +01:00
echo "# i2pd config"
2022-12-07 19:26:10 +00:00
/home/admin/config.scripts/blitz.conf.sh set debug tor /mnt/hdd/bitcoin/bitcoin.conf noquotes
confAdd debug i2p /mnt/hdd/bitcoin/bitcoin.conf
/home/admin/config.scripts/blitz.conf.sh set i2psam 127.0.0.1:7656 /mnt/hdd/bitcoin/bitcoin.conf noquotes
/home/admin/config.scripts/blitz.conf.sh set i2pacceptincoming 1 /mnt/hdd/bitcoin/bitcoin.conf noquotes
2023-12-12 20:19:43 +01:00
/home/admin/config.scripts/blitz.conf.sh set onlynet onion /mnt/hdd/bitcoin/bitcoin.conf noquotes
2022-12-07 19:26:10 +00:00
confAdd onlynet i2p /mnt/hdd/bitcoin/bitcoin.conf
PASSWORD_B = $( sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-)
2023-11-22 13:03:07 +01:00
cat <<EOF | sudo tee /etc/i2pd/i2pd.conf
2022-12-07 19:26:10 +00:00
# i2pd settings for the RaspiBlitz
# for the defaults see:
# https://github.com/PurpleI2P/i2pd/blob/openssl/contrib/i2pd.conf
# Docs:
# https://i2pd.readthedocs.io/en/latest/user-guide/configuration/
loglevel = none
[ http]
address = 0.0.0.0
strictheaders = false
port = 7070
auth = true
user = i2pd
pass = ${ PASSWORD_B }
[ httpproxy]
enabled = false
[ socksproxy]
enabled = false
[ sam]
enabled = true
[ bob]
enabled = false
[ i2cp]
enabled = false
[ i2pcontrol]
enabled = false
[ upnp]
enabled = false
EOF
sudo ufw allow 7070 comment "i2pd-webconsole"
# Restart bitcoind and start i2p
source <( /home/admin/_cache.sh get state)
if [ " ${ state } " = = "ready" ] ; then
echo "# Starting i2pd service ..."
sudo systemctl start i2pd
echo "# Restart bitcoind ..."
sudo systemctl restart bitcoind 2>/dev/null
sleep 10
fi
if i2pd --version; then
echo "# Installed i2pd"
else
echo "# i2pd is not installed"
exit 1
fi
# setting value in raspiblitz.conf
/home/admin/config.scripts/blitz.conf.sh set i2pd "on"
2023-11-22 13:03:07 +01:00
localip = $( hostname -I | awk '{print $1}' )
2022-12-07 19:26:10 +00:00
echo "# Config: /etc/i2pd/i2pd.conf"
echo " # i2pd web console: ${ localip } :7070 "
echo "# Monitor i2p in bitcoind:"
echo "sudo tail -n 100 /mnt/hdd/bitcoin/debug.log | grep i2p"
echo "bitcoin-cli -netinfo 4"
exit 0
fi
if [ " $1 " = "addseednodes" ] ; then
2024-07-06 15:58:38 +02:00
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 ..."
2022-12-07 19:26:10 +00:00
2024-07-06 15:58:38 +02:00
# Fetch and filter the list of seed nodes
2022-12-07 19:26:10 +00:00
i2pSeedNodeList = $( curl -sS https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/seeds/nodes_main.txt | grep .b32.i2p:0)
2024-07-06 15:58:38 +02:00
# 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
2022-12-07 19:26:10 +00:00
echo
echo "# Display bitcoin-cli -netinfo 4"
2024-07-06 15:58:38 +02:00
sudo -u bitcoin bitcoin-cli -netinfo 4
2022-12-07 19:26:10 +00:00
exit 0
fi
# switch off
if [ " $1 " = "0" ] || [ " $1 " = "off" ] ; then
echo "# stop & remove systemd service"
sudo systemctl stop i2pd 2>/dev/null
sudo systemctl disable i2pd.service
echo "# Uninstall with apt"
sudo apt remove -y i2pd
echo "# Remove settings from bitcoind"
/home/admin/config.scripts/blitz.conf.sh delete debug /mnt/hdd/bitcoin/bitcoin.conf noquotes
/home/admin/config.scripts/blitz.conf.sh set debug tor /mnt/hdd/bitcoin/bitcoin.conf noquotes
/home/admin/config.scripts/blitz.conf.sh delete i2psam /mnt/hdd/bitcoin/bitcoin.conf noquotes
/home/admin/config.scripts/blitz.conf.sh delete i2pacceptincoming /mnt/hdd/bitcoin/bitcoin.conf noquotes
/home/admin/config.scripts/blitz.conf.sh delete onlynet /mnt/hdd/bitcoin/bitcoin.conf noquotes
2023-12-12 20:19:43 +01:00
/home/admin/config.scripts/blitz.conf.sh set onlynet onion /mnt/hdd/bitcoin/bitcoin.conf noquotes
2022-12-07 19:26:10 +00:00
sudo rm /etc/systemd/system/i2pd.service
sudo ufw delete allow 7070
if ! i2pd --version 2>/dev/null; then
echo "# OK - i2pd is not installed now"
else
echo "# i2pd is still installed"
exit 1
fi
# setting value in raspiblitz.conf
/home/admin/config.scripts/blitz.conf.sh set i2pd "off"
exit 0
fi
if [ " $1 " = "status" ] ; then
bitcoinI2Pstatus
exit 0
fi
echo " # FAIL - Unknown Parameter $1 "
exit 1