diff --git a/README.md b/README.md index b42ef9d..978b616 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,32 @@ # Quilibrium Tools -Autoinstaller Script for Quilibrium as a Service + +**Quilibrium for Dummies** + +This script is an all-in-one quil usage software for newcomers. + +For installation and first run, please run + + wget https://raw.githubusercontent.com/0xOzgur/QuilibriumTools/main/quilibrium_for_dummies.sh + chmod u+x quilibrium_for_dummies.sh + ./quilibrium_for_dummies.sh + +After first run, when you need to reach your node, you need to run only; + + ./quilibrium_for_dummies.sh + + + + +**Autoinstaller Script for Quilibrium as a Service** Use below command to install v1.4.18 wget -O - https://raw.githubusercontent.com/0xOzgur/QuilibriumTools/main/install/install_quilibrium_service.sh | bash -If you need to upgrade your node from previous version to 1.4.18, apply below command +**Autoupdater** +If you need to update your node from previous version to 1.4.18, apply below command wget -O - https://raw.githubusercontent.com/0xOzgur/QuilibriumTools/main/update.sh | bash -For easy management of your nodes I created some shortcodes. You can import .profile or .bash_profile (Some Debian installations) file and source. Then you can easily query node related infos. \ No newline at end of file +For easy management of your nodes I created some shortcodes. You can import .profile or .bash_profile (Some Debian installations) file and source. Then you can easily query node related infos. diff --git a/install/install.sh b/install/install.sh index a137db4..e94835d 100644 --- a/install/install.sh +++ b/install/install.sh @@ -110,7 +110,7 @@ cd ~ if [ -d "ceremonyclient" ]; then echo "Directory ceremonyclient already exists, skipping git clone..." else - until git clone https://source.quilibrium.com/quilibrium/ceremonyclient.git; do + until git clone https://source.quilibrium.com/quilibrium/ceremonyclient.git || git clone https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git; do echo "Git clone failed, retrying..." sleep 2 done @@ -156,9 +156,6 @@ Description=Ceremony Client Go App Service Type=simple Restart=always RestartSec=5s -CPUAccounting=true -CPUQuota=${CPU_QUOTA}% - WorkingDirectory=$NODE_PATH ExecStart=$EXEC_START diff --git a/install/install_docker.sh b/install/install_docker.sh index 2780857..6ac03f7 100644 --- a/install/install_docker.sh +++ b/install/install_docker.sh @@ -3,7 +3,7 @@ cd ~ # Step 0: Welcome -echo "This script is made with ❤️ by 0xOzgur.eth" +echo "This script is made with ❤️ by 0xOzgur.eth @ https://quilibrium.space" echo "⏳Enjoy and sit back while you are building your Quilibrium Ceremony Client!" echo "⏳Processing..." sleep 10 # Add a 10-second delay diff --git a/install/install_quilibrium_service.sh b/install/install_quilibrium_service.sh index 2d327e4..094c2e7 100644 --- a/install/install_quilibrium_service.sh +++ b/install/install_quilibrium_service.sh @@ -82,6 +82,7 @@ else done fi cd ~/ceremonyclient/ +git remote set-url origin https://source.quilibrium.com/quilibrium/ceremonyclient.git || git remote set-url origin https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git git checkout release # Set the version number diff --git a/quilibrium_for_dummies.sh b/quilibrium_for_dummies.sh new file mode 100644 index 0000000..f3a05a0 --- /dev/null +++ b/quilibrium_for_dummies.sh @@ -0,0 +1,475 @@ +#!/bin/bash -i + +# Source .bashrc to make GO work if it is not working +source ~/.bashrc + +clear + +# Set the version number +VERSION="1.4.18" + +# Determine the ExecStart line based on the architecture +ARCH=$(uname -m) +OS=$(uname -s) + +# Determine the node binary name based on the architecture and OS +if [ "$ARCH" = "x86_64" ]; then + if [ "$OS" = "Linux" ]; then + NODE_BINARY="node-$VERSION-linux-amd64" + GO_BINARY="go1.20.14.linux-amd64.tar.gz" + elif [ "$OS" = "Darwin" ]; then + NODE_BINARY="node-$VERSION-darwin-amd64" + GO_BINARY="go1.20.14.linux-amd64.tar.gz" + fi +elif [ "$ARCH" = "aarch64" ]; then + if [ "$OS" = "Linux" ]; then + NODE_BINARY="node-$VERSION-linux-arm64" + GO_BINARY="go1.20.14.linux-arm64.tar.gz" + elif [ "$OS" = "Darwin" ]; then + NODE_BINARY="node-$VERSION-darwin-arm64.tar.gz" + GO_BINARY="go1.20.14.linux-arm64.tar.gz" + fi +fi + +# Function for each menu option +install_prerequisites() { +echo "Installing prerequisites..." +sleep 1 # Add a 1-second delay + +echo "Updating the machine" +echo "⏳Processing..." +sleep 1 # Add a 1-second delay + +# Fof DEBIAN OS - Check if sudo and git is installed +# Step 1.1: Prepare Machine +if ! command -v sudo &> /dev/null +then + echo "sudo could not be found" + echo "Installing sudo..." + su -c "apt update && apt install sudo -y" +else + echo "sudo is installed" +fi +# ınstall git if not installed +if ! command -v git &> /dev/null +then + echo "git could not be found" + echo "Installing git..." + su -c "apt update && apt install git -y" +else + echo "git is installed" +fi + +# Update the machine +sudo apt update +sudo apt upgrade -y + +# Install cpu limit and gawk +apt install cpulimit -y +apt install gawk -y #incase it is not installed + +# Download and install Go +wget https://go.dev/dl/$GO_BINARY || { echo "Failed to download Node! Exiting..."; exit_message; exit 1; } +sudo tar -xvf $GO_BINARY || { echo "Failed to extract Go! Exiting..."; exit_message; exit 1; } +sudo mv go /usr/local || { echo "Failed to move go! Exiting..."; exit_message; exit 1; } +sudo rm go1.20.14.linux-amd64.tar.gz || { echo "Failed to remove downloaded archive! Exiting..."; exit_message; exit 1; } + + +# Set Go environment variables +echo "⏳Setting Go environment variables..." +sleep 2 # Add a 2-second delay + +# Check if GOROOT is already set +if grep -q 'GOROOT=/usr/local/go' ~/.bashrc; then + echo "GOROOT already set in ~/.bashrc." +else + echo 'GOROOT=/usr/local/go' >> ~/.bashrc + echo "GOROOT set in ~/.bashrc." +fi + +# Check if GOPATH is already set +if grep -q "GOPATH=$HOME/go" ~/.bashrc; then + echo "GOPATH already set in ~/.bashrc." +else + echo "GOPATH=$HOME/go" >> ~/.bashrc + echo "GOPATH set in ~/.bashrc." +fi + +# Check if PATH is already set +if grep -q 'PATH=$GOPATH/bin:$GOROOT/bin:$PATH' ~/.bashrc; then + echo "PATH already set in ~/.bashrc." +else + echo 'PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >> ~/.bashrc + echo "PATH set in ~/.bashrc." +fi + +# Source .bashrc to apply changes +echo "⏳Sourcing .bashrc to apply changes" +source ~/.bashrc +sleep 2 # Add a 2-second delay + +# Check GO Version +go version +sleep 2 # Add a 2-second delay + +# Install gRPCurl +echo "⏳Installing gRPCurl" +sleep 1 # Add a 1-second delay +go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest +} + +# Install Node +install_node() { + echo "Installing node..." +# Adjust network buffer sizes +echo "Adjusting network buffer sizes..." +if grep -q "^net.core.rmem_max=600000000$" /etc/sysctl.conf; then + echo "net.core.rmem_max=600000000 found inside /etc/sysctl.conf, skipping..." +else + echo -e "\n# Change made to increase buffer sizes for better network performance for ceremonyclient\nnet.core.rmem_max=600000000" | sudo tee -a /etc/sysctl.conf > /dev/null +fi +if grep -q "^net.core.wmem_max=600000000$" /etc/sysctl.conf; then + echo "net.core.wmem_max=600000000 found inside /etc/sysctl.conf, skipping..." +else + echo -e "\n# Change made to increase buffer sizes for better network performance for ceremonyclient\nnet.core.wmem_max=600000000" | sudo tee -a /etc/sysctl.conf > /dev/null +fi +sudo sysctl -p + +# Check if directory ~/ceremonyclient exists, download from github +if [ -d ~/ceremonyclient ]; then + # Check if backup directory ~/backup/qnode_keys exists, if not create it + if [ ! -d ~/backup/qnode_keys ]; then + mkdir -p ~/backup/qnode_keys + fi + + # Check if files exist, then backup + if [ -f ~/ceremonyclient/node/.config/keys.yml ]; then + cp ~/ceremonyclient/node/.config/keys.yml ~/backup/qnode_keys/ + echo "✅ Backup of keys.yml created in ~/backup/qnode_keys folder" + fi + + if [ -f ~/ceremonyclient/node/.config/config.yml ]; then + cp ~/ceremonyclient/node/.config/config.yml ~/backup/qnode_keys/ + echo "✅ Backup of config.yml created in ~/backup/qnode_keys folder" + fi +fi + +# Download Ceremonyclient +echo "⏳Downloading Ceremonyclient" +sleep 1 # Add a 1-second delay +cd ~ +if [ -d "ceremonyclient" ]; then + echo "Directory ceremonyclient already exists, skipping git clone..." +else + until git clone https://source.quilibrium.com/quilibrium/ceremonyclient.git || git clone https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git; do + echo "Git clone failed, retrying..." + sleep 2 + done +fi +cd ~/ceremonyclient/ +git remote set-url origin https://source.quilibrium.com/quilibrium/ceremonyclient.git || git remote set-url origin https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git +git checkout release + + + +# Get the current user's home directory +HOME=$(eval echo ~$HOME_DIR) + +# Use the home directory in the path +NODE_PATH="$HOME/ceremonyclient/node" +EXEC_START="$NODE_PATH/release_autorun.sh" + +# Create Ceremonyclient Service +echo "⏳ Creating Ceremonyclient Service" +sleep 2 # Add a 2-second delay + +# Check if the file exists before attempting to remove it +if [ -f "/lib/systemd/system/ceremonyclient.service" ]; then + # If the file exists, remove it + rm /lib/systemd/system/ceremonyclient.service + echo "ceremonyclient.service file removed." +else + # If the file does not exist, inform the user + echo "ceremonyclient.service file does not exist. No action taken." +fi + +sudo tee /lib/systemd/system/ceremonyclient.service > /dev/null < /dev/null || { echo "Failed to enable gRPC! Exiting..."; exit 1; } + fi +else + echo "gRPC already enabled." +fi + + +# Check if the line listenRESTMultiaddr: /ip4/127.0.0.1/tcp/8338 exists +if ! line_exists "listenRESTMultiaddr: /ip4/127.0.0.1/tcp/8338" .config/config.yml; then + # Check if the line listenRESTMultiaddr: "" exists + if line_exists "listenRESTMultiaddr: \"\"" .config/config.yml; then + # Substitute listenRESTMultiaddr: "" with listenRESTMultiaddr: /ip4/127.0.0.1/tcp/8338 + sudo sed -i 's#^listenRESTMultiaddr:.*$#listenRESTMultiaddr: /ip4/127.0.0.1/tcp/8338#' .config/config.yml || { echo "Failed to enable gRPC! Exiting..."; exit 1; } + else + # Add listenRESTMultiaddr: /ip4/127.0.0.1/tcp/8338 + echo "listenRESTMultiaddr: /ip4/127.0.0.1/tcp/8338" | sudo tee -a .config/config.yml > /dev/null || { echo "Failed to enable gRPC! Exiting..."; exit 1; } + fi +else + echo "gRPC already enabled." +fi + + + +# Enable Stats Collection +echo "Enabling Stats Collection..." +if ! line_exists " statsMultiaddr: \"/dns/stats.quilibrium.com/tcp/443\"" .config/config.yml; then + sudo sed -i '/^ *engine:/a\ statsMultiaddr: "/dns/stats.quilibrium.com/tcp/443"' .config/config.yml || { echo "Failed to enable Stats Collection! Exiting..."; exit 1; } +else + echo "Stats Collection already enabled." +fi + +# Check if both lines were added successfully +if line_exists "listenGrpcMultiaddr: /ip4/127.0.0.1/tcp/8337" .config/config.yml && line_exists " statsMultiaddr: \"/dns/stats.quilibrium.com/tcp/443\"" .config/config.yml; then + echo "Success: The script successfully edited your config.yml file." +else + echo "ERROR: The script failed to correctly edit your config.yml file." + echo "You may want to follow the online guide to do it manually." + exit 1 +fi + +echo "gRPC calls setup was successful." +} + +update_node() { + echo "Updating node..." + service ceremonyclient stop + +apt install cpulimit -y +apt install gawk -y #incase it is not installed + +# Download Binary +echo "⏳ Downloading New Release v$VERSION" +cd ~/ceremonyclient +git remote set-url origin https://source.quilibrium.com/quilibrium/ceremonyclient.git || git remote set-url origin https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git +git pull +git checkout release + +# Get the current user's home directory +HOME=$(eval echo ~$HOME_DIR) + +# Use the home directory in the path +NODE_PATH="$HOME/ceremonyclient/node" +EXEC_START="$NODE_PATH/release_autorun.sh" + +# Re-Create Ceremonyclient Service +echo "⏳ Re-Creating Ceremonyclient Service" +sleep 2 # Add a 2-second delay +SERVICE_FILE="/lib/systemd/system/ceremonyclient.service" +if [ ! -f "$SERVICE_FILE" ]; then + echo "📝 Creating new ceremonyclient service file..." + if ! sudo tee "$SERVICE_FILE" > /dev/null <&2 + exit 1 + fi +else + echo "🔍 Checking existing ceremonyclient service file..." + # Check if the required lines exist and if they are different + if ! grep -q "WorkingDirectory=$NODE_PATH" "$SERVICE_FILE" || ! grep -q "ExecStart=$EXEC_START" "$SERVICE_FILE"; then + echo "🔄 Updating existing ceremonyclient service file..." + # Replace the existing lines with new values + sudo sed -i "s|WorkingDirectory=.*|WorkingDirectory=$NODE_PATH|" "$SERVICE_FILE" + sudo sed -i "s|ExecStart=.*|ExecStart=$EXEC_START|" "$SERVICE_FILE" + else + echo "✅ No changes needed." + fi +fi + +# Start the ceremonyclient service +echo "✅ Starting Ceremonyclient Service" +sleep 2 # Add a 2-second delay +sudo systemctl daemon-reload +sudo systemctl enable ceremonyclient +sudo service ceremonyclient start + +# See the logs of the ceremonyclient service +echo "🎉 Welcome to Quilibrium Ceremonyclient v$VERSION" +} + +check_visibility() { + echo "⏳Processing..." + sleep 2 # Add a 2-second delay + + # Bootstrap peer list + bootstrap_peers=( + "EiDpYbDwT2rZq70JNJposqAC+vVZ1t97pcHbK8kr5G4ZNA==" + "EiCcVN/KauCidn0nNDbOAGMHRZ5psz/lthpbBeiTAUEfZQ==" + "EiDhVHjQKgHfPDXJKWykeUflcXtOv6O2lvjbmUnRrbT2mw==" + "EiDHhTNA0yf07ljH+gTn0YEk/edCF70gQqr7QsUr8RKbAA==" + "EiAnwhEcyjsHiU6cDCjYJyk/1OVsh6ap7E3vDfJvefGigw==" + "EiB75ZnHtAOxajH2hlk9wD1i9zVigrDKKqYcSMXBkKo4SA==" + "EiDEYNo7GEfMhPBbUo+zFSGeDECB0RhG0GfAasdWp2TTTQ==" + "EiCzMVQnCirB85ITj1x9JOEe4zjNnnFIlxuXj9m6kGq1SQ==" + ) + + # Run the grpcurl command and capture its output + output=$(grpcurl -plaintext localhost:8337 quilibrium.node.node.pb.NodeService.GetNetworkInfo) + + # Check if any of the specific peers are in the output + visible=false + for peer in "${bootstrap_peers[@]}"; do + if [[ $output == *"$peer"* ]]; then + visible=true + echo "You see $peer as a bootstrap peer" + else + echo "Peer $peer not found" + fi + done + + if $visible ; then + echo "Great, your node is visible!" + else + echo "Sorry, your node is not visible. Please restart your node and try again." + fi +} + +node_info() { + echo "Getting node info..." + cd ~/ceremonyclient/node && ./$NODE_BINARY -node-info +} + + +node_logs() { + echo "Getting node logs..." + sudo journalctl -u ceremonyclient.service -f --no-hostname -o cat + # sudo journalctl -u ceremonyclient.service -n 100 --no-hostname -o cat +} + +restart_node() { + echo "Restarting node..." + service ceremonyclient restart +} + +stop_node() { + echo "Stopping node..." + service ceremonyclient stop + echo "Node stopped" +} + + +# Menu +while true; do + clear + echo "This script is made with ❤️ by 0xOzgur.eth @ https://quilibrium.space" + echo "Welcome to Quilibrium for Dummies!" + +echo " + _____ _ _ _ _ _ + / ___ \ (_) (_) | (_) + | | | |_ _ _| |_| | _ ____ _ _ _ ____ + | | |_| | | | | | | || \ / ___) | | | | \ + \ \____| |_| | | | | |_) ) | | | |_| | | | | + \_____)\____|_|_|_|____/|_| |_|\____|_|_|_| + + ___ + / __) + | |__ ___ ____ + | __) _ \ / ___) + | | | |_| | | + _| \___/|_| + + _____ _ + (____ \ (_) + _ \ \ _ _ ____ ____ _ ____ ___ + | | | | | | | \| \| |/ _ )/___) + | |__/ /| |_| | | | | | | | ( (/ /|___ | + |_____/ \____|_|_|_|_|_|_|_|\____|___/ + " + + + + echo "Please choose an option:" + + echo "1) Install Prerequisites" + echo "2) Install Node" + echo "3) Configure grpCurl" + echo "4) Update Node" + echo "5) Check Visibility" + echo "6) Node Info" + echo "7) Node Logs" + echo "8) Restart Node" + echo "9) Stop Node" + echo "e) Exit" + + read -p "Enter your choice: " choice + + case $choice in + 1) install_prerequisites ;; + 2) install_node ;; + 3) configure_grpcurl ;; + 4) update_node ;; + 5) check_visibility ;; + 6) node_info ;; + 7) node_logs ;; + 8) restart_node ;; + 9) stop_node ;; + e) break ;; + *) echo "Invalid option, please try again." ;; + esac + + read -n 1 -s -r -p "Press any key to continue" +done \ No newline at end of file diff --git a/update.sh b/update.sh index bd7bba3..dd1014a 100644 --- a/update.sh +++ b/update.sh @@ -1,7 +1,7 @@ #!/bin/bash # Step 0: Welcome -echo "This script is made with ❤️ by https://quilibrium.space @ 0xOzgur.eth" +echo "This script is made with ❤️ by 0xOzgur.eth @ https://quilibrium.space" echo "⏳Enjoy and sit back while you are upgrading your Quilibrium Node to v1.4.18!" echo "The script is prepared for Ubuntu machines. If you are using another operating system, please check the compatibility of the script." echo "⏳Processing..." diff --git a/visibility_check.sh b/visibility_check.sh new file mode 100644 index 0000000..cb8ed7a --- /dev/null +++ b/visibility_check.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Step 0: Welcome +echo "This script is made with ❤️ by 0xOzgur.eth @ https://quilibrium.space" +echo "⏳You need GO and grpcurl installed and configured on your machine to run this script. If you don't have them, please install and configure grpcurl first." +echo "You can find the installation instructions at https://docs.quilibrium.space/installing-prerequisites" +echo "⏳Processing..." +sleep 5 # Add a 5-second delay + +# Bootstrap peer list +bootstrap_peers=( +"EiDpYbDwT2rZq70JNJposqAC+vVZ1t97pcHbK8kr5G4ZNA==" +"EiCcVN/KauCidn0nNDbOAGMHRZ5psz/lthpbBeiTAUEfZQ==" +"EiDhVHjQKgHfPDXJKWykeUflcXtOv6O2lvjbmUnRrbT2mw==" +"EiDHhTNA0yf07ljH+gTn0YEk/edCF70gQqr7QsUr8RKbAA==" +"EiAnwhEcyjsHiU6cDCjYJyk/1OVsh6ap7E3vDfJvefGigw==" +"EiB75ZnHtAOxajH2hlk9wD1i9zVigrDKKqYcSMXBkKo4SA==" +"EiDEYNo7GEfMhPBbUo+zFSGeDECB0RhG0GfAasdWp2TTTQ==" +"EiCzMVQnCirB85ITj1x9JOEe4zjNnnFIlxuXj9m6kGq1SQ==" +) + +# Run the grpcurl command and capture its output +output=$(grpcurl -plaintext localhost:8337 quilibrium.node.node.pb.NodeService.GetNetworkInfo) + +# Check if any of the specific peers are in the output +visible=false +for peer in "${bootstrap_peers[@]}"; do + if [[ $output == *"$peer"* ]]; then + visible=true + echo "You see $peer as a bootstrap peer" + else + echo "Peer $peer not found" + fi +done + +if $visible ; then + echo "Great, your node is visible!" +else + echo "Sorry, your node is not visible. Please restart your node and try again." +fi \ No newline at end of file