Compare commits

...

12 Commits

Author SHA1 Message Date
Enki
2704f37c41 Merge remote-tracking branch 'origin/main' 2024-07-08 23:07:34 -07:00
Enki
910f8763cd some changes and new idea for LN Script 2024-07-08 22:51:50 -07:00
Enki
220125a2d9 Last round of clean up and fixes I hope 2024-01-09 17:49:26 -08:00
Enki
13daaf1c76 More systemd changes 2024-01-09 16:05:00 -08:00
Enki
6bb3df8d2f hopefully last permaissions changes Fuck 2024-01-09 13:52:45 -08:00
Enki
a611be9e6f Fix chown mistake 2024-01-09 11:16:38 -08:00
Enki
a445a0572f rpc auth change 2024-01-06 00:02:54 -08:00
Enki
1944f286d8 readme fix 2023-12-22 01:54:08 -08:00
Enki
71777cfc4b README update and added a line to the core install welcome 2023-12-22 01:48:59 -08:00
Enki
e9b7fe0b5a file structure update 2023-12-22 01:23:49 -08:00
Enki
537e5c0670 Bitcoin Core install Script and readme update. 2023-12-22 01:20:11 -08:00
enki
c20e247a0e Initial commit 2023-12-22 06:35:31 +00:00
5 changed files with 1806 additions and 4 deletions

751
Bitcoin/coreinstall.sh Normal file
View File

@ -0,0 +1,751 @@
#!/bin/bash
#This is a script to install Bitcoin Core
#Global Functions.
is_package_installed() {
if dpkg -l "$1" 2>/dev/null | grep -q "^ii"; then
echo "$1 is installed."
return 0 # Package is installed
else
echo "$1 is not installed."
return 1 # Package is not installed
fi
}
prompt_yes_no() {
local question="$1"
local default_choice="${2:-yes}"
while true; do
read -p "$question (y/n) [default: $default_choice]: " user_choice
case $user_choice in
[Yy])
echo "yes"
return
;;
[Nn])
echo "no"
return
;;
"")
# If the user just presses Enter, return the default choice
echo "$default_choice"
return
;;
*)
echo "Invalid choice. Please enter 'y' for yes or 'n' for no."
;;
esac
done
}
# Network stuff
# Installs TOR
install_tor() {
# Check if TOR is already installed
if is_package_installed "tor"; then
echo "TOR is already installed. Moving on..."
sleep 1
else
# Confirm TOR installation
if [ "$(prompt_yes_no 'Do you want to install TOR?')" == "yes" ]; then
echo "Adding the TOR repository..."
sleep 0.5
if ! echo "deb https://deb.torproject.org/torproject.org $(lsb_release -cs) main" >>/etc/apt/sources.list.d/tor.list; then
echo "Failed to add the TOR repository." >&2
exit 1
fi
echo "Importing the TOR project's GPG key..."
sleep 1
if ! wget -qO - https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor --output /etc/apt/trusted.gpg.d/tor.gpg; then
echo "Failed to import the GPG key for TOR." >&2
exit 1
fi
echo "Updating package lists...half a sec."
sleep 0.5
if ! apt-get update -qq; then
echo "Failed to update package lists with the new repository." >&2
exit 1
fi
echo "Installing TOR. Hodl tight..."
sleep 1
if ! apt-get install -y -qq tor; then
echo "Failed to install TOR." >&2
exit 1
fi
echo "Installing additional dependencies for TOR..."
sleep 1
if ! apt-get install -y -qq torsocks tor-geoipdb; then
echo "Failed to install additional dependencies for TOR." >&2
exit 1
fi
echo "Adding the user 'bitcoin' to the 'debian-tor' group to allow TOR access..."
sleep 1
sudo groupadd -f debian-tor
sudo usermod -a -G debian-tor bitcoin
echo "Setting correct permissions for the TOR configuration directory..."
sleep 1
if ! chown -R debian-tor:debian-tor /var/lib/tor; then
echo "Failed to set permissions for the TOR configuration directory." >&2
exit 1
fi
echo "Modifying the TOR config file (torrc) to work with core...."
sleep 1
if ! echo -e "ControlPort 9051\nCookieAuthentication 1\nCookieAuthFileGroupReadable 1\nLog notice stdout\nSOCKSPort 9050" >>/etc/tor/torrc; then
echo "Failed to custom configurations to torrc file." >&2
exit 1
fi
echo "Restarting TOR so the changes take effect..."
sleep 1
systemctl restart tor
echo "TOR has been installed and configured for core to use. Moving on..."
sleep 3
else
echo "TOR installation skipped. Moving on..." >&2
sleep 2
fi
fi
}
# Installs I2P
install_i2p() {
# Check if I2P is already installed
if is_package_installed "i2pd"; then
echo "I2P is already installed."
return
fi
# Confirm I2P installation
if [ "$(prompt_yes_no 'Do you want to install I2P?')" == "yes" ]; then
# Ensure apt-transport-https is installed before adding repositories
if ! is_package_installed "apt-transport-https"; then
echo "Installing apt-transport-https..."
if ! apt-get install -y -qq apt-transport-https; then
echo "Failed to install apt-transport-https." >&2
exit 1
fi
else
echo "apt-transport-https is already installed."
fi
# Adding I2P repository
echo "Adding I2P repository..."
if ! wget -qq -O - https://repo.i2pd.xyz/.help/add_repo | sudo bash -s -; then
echo "Failed to add the I2P repository." >&2
exit 1
fi
# Updating package lists
echo "Updating package lists..."
if ! apt-get update -qq; then
echo "Failed to update package lists." >&2
exit 1
fi
# Installing I2P
echo "Installing I2P..."
if ! apt-get install -y -qq i2pd; then
echo "Failed to install I2P." >&2
exit 1
fi
# Enabling and starting the I2P service
echo "Enabling the I2P service to start on boot..."
if ! systemctl enable i2pd; then
echo "Failed to enable the I2P service to start on boot." >&2
exit 1
fi
echo "Starting the I2P service..."
if ! systemctl start i2pd; then
echo "Failed to start the I2P service." >&2
exit 1
fi
echo "I2P has been installed and is configured to start on boot. Moving on..."
else
echo "I2P installation skipped. Moving on..."
fi
sleep 3
}
# Bitocin Stuff
# Checks if Bitcoin Core is installed
is_bitcoin_core_installed() {
command -v bitcoind &>/dev/null
}
# Installs Core's dependencies
install_bitcoin_core_dependencies() {
echo "Checking if Core is already installed..."
if is_bitcoin_core_installed; then
echo "Core is already installed. Skipping to config."
sleep 2
return
else
echo "Bitcoin Core dependencies not found. No worries..."
fi
echo "Installing required repositories for Core..."
sleep 3
if ! is_package_installed "git"; then
echo "Installing git..."
if ! apt-get install -y -qq git; then
echo "Failed to install git." >&2
exit 1
fi
else
echo "git is already installed."
fi
if ! is_package_installed "curl"; then
echo "Installing curl..."
if ! apt-get install -y -qq curl; then
echo "Failed to install curl." >&2
exit 1
fi
else
echo "curl is already installed."
fi
local bitcoin_core_dependencies=("build-essential" "libtool" "autotools-dev" "automake" "pkg-config" "bsdmainutils" "python3" "libssl-dev" "libevent-dev" "libboost-system-dev" "libboost-filesystem-dev" "libboost-test-dev" "libboost-thread-dev" "libboost-all-dev" "libzmq3-dev")
# Iterate through the dependencies and install them
for dep in "${bitcoin_core_dependencies[@]}"; do
if ! is_package_installed "$dep"; then
echo "Installing $dep..."
if ! apt-get install -y -qq "$dep"; then
echo "Failed to install $dep." >&2
exit 1
fi
else
echo "$dep is already installed."
fi
done
echo "Core dependencies have been successfully installed. Moving on..."
sleep 2
}
# Download and install Bitcoin Core
download_and_install_bitcoin_core() {
local node_folder="/home/bitcoin/node"
# Create the node folder if it doesn't exist
echo "Creating the node folder..."
sleep 1
mkdir -p "$node_folder"
# Fetch the latest version number from the GitHub API
echo "Fetching the latest version of Bitcoin Core..."
sleep 1
latest_version=$(curl -s https://api.github.com/repos/bitcoin/bitcoin/releases/latest | jq -r '.tag_name' | sed 's/^v//')
if [[ -z "$latest_version" ]]; then
echo "Failed to fetch the latest version of Bitcoin Core. Aborting the installation." >&2
exit 1
fi
# Download the Bitcoin Core source code as a .tar.gz file
echo "Downloading Bitcoin Core source code..."
sleep 1
local bitcoin_core_url="https://bitcoincore.org/bin/bitcoin-core-${latest_version}/bitcoin-${latest_version}.tar.gz"
local source_code_archive="${node_folder}/bitcoin-$latest_version.tar.gz"
if ! wget -nc -q "$bitcoin_core_url" -P "$node_folder"; then
echo "ERROR: Failed to download the Bitcoin Core source code." >&2
exit 1
fi
# Download the SHA256SUMS file
echo "Downloading Bitcoin Core SHA256SUMS file..."
sleep 2
local sha256sums_url="https://bitcoincore.org/bin/bitcoin-core-$latest_version/SHA256SUMS"
local sha256sums_file="${node_folder}/SHA256SUMS"
if ! wget -nc -q "$sha256sums_url" -O "$sha256sums_file"; then
echo "ERROR: Failed to download the SHA256SUMS file." >&2
exit 1
fi
# Verify the cryptographic checksum of the downloaded .tar.gz file
verify_checksum "$source_code_archive" "$latest_version"
# Extract the downloaded source code
echo "Extracting Bitcoin Core source code..."
sleep 1
tar -xzf "$source_code_archive" -C "$node_folder"
# Navigate into the Bitcoin Core directory
echo "Entering the Bitcoin Core directory so it can be compiled..."
sleep 1
if ! cd "$node_folder/bitcoin-$latest_version"; then
echo "Failed to enter the Bitcoin Core directory. Aborting the installation." >&2
exit 1
fi
# Build and install Bitcoin Core
echo "Building Bitcoin Core. This is compiling Bitcoin core from scratch. It will take a while, so go touch some grass or something."
echo "I'm going to let the output run here so you can see progress being made. Starting in a sec."
sleep 3
./autogen.sh
./configure
make
# Check if 'make install' was successful
if ! make install; then
echo "Failed to install Bitcoin Core. Aborting the installation." >&2
exit 1
fi
echo "Bitcoin Core compiled successfully! Woo! Moving on to configuration"
sleep 3
}
# Verifies the cryptographic checksum of a file
verify_checksum() {
local file="$1"
local expected_checksum="$2"
local current_dir="$(pwd)" # Store the current directory
# Change directory to the folder where the file is located
local file_dir="$(dirname "$file")"
cd "$file_dir"
# Download the SHA256SUMS file without renaming
echo "Verifying the cryptographic checksum..."
sleep 1
if sha256sum --ignore-missing --check SHA256SUMS; then
echo -e "\e[32m+--------------------------------+\e[0m"
echo -e "\e[32m| \e[1mVerification Successful!\e[0m \e[32m |\e[0m"
echo -e "\e[32m+--------------------------------+\e[0m"
sleep 3
else
echo -e "\e[1;31mERROR: Cryptographic checksum verification failed.\e[0m" >&2
exit 1
fi
# Return to the original directory
cd "$current_dir"
}
# Copies Core's binary to /usr/local/bin and checks permissions
copy_bitcoin_core_binary() {
local node_folder="/home/bitcoin/node"
local latest_version="$1"
local expected_location="/usr/local/bin"
if [ -x "${expected_location}/bitcoind" ] && [ -x "${expected_location}/bitcoin-cli" ]; then
echo "Bitcoin Core binaries are already installed in ${expected_location}. Skipping copying and permissions check."
return
fi
echo "Copying Bitcoin Core binary to ${expected_location}..."
sleep 1
cp "$node_folder/bitcoin-$latest_version/src/bitcoind" "${expected_location}"
cp "$node_folder/bitcoin-$latest_version/src/bitcoin-cli" "${expected_location}"
chown bitcoin:bitcoin "${expected_location}/bitcoind"
chown bitcoin:bitcoin "${expected_location}/bitcoin-cli"
chmod 755 "${expected_location}/bitcoind"
chmod 755 "${expected_location}/bitcoin-cli"
echo "Bitcoin Core binary has been copied to ${expected_location} and proper permissions have been set."
sleep 1
}
create_bitcoin_conf() {
local bitcoin_conf_dir="/home/bitcoin/.bitcoin"
local bitcoin_conf_file="$bitcoin_conf_dir/bitcoin.conf"
local network="$1"
# Ensure that the /home/bitcoin/.bitcoin directory exists
if [ ! -d "$bitcoin_conf_dir" ]; then
echo "Creating $bitcoin_conf_dir directory..."
mkdir -p "$bitcoin_conf_dir" || {
echo "Failed to create directory $bitcoin_conf_dir"
exit 1
}
chown bitcoin:bitcoin "$bitcoin_conf_dir" || {
echo "Failed to change ownership of $bitcoin_conf_dir" >&2
exit 1
}
chmod 700 "$bitcoin_conf_dir" || {
echo "Failed to set permissions for $bitcoin_conf_dir" >&2
exit 1
}
echo "$bitcoin_conf_dir directory created successfully."
fi
# Create or modify the bitcoin.conf file
if [ ! -f "$bitcoin_conf_file" ]; then
echo "Creating $bitcoin_conf_file with a base configuration..."
# Base Configuration (Hybrid Mode)
cat >"$bitcoin_conf_file" <<EOF
# Base Configuration
datadir=/home/bitcoin/.bitcoin
rpccookiefile=/home/bitcoin/.bitcoin/.cookie
coinstatsindex=1
daemon=1
server=1
rpcbind=127.0.0.1
rpcport=8332
rpcallowip=127.0.0.1
rpcallowip=::1
rpcuser=bitcoin
rpcpassword=craigwrightisnotsatoshi
daemonwait=1
dbcache=600
maxmempool=500
txindex=1
permitbaremultisig=0
EOF
chown bitcoin:bitcoin "$bitcoin_conf_file"
chmod 600 "$bitcoin_conf_file"
echo "Base configuration file created."
fi
# Additional configuration based on network mode
case "$network" in
"tor")
# TOR configuration
cat <<EOF >>"$bitcoin_conf_file"
# [Network]
debug=tor
proxy=127.0.0.1:9050
onlynet=onion
EOF
;;
"tor_hybrid")
# TOR hybrid configuration
cat <<EOF >>"$bitcoin_conf_file"
# [Network]
debug=tor
proxy=127.0.0.1:9050
EOF
;;
"i2p")
# I2P configuration
cat <<EOF >>"$bitcoin_conf_file"
# [Network]
debug=i2p
i2psam=127.0.0.1:7656
onlynet=i2p
addnode=255fhcp6ajvftnyo7bwz3an3t4a4brhopm3bamyh2iu5r3gnr2rq.b32.i2p:0
addnode=27yrtht5b5bzom2w5ajb27najuqvuydtzb7bavlak25wkufec5mq.b32.i2p:0
addnode=2el6enckmfyiwbfcwsygkwksovtynzsigmyv3bzyk7j7qqahooua.b32.i2p:0
addnode=3gocb7wc4zvbmmebktet7gujccuux4ifk3kqilnxnj5wpdpqx2hq.b32.i2p:0
addnode=3tns2oov4tnllntotazy6umzkq4fhkco3iu5rnkxtu3pbfzxda7q.b32.i2p:0
addnode=4fcc23wt3hyjk3csfzcdyjz5pcwg5dzhdqgma6bch2qyiakcbboa.b32.i2p:0
addnode=4osyqeknhx5qf3a73jeimexwclmt42cju6xdp7icja4ixxguu2hq.b32.i2p:0
addnode=4umsi4nlmgyp4rckosg4vegd2ysljvid47zu7pqsollkaszcbpqq.b32.i2p:0
addnode=52v6uo6crlrlhzphslyiqblirux6olgsaa45ixih7sq5np4jujaa.b32.i2p:0
addnode=6j2ezegd3e2e2x3o3pox335f5vxfthrrigkdrbgfbdjchm5h4awa.b32.i2p:0
EOF
;;
"i2p_hybrid")
# I2P hybrid configuration
cat <<EOF >>"$bitcoin_conf_file"
# [Network]
debug=i2p
i2psam=127.0.0.1:7656
addnode=255fhcp6ajvftnyo7bwz3an3t4a4brhopm3bamyh2iu5r3gnr2rq.b32.i2p:0
addnode=27yrtht5b5bzom2w5ajb27najuqvuydtzb7bavlak25wkufec5mq.b32.i2p:0
addnode=2el6enckmfyiwbfcwsygkwksovtynzsigmyv3bzyk7j7qqahooua.b32.i2p:0
addnode=3gocb7wc4zvbmmebktet7gujccuux4ifk3kqilnxnj5wpdpqx2hq.b32.i2p:0
addnode=3tns2oov4tnllntotazy6umzkq4fhkco3iu5rnkxtu3pbfzxda7q.b32.i2p:0
addnode=4fcc23wt3hyjk3csfzcdyjz5pcwg5dzhdqgma6bch2qyiakcbboa.b32.i2p:0
addnode=4osyqeknhx5qf3a73jeimexwclmt42cju6xdp7icja4ixxguu2hq.b32.i2p:0
addnode=4umsi4nlmgyp4rckosg4vegd2ysljvid47zu7pqsollkaszcbpqq.b32.i2p:0
addnode=52v6uo6crlrlhzphslyiqblirux6olgsaa45ixih7sq5np4jujaa.b32.i2p:0
addnode=6j2ezegd3e2e2x3o3pox335f5vxfthrrigkdrbgfbdjchm5h4awa.b32.i2p:0
EOF
;;
"both")
# TOR and I2P configuration
cat <<EOF >>"$bitcoin_conf_file"
# [Network]
debug=tor
debug=i2p
proxy=127.0.0.1:9050
i2psam=127.0.0.1:7656
onlynet=onion
onlynet=i2p
addnode=255fhcp6ajvftnyo7bwz3an3t4a4brhopm3bamyh2iu5r3gnr2rq.b32.i2p:0
addnode=27yrtht5b5bzom2w5ajb27najuqvuydtzb7bavlak25wkufec5mq.b32.i2p:0
addnode=2el6enckmfyiwbfcwsygkwksovtynzsigmyv3bzyk7j7qqahooua.b32.i2p:0
addnode=3gocb7wc4zvbmmebktet7gujccuux4ifk3kqilnxnj5wpdpqx2hq.b32.i2p:0
addnode=3tns2oov4tnllntotazy6umzkq4fhkco3iu5rnkxtu3pbfzxda7q.b32.i2p:0
addnode=4fcc23wt3hyjk3csfzcdyjz5pcwg5dzhdqgma6bch2qyiakcbboa.b32.i2p:0
addnode=4osyqeknhx5qf3a73jeimexwclmt42cju6xdp7icja4ixxguu2hq.b32.i2p:0
addnode=4umsi4nlmgyp4rckosg4vegd2ysljvid47zu7pqsollkaszcbpqq.b32.i2p:0
addnode=52v6uo6crlrlhzphslyiqblirux6olgsaa45ixih7sq5np4jujaa.b32.i2p:0
addnode=6j2ezegd3e2e2x3o3pox335f5vxfthrrigkdrbgfbdjchm5h4awa.b32.i2p:0
EOF
;;
"both_hybrid")
# TOR and I2P hybrid configuration
cat <<EOF >>"$bitcoin_conf_file"
# [Network]
debug=tor
debug=i2p
proxy=127.0.0.1:9050
i2psam=127.0.0.1:7656
addnode=255fhcp6ajvftnyo7bwz3an3t4a4brhopm3bamyh2iu5r3gnr2rq.b32.i2p:0
addnode=27yrtht5b5bzom2w5ajb27najuqvuydtzb7bavlak25wkufec5mq.b32.i2p:0
addnode=2el6enckmfyiwbfcwsygkwksovtynzsigmyv3bzyk7j7qqahooua.b32.i2p:0
addnode=3gocb7wc4zvbmmebktet7gujccuux4ifk3kqilnxnj5wpdpqx2hq.b32.i2p:0
addnode=3tns2oov4tnllntotazy6umzkq4fhkco3iu5rnkxtu3pbfzxda7q.b32.i2p:0
addnode=4fcc23wt3hyjk3csfzcdyjz5pcwg5dzhdqgma6bch2qyiakcbboa.b32.i2p:0
addnode=4osyqeknhx5qf3a73jeimexwclmt42cju6xdp7icja4ixxguu2hq.b32.i2p:0
addnode=4umsi4nlmgyp4rckosg4vegd2ysljvid47zu7pqsollkaszcbpqq.b32.i2p:0
addnode=52v6uo6crlrlhzphslyiqblirux6olgsaa45ixih7sq5np4jujaa.b32.i2p:0
addnode=6j2ezegd3e2e2x3o3pox335f5vxfthrrigkdrbgfbdjchm5h4awa.b32.i2p:0
EOF
;;
esac
echo "Bitcoin Core configuration updated for $network mode."
sleep 3
}
# Plugs Core into systemd
create_bitcoin_core_service() {
local service_file="/etc/systemd/system/bitcoind.service"
cat <<EOF >"$service_file"
[Unit]
Description=Bitcoin core daemon
After=network-online.target
Wants=network-online.target
[Service]
User=bitcoin
Group=bitcoin
Type=forking
ExecStart=/usr/local/bin/bitcoind -conf=/home/bitcoin/.bitcoin/bitcoin.conf
Restart=always
PrivateTmp=true
TimeoutStopSec=480s
TimeoutStartSec=480s
StartLimitInterval=600s
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
EOF
echo "Reloading systemd so it can recognize the new service..."
sleep 1
if ! systemctl daemon-reload; then
echo "Error: Failed to reload systemd. Please check systemd." >&2
exit 1
fi
}
# Starts and enables Bitcoin Core
start_and_enable_bitcoin_core() {
echo "Final permissions check..."
sudo chown -R bitcoin:bitcoin /home/bitcoin
sudo chmod -R u+rw,g+rw,o-rwx /home/bitcoin
sudo chmod u+x /usr/local/bin/bitcoind
sudo chmod u+x /usr/local/bin/bitcoin-cli
sudo systemctl enable bitcoind
sudo systemctl start bitcoind
echo "Bitcoin Core has been started and added to systemd."
echo "Now Bitcoin Core will start on boot."
sleep 3
}
# Final systems check and exit.
check_services() {
echo "Final check the make sure everything is working..."
if sudo systemctl is-active --quiet bitcoind; then
echo "Woot! Core is up and running. Looks like your good to go."
else
echo "It looks like something did not work bitcoind is not running."
echo "Check debug.log in /home/bitcoin/.bitcoin to see logs."
exit 1
fi
}
# Main script starts here
# Root Check
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root. Run wih sudo or use 'su' log into your admin account."
exit 1
fi
# Welcome Message
cat <<"EOF"
! .::::::. ... ::: .::.:::::::.. :::. :::. :::. :::. :::. ... :::::::-. .,:::::: ::::::::::. :::. .,-::::: ::: .
! ;;;` ` .;;;;;;;. ';;, ,;;;' ;;;;``;;;; ;;`;; `;;;;, `;;; `;;;;, `;;; .;;;;;;;. ;;, `';,;;;;'''' `;;;```.;;; ;;`;; ,;;;'````' ;;; .;;,.
! '[==/[[[[,,[[ \[[, \[[ .[[/ [[[,/[[[' ,[[ '[[, [[[[[. '[[ [[[[[. '[[,[[ \[[, `[[ [[ [[cccc `]]nnn]]' ,[[ '[[, [[[ [[[[[/'
! ''' $$$$, $$$ Y$c.$$" $$$$$$c c$$$cc$$$c $$$ "Y$c$$ $$$ "Y$c$$$$$, $$$ $$, $$ $$"""" $$$"" c$$$cc$$$c $$$ _$$$$,
! 88b dP"888,_ _,88P Y88P 888b "88bo, 888 888, 888 Y88 888 Y88"888,_ _,88P 888_,o8P' 888oo,__ 888o 888 888,`88bo,__,o, "888"88o,
! "YMmMY" "YMMMMMP" MP MMMM "W" YMM ""` MMM YM MMM YM "YMMMMMP" MMMMP"` """"YUMMM YMMMb YMM ""` "YUMMMMMP" MMM "MMP"
EOF
echo "Thanks for using Enki's Bitcoin Core install script"
echo "This is part of a set of scripts that help set up various parts of a bitcoin node."
echo "This script will install TOR, I2P and Bitcoin Core on your computer."
echo "It will also help you configure core to use whatever network combo you need."
if [ -t 0 ]; then
echo "To continue, hit any key."
read -n 1 -s -r -p ""
fi
echo "Making a log file."
echo "Find the log file in the same directory that this script is running."
sleep 2
log_file="install_log.txt"
exec > >(tee -a "$log_file") 2>&1
# Check if the user bitcoin already exists and make it if not.
if id "bitcoin" &>/dev/null; then
echo "User 'bitcoin' already exists."
echo "No need to make a user, Skipping..."
sleep 1
else
# Create a new user named "bitcoin" and set the password
echo "Creating a user called bitcoin..."
sleep 1
if sudo adduser --disabled-password --gecos "" bitcoin; then
echo "User 'bitcoin' created successfully."
echo "Please set the password for the 'bitcoin' user. This will let you log in later."
if sudo passwd bitcoin; then
echo "Password for 'bitcoin' set successfully."
else
echo "Failed to set the password for 'bitcoin'." >&2
exit 1
fi
else
echo "Failed to create the 'bitcoin' user." >&2
exit 1
fi
fi
# Ensure that /home/bitcoin directory exists and set proper permissions
bitcoin_home="/home/bitcoin"
if [ ! -d "$bitcoin_home" ]; then
echo "Creating /home/bitcoin directory..."
if mkdir -p "$bitcoin_home"; then
echo "Directory /home/bitcoin created successfully."
echo "Setting ownership and permissions for /home/bitcoin..."
if chown -R bitcoin:bitcoin "$bitcoin_home"; then
echo "Ownership and permissions set successfully."
if chmod 700 "$bitcoin_home"; then
echo "Permissions set successfully."
else
echo "Failed to set permissions for $bitcoin_home." >&2
exit 1
fi
else
echo "Failed to set ownership for $bitcoin_home." >&2
exit 1
fi
else
echo "Failed to create directory /home/bitcoin." >&2
exit 1
fi
fi
install_tor
install_i2p
# Check if TOR and I2P services are active
use_tor="no"
use_i2p="no"
if systemctl is-active --quiet tor; then
use_tor="yes"
echo "TOR is running."
else
echo "TOR is not running."
fi
if systemctl is-active --quiet i2pd; then
use_i2p="yes"
echo "I2P is running."
else
echo "I2P is not running."
fi
# Check if Bitcoin Core is already installed
if is_bitcoin_core_installed; then
echo "Bitcoin Core is already installed. Moving on to configuration."
else
echo "Bitcoin Core is not installed. Installing dependencies and Bitcoin Core"
install_bitcoin_core_dependencies
download_and_install_bitcoin_core
copy_bitcoin_core_binary "$latest_version"
fi
# Prompt the user and configure Bitcoin Core based on installed services
network="hybrid" # Default to hybrid mode
if [ "$use_tor" == "yes" ] && [ "$use_i2p" == "yes" ]; then
echo "Both TOR and I2P are installed. You can configure your Bitcoin Core to use:"
echo "- Only TOR and I2P traffic (more private, slower IBD)"
echo "- TOR, I2P, and IPV4/6 (normal traffic; less private, faster IBD)"
read -r -p "Hit yes for TOR and I2P only, no for the hybrid configuration [y/n]: " use_both
if [ "${use_both,,}" == "y" ]; then
network="both"
else
network="both_hybrid"
fi
elif [ "$use_tor" == "yes" ]; then
echo "Only TOR is installed. You can configure your Bitcoin Core to use:"
echo "- Only TOR traffic (more private, slower IBD)"
echo "- TOR and IPV4/6 (normal traffic; less private, faster IBD)"
read -r -p "Hit yes for TOR only, no for the hybrid configuration [y/n]: " tor_mode
if [ "${tor_mode,,}" == "y" ]; then
network="tor"
else
network="tor_hybrid"
fi
elif [ "$use_i2p" == "yes" ]; then
echo "Only I2P is installed. You can configure your Bitcoin Core to use:"
echo "- Only I2P traffic (more private, slower IBD)"
echo "- I2P and IPV4/6 (normal traffic; less private, faster IBD)"
read -r -p "Hit yes for I2P only, no for the hybrid configuration [y/n]: " i2p_mode
if [ "${i2p_mode,,}" == "y" ]; then
network="i2p"
else
network="i2p_hybrid"
fi
else
echo "Neither TOR nor I2P is installed. Proceeding with default configuration."
fi
# Create or modify the bitcoin.conf file based on the network choice
create_bitcoin_conf "$network"
# Create systemd service unit for Bitcoin Core
create_bitcoin_core_service
# Reload the systemd daemon to recognize the new service
systemctl daemon-reload
# Start and enable Bitcoin Core service
start_and_enable_bitcoin_core
check_services # Final systems check and exit
# Inform the user that the script has completed successfully
echo "Thanks for running a Bitcoin full node, you're helping to decentralize the network even further!"
echo "You can check your node's sync status with 'bitcoin-cli -getinfo'"
echo "You can check the status of your peer connections with 'bitcoin-cli -netinfo'"
echo "This will show the amount of peers you are connected to for each network."
echo "Your node is not configured for inbound connections. So don't be alarmed when it shows zero."
echo "Your default RPC password is 'craigwrightisnotsatoshi' you should change this."
echo "You can make a new hashed password here 'https://jlopp.github.io/bitcoin-core-rpc-auth-generator/'"
echo "Change it with 'nano /home/bitcoin/.bitcoin/bitcoin.conf' and look for the rpcauth option."
# Exit the script with a success status code
exit 0

503
Bitcoin/lndinstall.sh Normal file
View File

@ -0,0 +1,503 @@
#!/bin/bash
#This is a script to install LND.
#Global Functions.
#Global Functions.
is_package_installed() {
if dpkg -l "$1" 2>/dev/null | grep -q "^ii"; then
echo "$1 is installed."
return 0 # Package is installed
else
echo "$1 is not installed."
return 1 # Package is not installed
fi
}
prompt_yes_no() {
local question="$1"
local default_choice="${2:-yes}"
while true; do
read -p "$question (y/n) [default: $default_choice]: " user_choice
case $user_choice in
[Yy])
echo "yes"
return
;;
[Nn])
echo "no"
return
;;
"")
# If the user just presses Enter, return the default choice
echo "$default_choice"
return
;;
*)
echo "Invalid choice. Please enter 'y' for yes or 'n' for no."
;;
esac
done
}
is_bitcoin_core_installed() {
command -v bitcoind &>/dev/null
}
# Lightning Stuff
# Function to check if Go is installed and upgrade to the latest version if needed
upgrade_go() {
local installed_go_version=$(go version 2>/dev/null | grep -oP 'go[0-9.]+')
local latest_go_version=$(curl -s https://golang.org/dl/ | grep -oP 'https://golang.org/dl/go([0-9.]+).linux-amd64.tar.gz' | head -1 | grep -oP 'go([0-9.]+)')
if [[ -z "$installed_go_version" ]]; then
echo "Go is not installed. Installing the latest version."
elif [[ "$installed_go_version" == "$latest_go_version" ]]; then
echo "Latest version of Go ($installed_go_version) is already installed. Skipping."
return
else
echo "Upgrading Go from $installed_go_version to $latest_go_version."
fi
wget -q "https://golang.org/dl/$latest_go_version.linux-amd64.tar.gz" -P /tmp || {
echo "Failed to download Go. Aborting."
exit 1
}
tar -C /usr/local -xzf "/tmp/$latest_go_version.linux-amd64.tar.gz" || {
echo "Failed to extract Go. Aborting."
exit 1
}
rm "/tmp/$latest_go_version.linux-amd64.tar.gz"
if ! grep -q '/usr/local/go/bin' /etc/profile; then
echo "export PATH=\$PATH:/usr/local/go/bin" >>/etc/profile
echo "Go installation/upgrade completed successfully! Sourcing /etc/profile to update the PATH for the current session."
source /etc/profile
else
echo "Go installation/upgrade completed successfully!"
fi
}
# Function to install LND
install_lnd() {
# Edit the bitcoin.conf file using cat
bitcoin_conf_file="/home/bitcoin/.bitcoin/bitcoin.conf"
if [ -f "$bitcoin_conf_file" ]; then
echo "Editing the bitcoin.conf file..."
cat <<EOF >>"$bitcoin_conf_file"
# [RPC]
debug=rpc
rpcauth='lnd:1628299163766bdce1b3b9d321955971\$dfeb5a806808e3f5f31b46bc8289c79f27f679cfd41b9df1e154ab6588e10ad7'
# [zeromq]
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
EOF
else
echo "Bitcoin configuration file not found at $bitcoin_conf_file. Please ensure Bitcoin Core is correctly configured."
fi
# Restart bitcoind
echo "Restarting bitcoind..."
sudo systemctl restart bitcoind
echo "bitcoind has been restarted."
echo "Checking the latest release of LND..."
latest_release=$(curl -s https://api.github.com/repos/lightningnetwork/lnd/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
lnd_directory="/home/bitcoin/node/lnd"
if [ -d "$lnd_directory" ]; then
echo "LND directory already exists. Skipping cloning."
else
echo "Cloning LND into /home/bitcoin/node/lnd..."
git clone https://github.com/lightningnetwork/lnd "$lnd_directory"
fi
cd "$lnd_directory"
echo "Checking out the latest release of LND (v$latest_release)..."
git checkout "v$latest_release"
echo "Building and installing LND..."
make install
echo "LND has been installed successfully."
# Move lncli binary to /usr/local/bin for system-wide access
echo "Moving lncli binary to /usr/local/bin..."
sudo mv /home/bitcoin/go/bin/lncli /usr/local/bin/
}
# Function to configure LND and create its data folder
configure_lnd() {
echo "Configuring LND..."
# Ask the user for their node name
echo -n "Enter a name for your node: "
read -r node_name
# Create the LND data folder if it doesn't exist
lnd_data_folder="/home/bitcoin/.lnd"
mkdir -p "$lnd_data_folder"
chown bitcoin:bitcoin "$lnd_data_folder"
echo "LND data folder created: $lnd_data_folder"
# Generate LND configuration file
lnd_config_file="/home/bitcoin/.lnd/lnd.conf"
cat <<EOF >"$lnd_config_file"
[Application Options]
# Allow push payments
accept-keysend=1
# Public network name (User-provided node name)
alias=$node_name
# Allow gift routes
allow-circular-route=1
# Reduce the cooperative close chain fee
coop-close-target-confs=1000
# Log levels
debuglevel=CNCT=debug,CRTR=debug,HSWC=debug,NTFN=debug,RPCS=debug
# Mark unpayable, unpaid invoices as deleted
gc-canceled-invoices-on-startup=1
gc-canceled-invoices-on-the-fly=1
# Avoid historical graph data sync
ignore-historical-gossip-filters=1
# Listen (not using Tor? Remove this)
listen=localhost
# Set the maximum amount of commit fees in a channel
max-channel-fee-allocation=1.0
# Set the max timeout blocks of a payment
max-cltv-expiry=5000
# Allow commitment fee to rise on anchor channels
max-commit-fee-rate-anchors=100
# Pending channel limit
maxpendingchannels=10
# Min inbound channel limit
minchansize=5000
# gRPC socket binding
rpclisten=0.0.0.0:10009
restlisten=0.0.0.0:8080
# Avoid high startup overhead
stagger-initial-reconnect=1
# Delete and recreate RPC TLS certificate when details change or cert expires
tlsautorefresh=true
# Do not include IPs in the RPC TLS certificate
tlsdisableautofill=true
[Bitcoin]
# Turn on Bitcoin mode
bitcoin.active=1
# Set the channel confs to wait for channels
bitcoin.defaultchanconfs=2
# Forward fee rate in parts per million
bitcoin.feerate=1000
# Set bitcoin.testnet=1 or bitcoin.mainnet=1 as appropriate
bitcoin.mainnet=1
# Set the lower bound for HTLCs
bitcoin.minhtlc=1
# Set backing node, bitcoin.node=neutrino or bitcoin.node=bitcoind
bitcoin.node=bitcoind
# Set CLTV forwarding delta time
bitcoin.timelockdelta=144
[bitcoind]
# Configuration for using Bitcoin Core backend
# Set the password to what the auth script said
bitcoind.rpcpass=K@iHa$$0
# Set the username
bitcoind.rpcuser=lnd
# Set the ZMQ listeners
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
[bolt]
# Enable database compaction when restarting
db.bolt.auto-compact=true
[protocol]
# Enable large channels support
protocol.wumbo-channels=1
[routerrpc]
# Set minimum desired savings of trying a cheaper path
routerrpc.attemptcost=10
routerrpc.attemptcostppm=10
# Set the number of historical routing records
routerrpc.maxmchistory=10000
# Set the min confidence in a path worth trying
routerrpc.minrtprob=0.005
[routing]
# Remove channels from graph that have one side that hasn't made announcements
routing.strictgraphpruning=1
EOF
chown bitcoin:bitcoin "$lnd_config_file"
echo "LND configuration file created: $lnd_config_file"
# Ask the user about Tor mode and validate input
while true; do
read -rp "Do you want to use Tor only mode or hybrid mode? (Type 'yes' for Tor only mode, 'no' for hybrid mode): " tor_mode
case $tor_mode in
[Yy]es)
echo "Enabling Tor mode in LND..."
;;
[Nn]o)
echo "LND will be configured in hybrid mode (without Tor)."
;;
*)
echo "Invalid input. Please type 'yes' for Tor only mode or 'no' for hybrid mode."
continue
;;
esac
break
done
if [[ "$tor_mode" == "yes" ]]; then
echo -n "Enter a password for LND Tor (this will be used to generate HashedControlPassword in torrc): "
read -r tor_password
# Set Tor configurations in LND conf file for Tor only mode
cat <<EOF >>"$lnd_config_file"
[tor]
tor.active=1
tor.v3=1
tor.socks=127.0.0.1:9050
tor.streamisolation=true
tor.password=$tor_password
tor.privatekeypath=/root/.lnd/v3_onion_private_key
EOF
# Update the torrc file with HashedControlPassword
tor_hashed_password=$(tor --hash-password "$tor_password")
echo "Updating torrc file with HashedControlPassword..."
echo "HashedControlPassword $tor_hashed_password" | sudo tee -a /etc/tor/torrc
sudo systemctl restart tor
echo "LND has been configured in Tor only mode."
else
echo -n "Enter a password for LND Tor (this will be used to generate HashedControlPassword in torrc): "
read -r tor_password
# Set Tor configurations in LND conf file for hybrid mode
cat <<EOF >>"$lnd_config_file"
[tor]
tor.active=1
tor.v3=1
tor.socks=127.0.0.1:9050
tor.streamisolation=false
tor.password=$tor_password
tor.privatekeypath=/root/.lnd/v3_onion_private_key
EOF
# Update the torrc file with HashedControlPassword
tor_hashed_password=$(tor --hash-password "$tor_password")
echo "Updating torrc file with HashedControlPassword..."
echo "HashedControlPassword $tor_hashed_password" | sudo tee -a /etc/tor/torrc
sudo systemctl restart tor
fi
# Create the systemd service file for LND
lnd_service_file="/etc/systemd/system/lnd.service"
cat <<EOF | sudo tee "$lnd_service_file"
[Unit]
Description=LND Lightning Network Daemon
Wants=bitcoind.service
After=bitcoind.service
[Service]
User=bitcoin
LimitNOFILE=65535
ExecStart=/home/bitcoin/go/bin/lnd --configfile=/home/bitcoin/.lnd/lnd.conf
ExecStop=/usr/local/bin/lncli stop
SyslogIdentifier=lnd
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
EOF
# Enable and start the LND service
sudo systemctl enable lnd.service
sudo systemctl start lnd.service
}
# Function to prompt the user to create a wallet
prompt_create_wallet() {
echo "Now it's time to create your wallet. Please press any key to continue and create a new wallet."
# Wait for user input to continue
read -n 1 -s -r -p ""
echo ""
echo -n "Please remember the password you enter for your wallet: "
read -s wallet_password
echo ""
# Run the lncli create command
lncli create
# Create the wallet password file
wallet_password_file="/home/bitcoin/.lnd/wallet_password"
echo "$wallet_password" >"$wallet_password_file"
chown bitcoin:bitcoin "$wallet_password_file"
chmod 400 "$wallet_password_file"
}
# Ride the lightning dashboard stuff
# Install RTL dash (Ride The Lightning)
install_rtl() {
echo "Checking for NPM (Node Package Manager)..."
if ! command -v npm &>/dev/null; then
echo "NPM not found. Installing NPM..."
sleep 1
sudo apt update
sudo apt install -qq -y npm
else
echo "NPM is already installed."
sleep 1
fi
rtl_folder="/home/bitcoin/node/RTL"
echo "Cloning RTL into $rtl_folder..."
git clone https://github.com/Ride-The-Lightning/RTL.git "$rtl_folder"
echo "Entering the RTL folder..."
cd "$rtl_folder"
echo "Running npm install..."
npm install --omit=dev
echo "RTL has been installed successfully."
sleep 1
}
# Configure RTL and plug it into systemd
configure_rtl() {
echo "Configuring RTL..."
sleep 1
# Get the computer's LAN IPv4 address
lan_address=$(ip -4 addr show | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '127.0.0.1' | head -1)
# Ask the user about enabling FIAT conversion
echo "Do you want to enable FIAT conversion? (Type 'yes' for enabling FIAT conversion, 'no' otherwise):"
read -r enable_fiat
rtl_folder="/home/bitcoin/node/RTL"
rtl_config_file="$rtl_folder/RTL-Config.json"
cat <<EOF >"$rtl_config_file"
{
"multiPass": "password",
"port": "3000",
"defaultNodeIndex": 1,
"dbDirectoryPath": "/home/bitcoin/node/RTL/data",
"SSO": {
"rtlSSO": 0
},
"nodes": [
{
"index": 1,
"lnNode": "LND",
"lnImplementation": "LND",
"Authentication": {
"macaroonPath": "/home/bitcoin/.lnd/data/chain/bitcoin/mainnet"
},
"Settings": {
"userPersona": "OPERATOR",
"themeMode": "NIGHT",
"themeColor": "PURPLE",
"channelBackupPath": "/home/bitcoin/bitcoin/node/RTL/backups",
"bitcoindConfigPath": "/home/bitcoin/.bitcoin/bitcoin.conf",
"logLevel": "INFO",
"fiatConversion": "$enable_fiat",
"unannouncedChannels": true,
"lnServerUrl": "https://$lan_address:8080"
}
}
]
}
EOF
echo "RTL configuration file created: $rtl_config_file"
# Create the data folder for RTL
rtl_data_folder="/home/bitcoin/node/RTL/data"
mkdir -p "$rtl_data_folder"
chown bitcoin:bitcoin "$rtl_data_folder"
echo "RTL data folder created: $rtl_data_folder"
echo "RTL has been configured."
# Create and start the systemd service for RTL
rtl_systemd_file="/etc/systemd/system/rtl.service"
cat <<EOF >"$rtl_systemd_file"
[Unit]
Description=Ride The Lightning (RTL) Bitcoin Lightning Network GUI
After=bitcoind.service lnd.service
[Service]
User=bitcoin
Group=bitcoin
Type=simple
ExecStart=/usr/bin/npm --prefix /home/bitcoin/node/RTL run start
[Install]
WantedBy=multi-user.target
EOF
echo "Systemd service file created: $rtl_systemd_file"
sudo systemctl enable rtl
sudo systemctl start rtl
echo "RTL service has been started."
echo "You can access RTL at http://localhost:8080 or http://$lan_address:8080"
}
# Root Check
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root."
exit 1
fi
# Welcom Message
cat <<"EOF"
! .::::::. ... ::: .::.:::::::.. :::. :::. :::. :::. :::. ... :::::::-. .,:::::: ::::::::::. :::. .,-::::: ::: .
! ;;;` ` .;;;;;;;. ';;, ,;;;' ;;;;``;;;; ;;`;; `;;;;, `;;; `;;;;, `;;; .;;;;;;;. ;;, `';,;;;;'''' `;;;```.;;; ;;`;; ,;;;'````' ;;; .;;,.
! '[==/[[[[,,[[ \[[, \[[ .[[/ [[[,/[[[' ,[[ '[[, [[[[[. '[[ [[[[[. '[[,[[ \[[, `[[ [[ [[cccc `]]nnn]]' ,[[ '[[, [[[ [[[[[/'
! ''' $$$$, $$$ Y$c.$$" $$$$$$c c$$$cc$$$c $$$ "Y$c$$ $$$ "Y$c$$$$$, $$$ $$, $$ $$"""" $$$"" c$$$cc$$$c $$$ _$$$$,
! 88b dP"888,_ _,88P Y88P 888b "88bo, 888 888, 888 Y88 888 Y88"888,_ _,88P 888_,o8P' 888oo,__ 888o 888 888,`88bo,__,o, "888"88o,
! "YMmMY" "YMMMMMP" MP MMMM "W" YMM ""` MMM YM MMM YM "YMMMMMP" MMMMP"` """"YUMMM YMMMb YMM ""` "YUMMMMMP" MMM "MMP"
EOF
echo
center_text "Thanks for using Enki's LND install script"
center_text "This script will install LND and RTL on your box."
center_text "To continue, hit any key."
if [ -t 0 ]; then # Check if running in an interactive shell before using "read"
center_text "To continue, hit any key."
read -n 1 -s -r -p ""
fi
echo
# Main part of the script.
# Checks if Bitcoin Core is installed
if is_bitcoin_core_installed; then
echo "Core is installed. Lets "
else
echo "Bitcoin Core is not installed. do you want to install Core?"
fi
install_go # Install Go if it's not already installed
install_lnd # Call the function to install LND
configure_lnd # Call the function to configure LND and create its data folder
prompt_create_wallet # Makes a wallet and adds the auto unlock file.
install_rtl # Installs Ride The Lightning
configure_rtl # makes the RTL config file and plugs it into systemd

504
Bitcoin/lndnew.sh Normal file
View File

@ -0,0 +1,504 @@
#!/bin/bash
#This is a script to install LND.
#--------------------
#Global Functions.
#--------------------
is_package_installed() {
if dpkg -l "$1" 2>/dev/null | grep -q "^ii"; then
echo "$1 is installed."
return 0 # Package is installed
else
echo "$1 is not installed."
return 1 # Package is not installed
fi
}
prompt_yes_no() {
local question="$1"
local default_choice="${2:-yes}"
while true; do
read -p "$question (y/n) [default: $default_choice]: " user_choice
case $user_choice in
[Yy])
echo "yes"
return
;;
[Nn])
echo "no"
return
;;
"")
# If the user just presses Enter, return the default choice
echo "$default_choice"
return
;;
*)
echo "Invalid choice. Please enter 'y' for yes or 'n' for no."
;;
esac
done
}
is_bitcoin_core_installed() {
command -v bitcoind &>/dev/null
}
#--------------------
# Lightning Stuff
#--------------------
# Function to check if Go is installed and upgrade to the latest version if needed
upgrade_go() {
local installed_go_version=$(go version 2>/dev/null | grep -oP 'go[0-9.]+')
local latest_go_version=$(curl -s https://golang.org/dl/ | grep -oP 'https://golang.org/dl/go([0-9.]+).linux-amd64.tar.gz' | head -1 | grep -oP 'go([0-9.]+)')
if [[ -z "$installed_go_version" ]]; then
echo "Go is not installed. Installing the latest version."
elif [[ "$installed_go_version" == "$latest_go_version" ]]; then
echo "Latest version of Go ($installed_go_version) is already installed. Skipping."
return
else
echo "Upgrading Go from $installed_go_version to $latest_go_version."
fi
wget -q "https://golang.org/dl/$latest_go_version.linux-amd64.tar.gz" -P /tmp || {
echo "Failed to download Go. Aborting."
exit 1
}
tar -C /usr/local -xzf "/tmp/$latest_go_version.linux-amd64.tar.gz" || {
echo "Failed to extract Go. Aborting."
exit 1
}
rm "/tmp/$latest_go_version.linux-amd64.tar.gz"
if ! grep -q '/usr/local/go/bin' /etc/profile; then
echo "export PATH=\$PATH:/usr/local/go/bin" >>/etc/profile
echo "Go installation/upgrade completed successfully! Sourcing /etc/profile to update the PATH for the current session."
source /etc/profile
else
echo "Go installation/upgrade completed successfully!"
fi
}
# Function to install LND
install_lnd() {
# Edit the bitcoin.conf file using cat
bitcoin_conf_file="/home/bitcoin/.bitcoin/bitcoin.conf"
if [ -f "$bitcoin_conf_file" ]; then
echo "Editing the bitcoin.conf file..."
cat <<EOF >>"$bitcoin_conf_file"
# [RPC]
debug=rpc
rpcauth='lnd:1628299163766bdce1b3b9d321955971\$dfeb5a806808e3f5f31b46bc8289c79f27f679cfd41b9df1e154ab6588e10ad7'
# [zeromq]
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
EOF
else
echo "Bitcoin configuration file not found at $bitcoin_conf_file. Please ensure Bitcoin Core is correctly configured."
fi
# Restart bitcoind
echo "Restarting bitcoind..."
sudo systemctl restart bitcoind
echo "bitcoind has been restarted."
echo "Checking the latest release of LND..."
latest_release=$(curl -s https://api.github.com/repos/lightningnetwork/lnd/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
lnd_directory="/home/bitcoin/node/lnd"
if [ -d "$lnd_directory" ]; then
echo "LND directory already exists. Skipping cloning."
else
echo "Cloning LND into /home/bitcoin/node/lnd..."
git clone https://github.com/lightningnetwork/lnd "$lnd_directory"
fi
cd "$lnd_directory"
echo "Checking out the latest release of LND (v$latest_release)..."
git checkout "v$latest_release"
echo "Building and installing LND..."
make install
echo "LND has been installed successfully."
# Move lncli binary to /usr/local/bin for system-wide access
echo "Moving lncli binary to /usr/local/bin..."
sudo mv /home/bitcoin/go/bin/lncli /usr/local/bin/
}
# Function to configure LND and create its data folder
configure_lnd() {
echo "Configuring LND..."
# Ask the user for their node name
echo -n "Enter a name for your node: "
read -r node_name
# Create the LND data folder if it doesn't exist
lnd_data_folder="/home/bitcoin/.lnd"
mkdir -p "$lnd_data_folder"
chown bitcoin:bitcoin "$lnd_data_folder"
echo "LND data folder created: $lnd_data_folder"
# Generate LND configuration file
lnd_config_file="/home/bitcoin/.lnd/lnd.conf"
cat <<EOF >"$lnd_config_file"
[Application Options]
# Allow push payments
accept-keysend=1
# Public network name (User-provided node name)
alias=$node_name
# Allow gift routes
allow-circular-route=1
# Reduce the cooperative close chain fee
coop-close-target-confs=1000
# Log levels
debuglevel=CNCT=debug,CRTR=debug,HSWC=debug,NTFN=debug,RPCS=debug
# Mark unpayable, unpaid invoices as deleted
gc-canceled-invoices-on-startup=1
gc-canceled-invoices-on-the-fly=1
# Avoid historical graph data sync
ignore-historical-gossip-filters=1
# Listen (not using Tor? Remove this)
listen=localhost
# Set the maximum amount of commit fees in a channel
max-channel-fee-allocation=1.0
# Set the max timeout blocks of a payment
max-cltv-expiry=5000
# Allow commitment fee to rise on anchor channels
max-commit-fee-rate-anchors=100
# Pending channel limit
maxpendingchannels=10
# Min inbound channel limit
minchansize=5000
# gRPC socket binding
rpclisten=0.0.0.0:10009
restlisten=0.0.0.0:8080
# Avoid high startup overhead
stagger-initial-reconnect=1
# Delete and recreate RPC TLS certificate when details change or cert expires
tlsautorefresh=true
# Do not include IPs in the RPC TLS certificate
tlsdisableautofill=true
[Bitcoin]
# Turn on Bitcoin mode
bitcoin.active=1
# Set the channel confs to wait for channels
bitcoin.defaultchanconfs=2
# Forward fee rate in parts per million
bitcoin.feerate=1000
# Set bitcoin.testnet=1 or bitcoin.mainnet=1 as appropriate
bitcoin.mainnet=1
# Set the lower bound for HTLCs
bitcoin.minhtlc=1
# Set backing node, bitcoin.node=neutrino or bitcoin.node=bitcoind
bitcoin.node=bitcoind
# Set CLTV forwarding delta time
bitcoin.timelockdelta=144
[bitcoind]
# Configuration for using Bitcoin Core backend
# Set the password to what the auth script said
bitcoind.rpcpass=K@iHa$$0
# Set the username
bitcoind.rpcuser=lnd
# Set the ZMQ listeners
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
[bolt]
# Enable database compaction when restarting
db.bolt.auto-compact=true
[protocol]
# Enable large channels support
protocol.wumbo-channels=1
[routerrpc]
# Set minimum desired savings of trying a cheaper path
routerrpc.attemptcost=10
routerrpc.attemptcostppm=10
# Set the number of historical routing records
routerrpc.maxmchistory=10000
# Set the min confidence in a path worth trying
routerrpc.minrtprob=0.005
[routing]
# Remove channels from graph that have one side that hasn't made announcements
routing.strictgraphpruning=1
EOF
chown bitcoin:bitcoin "$lnd_config_file"
echo "LND configuration file created: $lnd_config_file"
# Ask the user about Tor mode and validate input
while true; do
read -rp "Do you want to use Tor only mode or hybrid mode? (Type 'yes' for Tor only mode, 'no' for hybrid mode): " tor_mode
case $tor_mode in
[Yy]es)
echo "Enabling Tor mode in LND..."
;;
[Nn]o)
echo "LND will be configured in hybrid mode (without Tor)."
;;
*)
echo "Invalid input. Please type 'yes' for Tor only mode or 'no' for hybrid mode."
continue
;;
esac
break
done
if [[ "$tor_mode" == "yes" ]]; then
echo -n "Enter a password for LND Tor (this will be used to generate HashedControlPassword in torrc): "
read -r tor_password
# Set Tor configurations in LND conf file for Tor only mode
cat <<EOF >>"$lnd_config_file"
[tor]
tor.active=1
tor.v3=1
tor.socks=127.0.0.1:9050
tor.streamisolation=true
tor.password=$tor_password
tor.privatekeypath=/root/.lnd/v3_onion_private_key
EOF
# Update the torrc file with HashedControlPassword
tor_hashed_password=$(tor --hash-password "$tor_password")
echo "Updating torrc file with HashedControlPassword..."
echo "HashedControlPassword $tor_hashed_password" | sudo tee -a /etc/tor/torrc
sudo systemctl restart tor
echo "LND has been configured in Tor only mode."
else
echo -n "Enter a password for LND Tor (this will be used to generate HashedControlPassword in torrc): "
read -r tor_password
# Set Tor configurations in LND conf file for hybrid mode
cat <<EOF >>"$lnd_config_file"
[tor]
tor.active=1
tor.v3=1
tor.socks=127.0.0.1:9050
tor.streamisolation=false
tor.password=$tor_password
tor.privatekeypath=/root/.lnd/v3_onion_private_key
EOF
# Update the torrc file with HashedControlPassword
tor_hashed_password=$(tor --hash-password "$tor_password")
echo "Updating torrc file with HashedControlPassword..."
echo "HashedControlPassword $tor_hashed_password" | sudo tee -a /etc/tor/torrc
sudo systemctl restart tor
fi
# Create the systemd service file for LND
lnd_service_file="/etc/systemd/system/lnd.service"
cat <<EOF | sudo tee "$lnd_service_file"
[Unit]
Description=LND Lightning Network Daemon
Wants=bitcoind.service
After=bitcoind.service
[Service]
User=bitcoin
LimitNOFILE=65535
ExecStart=/home/bitcoin/go/bin/lnd --configfile=/home/bitcoin/.lnd/lnd.conf
ExecStop=/usr/local/bin/lncli stop
SyslogIdentifier=lnd
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
EOF
# Enable and start the LND service
sudo systemctl enable lnd.service
sudo systemctl start lnd.service
}
# Function to prompt the user to create a wallet
prompt_create_wallet() {
echo "Now it's time to create your wallet. Please press any key to continue and create a new wallet."
# Wait for user input to continue
read -n 1 -s -r -p ""
echo ""
echo -n "Please remember the password you enter for your wallet: "
read -s wallet_password
echo ""
# Run the lncli create command
lncli create
# Create the wallet password file
wallet_password_file="/home/bitcoin/.lnd/wallet_password"
echo "$wallet_password" >"$wallet_password_file"
chown bitcoin:bitcoin "$wallet_password_file"
chmod 400 "$wallet_password_file"
}
# Ride the lightning dashboard stuff
# Install RTL dash (Ride The Lightning)
install_rtl() {
echo "Checking for NPM (Node Package Manager)..."
if ! command -v npm &>/dev/null; then
echo "NPM not found. Installing NPM..."
sleep 1
sudo apt update
sudo apt install -qq -y npm
else
echo "NPM is already installed."
sleep 1
fi
rtl_folder="/home/bitcoin/node/RTL"
echo "Cloning RTL into $rtl_folder..."
git clone https://github.com/Ride-The-Lightning/RTL.git "$rtl_folder"
echo "Entering the RTL folder..."
cd "$rtl_folder"
echo "Running npm install..."
npm install --omit=dev
echo "RTL has been installed successfully."
sleep 1
}
# Configure RTL and plug it into systemd
configure_rtl() {
echo "Configuring RTL..."
sleep 1
# Get the computer's LAN IPv4 address
lan_address=$(ip -4 addr show | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '127.0.0.1' | head -1)
# Ask the user about enabling FIAT conversion
echo "Do you want to enable FIAT conversion? (Type 'yes' for enabling FIAT conversion, 'no' otherwise):"
read -r enable_fiat
rtl_folder="/home/bitcoin/node/RTL"
rtl_config_file="$rtl_folder/RTL-Config.json"
cat <<EOF >"$rtl_config_file"
{
"multiPass": "password",
"port": "3000",
"defaultNodeIndex": 1,
"dbDirectoryPath": "/home/bitcoin/node/RTL/data",
"SSO": {
"rtlSSO": 0
},
"nodes": [
{
"index": 1
"lnNode": "LND",
"lnImplementation": "LND",
"Authentication": {
"macaroonPath": "/home/bitcoin/.lnd/data/chain/bitcoin/mainnet"
},
"Settings": {
"userPersona": "OPERATOR",
"themeMode": "NIGHT",
"themeColor": "PURPLE",
"channelBackupPath": "/home/bitcoin/bitcoin/node/RTL/backups",
"bitcoindConfigPath": "/home/bitcoin/.bitcoin/bitcoin.conf",
"logLevel": "INFO",
"fiatConversion": "$enable_fiat",
"unannouncedChannels": true,
"lnServerUrl": "https://$lan_address:8080"
}
}
]
}
EOF
echo "RTL configuration file created: $rtl_config_file"
# Create the data folder for RTL
rtl_data_folder="/home/bitcoin/node/RTL/data"
mkdir -p "$rtl_data_folder"
chown bitcoin:bitcoin "$rtl_data_folder"
echo "RTL data folder created: $rtl_data_folder"
echo "RTL has been configured."
# Create and start the systemd service for RTL
rtl_systemd_file="/etc/systemd/system/rtl.service"
cat <<EOF >"$rtl_systemd_file"
[Unit]
Description=Ride The Lightning (RTL) Bitcoin Lightning Network GUI
After=bitcoind.service lnd.service
[Service]
User=bitcoin
Group=bitcoin
Type=simple
ExecStart=/usr/bin/npm --prefix /home/bitcoin/node/RTL run start
[Install]
WantedBy=multi-user.target
EOF
echo "Systemd service file created: $rtl_systemd_file"
sudo systemctl enable rtl
sudo systemctl start rtl
echo "RTL service has been started."
echo "You can access RTL at http://localhost:8080 or http://$lan_address:8080"
}
# Root Check
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root."
exit 1
fi
# Welcom Message
cat <<"EOF"
! .::::::. ... ::: .::.:::::::.. :::. :::. :::. :::. :::. ... :::::::-. .,:::::: ::::::::::. :::. .,-::::: ::: .
! ;;;` ` .;;;;;;;. ';;, ,;;;' ;;;;``;;;; ;;`;; `;;;;, `;;; `;;;;, `;;; .;;;;;;;. ;;, `';,;;;;'''' `;;;```.;;; ;;`;; ,;;;'````' ;;; .;;,.
! '[==/[[[[,,[[ \[[, \[[ .[[/ [[[,/[[[' ,[[ '[[, [[[[[. '[[ [[[[[. '[[,[[ \[[, `[[ [[ [[cccc `]]nnn]]' ,[[ '[[, [[[ [[[[[/'
! ''' $$$$, $$$ Y$c.$$" $$$$$$c c$$$cc$$$c $$$ "Y$c$$ $$$ "Y$c$$$$$, $$$ $$, $$ $$"""" $$$"" c$$$cc$$$c $$$ _$$$$,
! 88b dP"888,_ _,88P Y88P 888b "88bo, 888 888, 888 Y88 888 Y88"888,_ _,88P 888_,o8P' 888oo,__ 888o 888 888,`88bo,__,o, "888"88o,
! "YMmMY" "YMMMMMP" MP MMMM "W" YMM ""` MMM YM MMM YM "YMMMMMP" MMMMP"` """"YUMMM YMMMb YMM ""` "YUMMMMMP" MMM "MMP"
EOF
echo
center_text "Thanks for using Enki's LND install script"
center_text "This script will install LND and RTL on your box."
center_text "To continue, hit any key."
if [ -t 0 ]; then # Check if running in an interactive shell before using "read"
center_text "To continue, hit any key."
read -n 1 -s -r -p ""
fi
echo
# Main part of the script.
# Checks if Bitcoin Core is installed
if is_bitcoin_core_installed; then
echo "Core is installed. LFG"
else
echo "Bitcoin Core is not installed. do you want to install Core?"
fi
install_go # Install Go if it's not already installed
install_lnd # Call the function to install LND
configure_lnd # Call the function to configure LND and create its data folder
prompt_create_wallet # Makes a wallet and adds the auto unlock file.
install_rtl # Installs Ride The Lightning
configure_rtl # makes the RTL config file and plugs it into systemd

View File

@ -1,7 +1,4 @@
MIT License MIT License
Copyright (c) 2024 enki
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

View File

@ -1,2 +1,49 @@
# sovran-scripts ```
.::::::. ... ::: .::.:::::::.. :::. :::. :::. .::::::. .,-::::: :::::::.. :::::::::::::. :::::::::::: .::::::.
;;;` ` .;;;;;;;. ';;, ,;;;' ;;;;``;;;; ;;`;; `;;;;, `;;; ;;;` ` ,;;;'````' ;;;;``;;;; ;;; `;;;```.;;;;;;;;;;;'''';;;` `
'[==/[[[[,,[[ \[[,\[[ .[[/ [[[,/[[[' ,[[ '[[, [[[[[. '[[ '[==/[[[[,[[[ [[[,/[[[' [[[ `]]nnn]]' [[ '[==/[[[[,
''' $$$$, $$$ Y$c.$$" $$$$$$c c$$$cc$$$c $$$ "Y$c$$ ''' $$$$ $$$$$$c $$$ $$$"" $$ ''' $
88b dP"888,_ _,88P Y88P 888b "88bo,888 888,888 Y88 88b dP`88bo,__,o, 888b "88bo,888 888o 88, 88b dP
"YMmMY" "YMMMMMP" MP MMMM "W" YMM ""` MMM YM "YMmMY" "YUMMMMMP"MMMM "W" MMM YMMMb MMM "YMmMY"
```
# How to use these scripts
----------------------------
These should work on most Debian based distros that use apt.
If you're using a GUI, then you can download the zip file.
Unzip and open the folder.
Find the script (or set of scripts.) that you want to use right click, look for the permissions section and tick the "run as program" permission.
Right click on a folder select "Open in terminal" then type `ls` this will show whats in the folder
then `sudo ./full_script_name.sh`. You might need to provide an admin password.
If you are running 'headless' and dont have Git installed yet you can run :
`wget https://github.com/Enkimin/Sovran-Scripts/archive/main.tar.gz`\
`tar -xzf main.tar.gz`\
`cd main`\
`ls`\
`cd folder_name`\
`sudo ./script_name.sh`
If Git is installed use :
`git clone https://github.com/Enkimin/Sovran-Scripts.git`\
`cd Sovran-Scripts`\
`ls`\
`cd folder_name`\
`sudo ./script_name.sh`
## Scripts
### List of scripts and what they do.
------------
### coreinstall.sh
- This script walks the user through the process of installing TOR, I2P, and Bitcoin Core plus configures Core to use whatever network is installed.