├── LICENSE ├── README.md ├── debug ├── qnode_balance_checker.sh └── qone_menu_debug.sh ├── old ├── CPU_perf_boost.sh ├── qnode_autoupdate_setup.sh ├── qnode_balance_checker.py ├── qnode_binary_rollback.sh ├── qnode_binary_rollback_cluster.sh ├── qnode_proof_rate.sh ├── qnode_restart.sh ├── qnode_service_installer_autorun.sh ├── qnode_service_installer_bin_cpuquota.sh ├── qnode_service_installer_bin_no_ht.sh ├── qnode_service_installer_old.sh ├── qnode_service_only_installer.sh ├── qnode_service_update_autorun.sh ├── qnode_service_update_cpulimit.sh ├── qnode_service_update_nameservers.sh ├── qnode_service_update_old.sh ├── qnode_store_backup_idrive.sh ├── qnode_system_cleanup_2.sh ├── qone_old.sh ├── qone_setup_old.sh ├── release_autorun_createnew.sh ├── server_setup.sh └── store_kickstart.sh ├── qnode_service_installer.sh ├── qnode_service_update.sh ├── qone.sh ├── test ├── qnode_autoupdate_edit_timer.sh ├── qnode_balancelog_migration.sh ├── qnode_check_frames.sh ├── qnode_check_frames_installer.sh ├── qnode_check_peers.sh ├── qnode_cleanup_releases_test.sh ├── qnode_cpulimit_check.sh ├── qnode_monitor_proofs.sh ├── qnode_monitor_proofs_autorestarter.sh ├── qnode_monitor_proofs_autorestarter_installer.sh ├── qnode_service_change_autorun_to_bin_2.sh ├── test_script.sh └── testnet.sh └── tools ├── CPU_test.sh ├── qclient_actions.sh ├── qclient_install.sh ├── qnode_backup_restore_storj.sh ├── qnode_backup_storj.sh ├── qnode_balance_checker.sh ├── qnode_balance_checker_installer.sh ├── qnode_balance_log_download.sh ├── qnode_cpuquota_remover.sh ├── qnode_cron_manager.sh ├── qnode_download_node_binary.sh ├── qnode_firewall_setup.sh ├── qnode_gRPC_calls_setup.sh ├── qnode_gsheet_config_update.sh ├── qnode_listen_multiaddr_updater.sh ├── qnode_oom_sys_restart_installer.sh ├── qnode_peermanifest_checker.sh ├── qnode_proof_monitor.sh ├── qnode_rewards_monitor.sh ├── qnode_server_revert.sh ├── qnode_service_change_autorun_to_bin.sh ├── qnode_service_update_forced.sh ├── qnode_store_backup_aws.sh ├── qnode_store_snapshot_storj.sh ├── qnode_system_cleanup.sh ├── qnode_update_quick_check.sh ├── qnode_visibility_check.sh ├── qnode_visibility_check_autorestart.sh ├── qnode_visibility_check_installer.sh └── server_setup.sh /README.md: -------------------------------------------------------------------------------- 1 | # Quilibrium node setup guide and auto-installer script 2 | >[!WARNING] 3 | > Before using any of the scripts in this repo, please read the [guide on Gitbook](https://iri.quest/quilibrium-node-guide). 4 | 5 | [![image-text](https://i.imgur.com/2YYGhuc.jpeg)](https://docs.quilibrium.one) 6 | -------------------------------------------------------------------------------- /debug/qnode_balance_checker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Set timezone to Europe/Rome 4 | export TZ="Europe/Rome" 5 | echo "🔧 DEBUG: Timezone set to $TZ" 6 | 7 | # Script version 8 | SCRIPT_VERSION="1.5.8" 9 | echo "📌 DEBUG: Script version: $SCRIPT_VERSION" 10 | 11 | # Function to check for newer script version 12 | check_for_updates() { 13 | echo "🔄 DEBUG: Checking for script updates..." 14 | LATEST_VERSION=$(wget -qO- "https://github.com/lamat1111/QuilibriumScripts/raw/main/tools/qnode_balance_checker.sh" | grep 'SCRIPT_VERSION="' | head -1 | cut -d'"' -f2) 15 | echo "📊 DEBUG: Latest version available: $LATEST_VERSION" 16 | echo "📊 DEBUG: Current version: $SCRIPT_VERSION" 17 | 18 | if [ "$SCRIPT_VERSION" != "$LATEST_VERSION" ]; then 19 | echo "⚡ DEBUG: New version found! Updating script..." 20 | wget -O ~/scripts/qnode_balance_checker.sh "https://github.com/lamat1111/QuilibriumScripts/raw/main/tools/qnode_balance_checker.sh" 21 | chmod +x ~/scripts/qnode_balance_checker.sh 22 | echo "✅ DEBUG: Script updated successfully" 23 | sleep 1 24 | else 25 | echo "✅ DEBUG: Script is up to date" 26 | fi 27 | } 28 | 29 | # Check for updates and update if available 30 | echo "🔍 DEBUG: Starting update check process..." 31 | #check_for_updates 32 | 33 | # Function to get the node binary name 34 | get_node_binary() { 35 | echo "🔍 DEBUG: Looking for node binary..." 36 | local node_dir="$HOME/ceremonyclient/node" 37 | echo "📂 DEBUG: Searching in directory: $node_dir" 38 | 39 | local binary_name 40 | binary_name=$(find "$node_dir" -name "node-[0-9]*" ! -name "*.dgst*" ! -name "*.sig*" -type f -executable 2>/dev/null | sort -V | tail -n 1 | xargs basename) 41 | 42 | if [ -z "$binary_name" ]; then 43 | echo "❌ DEBUG: No executable node binary found in $node_dir" 44 | return 1 45 | fi 46 | 47 | echo "✅ DEBUG: Found binary: $binary_name" 48 | echo "$binary_name" 49 | } 50 | 51 | # Function to get the unclaimed balance 52 | get_unclaimed_balance() { 53 | echo "💰 DEBUG: Getting unclaimed balance..." 54 | local node_directory="$HOME/ceremonyclient/node" 55 | echo "📂 DEBUG: Node directory: $node_directory" 56 | 57 | local NODE_BINARY 58 | NODE_BINARY=$(get_node_binary) 59 | echo "🔧 DEBUG: Using binary: $NODE_BINARY" 60 | 61 | if [ "$NODE_BINARY" == "ERROR:"* ]; then 62 | echo "❌ DEBUG: Failed to get node binary" 63 | echo "ERROR" 64 | return 1 65 | fi 66 | 67 | local node_command="./$NODE_BINARY -balance" 68 | echo "🔧 DEBUG: Executing command: $node_command" 69 | 70 | local output 71 | output=$(cd "$node_directory" && $node_command 2>&1) 72 | echo "📝 DEBUG: Raw output: $output" 73 | 74 | local balance 75 | balance=$(echo "$output" | grep "Owned balance" | awk '{print $3}' | sed 's/QUIL//g' | tr -d ' ') 76 | echo "💵 DEBUG: Extracted balance: $balance" 77 | 78 | if [[ "$balance" =~ ^[0-9.]+$ ]]; then 79 | echo "✅ DEBUG: Valid balance found" 80 | echo "$balance" 81 | else 82 | echo "❌ DEBUG: Invalid balance format" 83 | echo "ERROR" 84 | fi 85 | } 86 | 87 | # Function to write data to CSV file 88 | write_to_csv() { 89 | echo "📝 DEBUG: Starting CSV write process..." 90 | local filename="$HOME/scripts/balance_log.csv" 91 | local data="$1" 92 | 93 | echo "📂 DEBUG: CSV file path: $filename" 94 | echo "📊 DEBUG: Data to write: $data" 95 | 96 | if [ ! -f "$filename" ] || [ ! -s "$filename" ]; then 97 | echo "📝 DEBUG: Creating new CSV file with headers" 98 | echo "time,balance" > "$filename" 99 | else 100 | echo "✅ DEBUG: CSV file exists" 101 | fi 102 | 103 | # Split the data into time and balance 104 | local time=$(echo "$data" | cut -d',' -f1) 105 | local balance=$(echo "$data" | cut -d',' -f2) 106 | echo "⏰ DEBUG: Time: $time" 107 | echo "💰 DEBUG: Balance: $balance" 108 | 109 | # Only process if balance is not an error 110 | if [ "$balance" != "ERROR" ]; then 111 | # Round to 2 decimal places and replace dot with comma 112 | balance=$(printf "%.2f" "$balance" | sed 's/\./,/') 113 | echo "💵 DEBUG: Formatted balance: $balance" 114 | 115 | # Format the data with quotes 116 | local formatted_data="\"$time\",\"$balance\"" 117 | echo "📊 DEBUG: Formatted data: $formatted_data" 118 | echo "$formatted_data" >> "$filename" 119 | echo "✅ DEBUG: Data written to CSV successfully" 120 | else 121 | echo "❌ DEBUG: Error: Failed to retrieve balance." 122 | exit 1 123 | fi 124 | } 125 | 126 | # Main function 127 | main() { 128 | echo "🚀 DEBUG: Starting main function..." 129 | 130 | local current_time 131 | current_time=$(date +'%d/%m/%Y %H:%M') 132 | echo "⏰ DEBUG: Current time: $current_time" 133 | 134 | local balance 135 | echo "💰 DEBUG: Getting balance..." 136 | balance=$(get_unclaimed_balance) 137 | echo "💵 DEBUG: Retrieved balance: $balance" 138 | 139 | if [ "$balance" != "ERROR" ]; then 140 | local data_to_write="$current_time,$balance" 141 | echo "📊 DEBUG: Preparing to write data: $data_to_write" 142 | write_to_csv "$data_to_write" 143 | echo "✅ DEBUG: Main function completed successfully" 144 | else 145 | echo "❌ DEBUG: Error: Failed to retrieve balance." 146 | exit 1 147 | fi 148 | } 149 | 150 | # Run main function 151 | echo "🎬 DEBUG: Starting script execution..." 152 | main 153 | echo "🏁 DEBUG: Script execution completed" -------------------------------------------------------------------------------- /debug/qone_menu_debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Color codes for output formatting 4 | RED='\033[0;31m' 5 | GREEN='\033[0;32m' 6 | YELLOW='\033[0;33m' 7 | BLUE='\033[0;34m' 8 | NC='\033[0m' # No Color 9 | 10 | # Function to print formatted debug messages 11 | debug_print() { 12 | local color=$1 13 | local message=$2 14 | echo -e "${color}${message}${NC}" 15 | } 16 | 17 | # Function to compare versions 18 | version_gt() { 19 | test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" 20 | } 21 | 22 | # Debug function for Node 23 | debug_node() { 24 | debug_print $BLUE "\n=== Debugging Node Installation ===" 25 | 26 | # Check Node installation directory 27 | NODE_DIR="$HOME/ceremonyclient/node" 28 | if [ -d "$NODE_DIR" ]; then 29 | debug_print $GREEN "✅ Node directory found: $NODE_DIR" 30 | else 31 | debug_print $RED "❌ Node directory not found at $NODE_DIR" 32 | debug_print $YELLOW "Suggestion: Ensure you've installed the Node correctly. Run the installation script if needed." 33 | return 34 | fi 35 | 36 | # Find Node binary 37 | NODE_BINARY=$(find "$NODE_DIR" -name "node-*" -type f -executable 2>/dev/null | sort -V | tail -n 1) 38 | if [ -n "$NODE_BINARY" ]; then 39 | debug_print $GREEN "✅ Node binary found: $NODE_BINARY" 40 | CURRENT_NODE_VERSION=$(basename "$NODE_BINARY" | grep -oP 'node-\K[0-9]+(\.[0-9]+){2,3}') 41 | debug_print $GREEN "Current Node version: $CURRENT_NODE_VERSION" 42 | else 43 | debug_print $RED "❌ No executable Node binary found in $NODE_DIR" 44 | debug_print $YELLOW "Suggestion: Check if the Node was installed correctly. You might need to reinstall." 45 | return 46 | fi 47 | 48 | # Check latest Node version 49 | LATEST_NODE_VERSION=$(curl -s https://releases.quilibrium.com/release | grep -oP 'node-\K[0-9]+(\.[0-9]+){2,3}' | sort -V | tail -n 1) 50 | if [ -n "$LATEST_NODE_VERSION" ]; then 51 | debug_print $GREEN "Latest Node version from server: $LATEST_NODE_VERSION" 52 | else 53 | debug_print $RED "❌ Failed to fetch latest Node version from server" 54 | debug_print $YELLOW "Suggestion: Check your internet connection or try again later." 55 | return 56 | fi 57 | 58 | # Compare versions 59 | if version_gt "$LATEST_NODE_VERSION" "$CURRENT_NODE_VERSION"; then 60 | debug_print $YELLOW "⚠️ Node update is needed" 61 | else 62 | debug_print $GREEN "✅ Node is up to date" 63 | fi 64 | } 65 | 66 | # Debug function for Qclient 67 | debug_qclient() { 68 | debug_print $BLUE "\n=== Debugging Qclient Installation ===" 69 | 70 | # Check Qclient installation directory 71 | CLIENT_DIR="$HOME/ceremonyclient/client" 72 | if [ -d "$CLIENT_DIR" ]; then 73 | debug_print $GREEN "✅ Qclient directory found: $CLIENT_DIR" 74 | else 75 | debug_print $RED "❌ Qclient directory not found at $CLIENT_DIR" 76 | debug_print $YELLOW "Suggestion: Ensure you've installed the Qclient correctly. Run the installation script if needed." 77 | return 78 | fi 79 | 80 | # Find Qclient binary 81 | QCLIENT_BINARY=$(find "$CLIENT_DIR" -name "qclient-*" -type f -executable 2>/dev/null | sort -V | tail -n 1) 82 | if [ -n "$QCLIENT_BINARY" ]; then 83 | debug_print $GREEN "✅ Qclient binary found: $QCLIENT_BINARY" 84 | CURRENT_QCLIENT_VERSION=$(basename "$QCLIENT_BINARY" | grep -oP 'qclient-\K[0-9]+(\.[0-9]+){2,3}') 85 | debug_print $GREEN "Current Qclient version: $CURRENT_QCLIENT_VERSION" 86 | else 87 | debug_print $RED "❌ No executable Qclient binary found in $CLIENT_DIR" 88 | debug_print $YELLOW "Suggestion: Check if the Qclient was installed correctly. You might need to reinstall." 89 | return 90 | fi 91 | 92 | # Check latest Qclient version 93 | LATEST_QCLIENT_VERSION=$(curl -s https://releases.quilibrium.com/qclient-release | grep -oP 'qclient-\K[0-9]+(\.[0-9]+){2,3}' | sort -V | tail -n 1) 94 | if [ -n "$LATEST_QCLIENT_VERSION" ]; then 95 | debug_print $GREEN "Latest Qclient version from server: $LATEST_QCLIENT_VERSION" 96 | else 97 | debug_print $RED "❌ Failed to fetch latest Qclient version from server" 98 | debug_print $YELLOW "Suggestion: Check your internet connection or try again later." 99 | return 100 | fi 101 | 102 | # Compare versions 103 | if version_gt "$LATEST_QCLIENT_VERSION" "$CURRENT_QCLIENT_VERSION"; then 104 | debug_print $YELLOW "⚠️ Qclient update is needed" 105 | else 106 | debug_print $GREEN "✅ Qclient is up to date" 107 | fi 108 | } 109 | 110 | # Main execution 111 | echo "Starting Q1 Debug Script..." 112 | debug_node 113 | debug_qclient 114 | echo -e "\nDebug process completed. If you're still experiencing issues, please share this output with the support team." -------------------------------------------------------------------------------- /old/CPU_perf_boost.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Function to check if the system is Linux and has an AMD processor 4 | check_system_compatibility() { 5 | # Check if the system is Linux 6 | if [[ "$(uname)" != "Linux" ]]; then 7 | echo "Error: This script is intended for Linux systems only." 8 | exit 1 9 | fi 10 | 11 | # Check if the processor is AMD 12 | if ! grep -qi "amd" /proc/cpuinfo; then 13 | echo "Error: This script is intended for AMD processors only." 14 | exit 1 15 | fi 16 | 17 | echo "System compatibility check passed. Proceeding with the script." 18 | } 19 | 20 | 21 | # Function to check if the script is run with sudo 22 | check_sudo() { 23 | if [ "$EUID" -ne 0 ]; then 24 | echo "Please run this script with sudo or as root." 25 | exit 1 26 | fi 27 | } 28 | 29 | # Updated function to check and install dependencies 30 | check_and_install_dependencies() { 31 | local dependencies=("linux-tools-generic" "cpufrequtils") 32 | local to_install=() 33 | 34 | for dep in "${dependencies[@]}"; do 35 | if ! dpkg -s "$dep" >/dev/null 2>&1; then 36 | to_install+=("$dep") 37 | fi 38 | done 39 | 40 | # Check for kernel-specific tools 41 | local kernel_version=$(uname -r) 42 | local kernel_tools="linux-tools-$kernel_version" 43 | local cloud_tools="linux-cloud-tools-$kernel_version" 44 | 45 | if ! dpkg -s "$kernel_tools" >/dev/null 2>&1; then 46 | to_install+=("$kernel_tools") 47 | fi 48 | if ! dpkg -s "$cloud_tools" >/dev/null 2>&1; then 49 | to_install+=("$cloud_tools") 50 | fi 51 | 52 | if [ ${#to_install[@]} -ne 0 ]; then 53 | echo "Installing required dependencies: ${to_install[*]}" 54 | apt install update 55 | apt install install -y "${to_install[@]}" 56 | else 57 | echo "All required dependencies are already installed." 58 | fi 59 | } 60 | 61 | # Function to perform system updates 62 | update_system() { 63 | apt install update 64 | apt install upgrade -y 65 | apt install dist-upgrade -y 66 | apt install autoremove -y 67 | apt install autoclean 68 | } 69 | 70 | # Function to check and install specific kernel version 71 | check_and_install_kernel() { 72 | local desired_kernel="5.19.0-50-generic" 73 | if uname -r | grep -q "$desired_kernel"; then 74 | echo "Kernel $desired_kernel is already installed. Skipping kernel installation." 75 | else 76 | echo "Installing kernel $desired_kernel..." 77 | apt install install linux-image-$desired_kernel linux-headers-$desired_kernel -y 78 | fi 79 | } 80 | 81 | # Function to modify GRUB configuration 82 | modify_grub() { 83 | sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=".*"/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amd_pstate=passive"/' /etc/default/grub 84 | update-grub 85 | } 86 | 87 | # Function to set CPU governor to performance 88 | set_cpu_governor() { 89 | echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 90 | } 91 | 92 | # Function to display system info 93 | display_system_info() { 94 | echo "================================================" 95 | echo "Current System State:" 96 | echo "================================================" 97 | echo "Kernel version:" 98 | uname -r 99 | echo "" 100 | echo "CPU frequency scaling driver:" 101 | cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver | sort | uniq 102 | echo "" 103 | echo "CPU frequency info:" 104 | cpupower frequency-info 105 | echo "================================================" 106 | } 107 | 108 | # Main script execution 109 | check_system_compatibility 110 | check_sudo 111 | check_and_install_dependencies 112 | 113 | echo "Updating system..." 114 | update_system 115 | 116 | echo "Current kernel version:" 117 | uname -r 118 | 119 | check_and_install_kernel 120 | 121 | echo "Modifying GRUB configuration..." 122 | modify_grub 123 | 124 | echo "Setting CPU governor to performance..." 125 | set_cpu_governor 126 | 127 | echo "Script execution complete." 128 | 129 | display_system_info 130 | echo 131 | echo "================================================" 132 | echo "Please manually reboot your system to complete the process." 133 | echo "After reboot, the new kernel version (if installed) and GRUB changes will take effect." 134 | echo "To reboot, use the command: sudo reboot" 135 | echo "" 136 | echo "After rebooting, run these commands to see the updated system state:" 137 | echo "cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver | sort | uniq" 138 | echo "sudo cpupower frequency-info" 139 | echo "================================================" 140 | -------------------------------------------------------------------------------- /old/qnode_autoupdate_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Function to check if running with sudo 4 | check_sudo() { 5 | if [ "$EUID" -ne 0 ]; then 6 | echo "Please run as root or with sudo" 7 | exit 1 8 | fi 9 | } 10 | 11 | # Function to download and execute the latest script 12 | download_update_script() { 13 | mkdir -p ${HOME}/scripts && \ 14 | curl -sSL "https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/qnode_service_update.sh" -o ${HOME}/scripts/qnode_service_update.sh && \ 15 | chmod +x ${HOME}/scripts/qnode_service_update.sh 16 | } 17 | 18 | # Function to create service file 19 | create_service_file() { 20 | # Store the current user's home directory 21 | CURRENT_HOME=${HOME} 22 | 23 | cat << EOF > /etc/systemd/system/qnode-autoupdate.service 24 | [Unit] 25 | Description=QNode Service Update Script 26 | After=network.target 27 | 28 | [Service] 29 | Type=oneshot 30 | ExecStart=/bin/bash ${CURRENT_HOME}/scripts/qnode_service_update.sh 31 | User=$(id -un) 32 | StandardOutput=journal 33 | StandardError=journal 34 | 35 | [Install] 36 | WantedBy=multi-user.target 37 | EOF 38 | } 39 | 40 | # Timer - once every 12 hrs 41 | # [Unit] 42 | # Description=Run QNode Service Update every 12 hours at a consistent time 43 | 44 | # [Timer] 45 | # OnBootSec=5min 46 | # # Runs every 12 hours 47 | # OnCalendar=*-*-* 0/12:00:00 48 | # # One initial random delay up to 12 hours that becomes fixed 49 | # RandomizedDelaySec=43200 50 | # # This is key - makes the random delay consistent 51 | # FixedRandomDelay=true 52 | # # Persistent=true ensures the timing persists across reboots 53 | # Persistent=true 54 | # Unit=qnode-autoupdate.service 55 | 56 | # [Install] 57 | # WantedBy=timers.target 58 | 59 | # Timer - once every 5 mins 60 | # [Unit] 61 | # Description=Run QNode Service Update every 5 minutes at a fixed second offset 62 | 63 | # [Timer] 64 | # OnBootSec=5min 65 | # OnCalendar=*:0/5 66 | # RandomizedDelaySec=300sec 67 | # FixedRandomDelay=true 68 | # Persistent=true 69 | # Unit=qnode-autoupdate.service 70 | 71 | # [Install] 72 | # WantedBy=timers.target 73 | 74 | # Function to create timer file - once every 1 hr 75 | create_timer_file() { 76 | cat << EOF > /etc/systemd/system/qnode-autoupdate.timer 77 | [Unit] 78 | Description=Run QNode Service Update every hour at a fixed minute 79 | 80 | [Timer] 81 | OnBootSec=5min 82 | OnCalendar=hourly 83 | RandomizedDelaySec=3600sec 84 | FixedRandomDelay=true 85 | Persistent=true 86 | Unit=qnode-autoupdate.service 87 | 88 | [Install] 89 | WantedBy=timers.target 90 | EOF 91 | } 92 | 93 | # Function to activate service and timer 94 | activate_service_and_timer() { 95 | systemctl daemon-reload 96 | systemctl enable qnode-autoupdate.timer 97 | systemctl start qnode-autoupdate.timer 98 | echo "✅ Auto updates are ON." 99 | } 100 | 101 | # Main script logic 102 | main() { 103 | check_sudo 104 | download_update_script 105 | 106 | if systemctl list-unit-files | grep -q qnode-autoupdate.service; then 107 | if systemctl is-active --quiet qnode-autoupdate.timer; then 108 | echo "QNode auto-update service and timer are already active." 109 | echo "✅ Auto updates are ON." 110 | else 111 | echo "QNode auto-update service and timer exist but are not active. Activating..." 112 | activate_service_and_timer 113 | fi 114 | else 115 | echo "Setting up QNode auto-update service and timer..." 116 | create_service_file 117 | create_timer_file 118 | activate_service_and_timer 119 | fi 120 | } 121 | 122 | main -------------------------------------------------------------------------------- /old/qnode_balance_checker.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import subprocess 4 | import os 5 | import csv 6 | import random 7 | from datetime import datetime, timedelta 8 | 9 | # Define the node binary filename 10 | NODE_BINARY = 'node-1.4.19-linux-amd64' 11 | 12 | # Function to get the unclaimed balance 13 | def get_unclaimed_balance(): 14 | try: 15 | node_command = [os.path.join('./', NODE_BINARY), '-node-info'] 16 | node_directory = os.path.expanduser('~/ceremonyclient/node') 17 | result = subprocess.run(node_command, cwd=node_directory, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) 18 | output = result.stdout.decode('utf-8') 19 | 20 | for line in output.split('\n'): 21 | if 'Unclaimed balance' in line: 22 | balance = float(line.split()[2]) 23 | return balance 24 | except subprocess.CalledProcessError as e: 25 | print(f"Error running node command: {e}") 26 | except Exception as e: 27 | print(f"Unexpected error: {e}") 28 | return None 29 | 30 | # Function to write data to CSV file 31 | def write_to_csv(filename, data): 32 | try: 33 | # Check if file exists to determine if headers need to be written 34 | file_exists = os.path.isfile(filename) 35 | with open(filename, 'a', newline='') as file: 36 | writer = csv.writer(file) 37 | if not file_exists: 38 | writer.writerow(["time", "balance", "increase"]) # Write headers if file is empty 39 | writer.writerow(data) 40 | except Exception as e: 41 | print(f"Error writing to CSV file: {e}") 42 | 43 | # Main function to run once per execution 44 | def main(): 45 | try: 46 | current_time = datetime.now() 47 | balance = get_unclaimed_balance() 48 | if balance is not None: 49 | home_dir = os.getenv('HOME', '/root') 50 | filename = f"{home_dir}/scripts/balance_log.csv" 51 | 52 | # Calculate previous hour time range 53 | start_time = current_time - timedelta(hours=1) 54 | 55 | # For now, we're using the current balance instead of get_unclaimed_balance_at_time 56 | balance_one_hour_ago = balance 57 | 58 | # Calculate increase in balance over one hour 59 | increase = balance - balance_one_hour_ago 60 | 61 | # Format increase to 5 decimal places 62 | formatted_increase = f"{increase:.5f}" 63 | 64 | # Format balance to 2 decimal places 65 | formatted_balance = f"{balance:.2f}" 66 | 67 | # Print data 68 | data_to_write = [ 69 | current_time.strftime('%d/%m/%Y %H:%M'), 70 | formatted_balance, 71 | formatted_increase 72 | ] 73 | print(','.join(data_to_write)) 74 | 75 | # Write to CSV file 76 | write_to_csv(filename, data_to_write) 77 | 78 | except Exception as e: 79 | print(f"Error: {e}") 80 | 81 | if __name__ == "__main__": 82 | main() 83 | -------------------------------------------------------------------------------- /old/qnode_binary_rollback.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script to update Quilibrium node 4 | set -euo pipefail # Exit on error, undefined vars, and pipeline failures 5 | 6 | # Set the version number as a variable 7 | VERSION="1.4.21.1" 8 | NODE_DIR="$HOME/ceremonyclient/node" 9 | NODE_BINARY="node-$VERSION-linux-amd64" 10 | 11 | # Function to handle errors 12 | error_exit() { 13 | echo "Error: $1" >&2 14 | exit 1 15 | } 16 | 17 | # Display update plan 18 | echo "===============================================" 19 | echo "Quilibrium Node - downgrade to version $VERSION" 20 | echo "===============================================" 21 | echo 22 | echo "This script will perform the following actions:" 23 | echo "1. Create a backup of your current .config directory" 24 | echo "2. Download the new node binary and signature files" 25 | echo "3. Make the new node binary executable" 26 | echo "4. Stop the ceremonyclient service" 27 | echo "5. Update the service file to use the new binary" 28 | echo "6. Reload systemd configuration" 29 | echo "7. Start the ceremonyclient service with new version" 30 | echo 31 | echo "The update will be performed in: $NODE_DIR" 32 | echo "New binary will be: $NODE_BINARY" 33 | echo 34 | echo "===============================================" 35 | echo "Compatibility:" 36 | echo "only compatible with nodes that are running via service file" 37 | echo "only compatible with: os:linux arch:amd64 / ubuntu 22.x or 24.x" 38 | echo "not compatible with node clusters" 39 | echo 40 | echo "DO NOT RUN THIS SCRIPT IF YOU ARE ALREADY ON v2.0.1" 41 | echo 42 | sleep 1 43 | 44 | # Ask for confirmation 45 | read -p "Do you want to proceed with the update? (y/n) " -n 1 -r 46 | echo 47 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then 48 | echo "Update cancelled." 49 | exit 1 50 | fi 51 | 52 | # Verify directory exists 53 | [ -d "$NODE_DIR" ] || error_exit "Directory $NODE_DIR does not exist" 54 | 55 | # Check if service file exists 56 | if [ ! -f "/lib/systemd/system/ceremonyclient.service" ]; then 57 | echo "Error: ceremonyclient service file not found." 58 | echo "This script is only compatible with nodes running via service file." 59 | exit 1 60 | fi 61 | 62 | # Stop the ceremonyclient service 63 | echo "Stopping ceremonyclient service..." 64 | systemctl stop ceremonyclient || error_exit "Failed to stop ceremonyclient service" 65 | 66 | # Backup .config directory with progress and error checking 67 | echo "Starting backup of .config directory..." 68 | if [ -d "$NODE_DIR/.config" ]; then 69 | # Create a temporary backup first 70 | echo "Creating temporary backup..." 71 | rsync -av --progress "$NODE_DIR/.config/" "$NODE_DIR/.config.bak.tmp/" || { 72 | echo "Error: Temporary backup failed" 73 | rm -rf "$NODE_DIR/.config.bak.tmp" # Clean up failed backup 74 | exit 1 75 | } 76 | 77 | # If temporary backup succeeded, remove old backup and move new one into place 78 | echo "Finalizing backup..." 79 | if [ -d "$NODE_DIR/.config.bak" ]; then 80 | rm -rf "$NODE_DIR/.config.bak" || { 81 | echo "Error: Could not remove old backup" 82 | rm -rf "$NODE_DIR/.config.bak.tmp" 83 | exit 1 84 | } 85 | fi 86 | 87 | mv "$NODE_DIR/.config.bak.tmp" "$NODE_DIR/.config.bak" || { 88 | echo "Error: Could not finalize backup" 89 | rm -rf "$NODE_DIR/.config.bak.tmp" 90 | exit 1 91 | } 92 | 93 | echo "Backup completed successfully" 94 | else 95 | echo "Error: .config directory not found at $NODE_DIR/.config" 96 | exit 1 97 | fi 98 | 99 | # Change to the specified directory 100 | echo "Changing to the ceremonyclient/node directory..." 101 | cd "$NODE_DIR" || error_exit "Failed to change directory" 102 | 103 | # Download files 104 | echo "Downloading new node files..." 105 | 106 | # Main files to download 107 | main_files=( 108 | "$NODE_BINARY" 109 | "$NODE_BINARY.dgst" 110 | ) 111 | 112 | # Signature files to download 113 | sig_files=( 114 | "$NODE_BINARY.dgst.sig.1" 115 | "$NODE_BINARY.dgst.sig.2" 116 | "$NODE_BINARY.dgst.sig.3" 117 | "$NODE_BINARY.dgst.sig.8" 118 | "$NODE_BINARY.dgst.sig.9" 119 | "$NODE_BINARY.dgst.sig.13" 120 | "$NODE_BINARY.dgst.sig.15" 121 | "$NODE_BINARY.dgst.sig.16" 122 | "$NODE_BINARY.dgst.sig.17" 123 | ) 124 | 125 | # Download all files using curl 126 | for file in "${main_files[@]}" "${sig_files[@]}"; do 127 | echo "Downloading $file..." 128 | curl -# -L -o "$file" "https://releases.quilibrium.com/$file" || error_exit "Failed to download $file" 129 | done 130 | 131 | echo "File download process completed." 132 | 133 | # Make the new node executable 134 | echo "Making the new node executable..." 135 | chmod +x "$NODE_BINARY" || error_exit "Failed to make node executable" 136 | 137 | # Update the service file 138 | echo "Updating ceremonyclient service file..." 139 | sed -i "s|^ExecStart=.*|ExecStart=$NODE_DIR/$NODE_BINARY|" /lib/systemd/system/ceremonyclient.service || error_exit "Failed to update service file" 140 | 141 | # Reload systemd 142 | echo "Reloading systemd..." 143 | systemctl daemon-reload || error_exit "Failed to reload systemd" 144 | 145 | # Start the ceremonyclient service 146 | echo "Starting ceremonyclient service..." 147 | systemctl start ceremonyclient || error_exit "Failed to start ceremonyclient service" 148 | 149 | echo "Update to v$VERSION completed successfully!" 150 | echo "Node started automatically" 151 | echo 152 | echo "Note: If you use the Q1 'check balance' menu option, you will see 0 balance." 153 | echo "Please use this command instead:" 154 | echo "cd $NODE_DIR && ./$NODE_BINARY -balance" -------------------------------------------------------------------------------- /old/qnode_binary_rollback_cluster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script to update Quilibrium node 4 | 5 | # Set the version number as a variable 6 | VERSION="1.4.21.1" 7 | 8 | # Change to the specified directory 9 | echo "Changing to the ceremonyclient/node directory..." 10 | cd $HOME/ceremonyclient/node || { echo "Failed to change directory. Exiting."; exit 1; } 11 | 12 | # Download files 13 | echo "Downloading new node files..." 14 | 15 | # Main files to download 16 | main_files=( 17 | "node-$VERSION-linux-amd64" 18 | "node-$VERSION-linux-amd64.dgst" 19 | ) 20 | 21 | # Signature files to download 22 | sig_files=( 23 | "node-$VERSION-linux-amd64.dgst.sig.1" 24 | "node-$VERSION-linux-amd64.dgst.sig.2" 25 | "node-$VERSION-linux-amd64.dgst.sig.3" 26 | "node-$VERSION-linux-amd64.dgst.sig.8" 27 | "node-$VERSION-linux-amd64.dgst.sig.9" 28 | "node-$VERSION-linux-amd64.dgst.sig.13" 29 | "node-$VERSION-linux-amd64.dgst.sig.15" 30 | "node-$VERSION-linux-amd64.dgst.sig.16" 31 | "node-$VERSION-linux-amd64.dgst.sig.17" 32 | ) 33 | 34 | # Download main files 35 | for file in "${main_files[@]}"; do 36 | if wget "https://releases.quilibrium.com/$file" -O "$file"; then 37 | echo "Successfully downloaded $file" 38 | else 39 | echo "Failed to download $file. Exiting." 40 | exit 1 41 | fi 42 | done 43 | 44 | # Download signature files 45 | echo "Downloading signature files..." 46 | for file in "${sig_files[@]}"; do 47 | if wget "https://releases.quilibrium.com/$file" -O "$file"; then 48 | echo "Successfully downloaded $file" 49 | else 50 | echo "Failed to download $file. Skipping..." 51 | fi 52 | done 53 | 54 | echo "File download process completed." 55 | 56 | # Make the new node executable 57 | echo "Making the new node executable..." 58 | chmod +x $HOME/ceremonyclient/node/node-$VERSION-linux-amd64 || { echo "Failed to make node executable. Exiting."; exit 1; } 59 | 60 | # Update the service file 61 | #echo "Updating ceremonyclient service file..." 62 | #sudo sed -i "s|^ExecStart=.*|ExecStart=/root/ceremonyclient/node/node-$VERSION-linux-amd64|" /lib/systemd/system/ceremonyclient.service || { echo "Failed to update service file. Exiting."; exit 1; } 63 | 64 | # Reload systemd 65 | #echo "Reloading systemd..." 66 | #sudo systemctl daemon-reload || { echo "Failed to reload systemd. Exiting."; exit 1; } 67 | 68 | # Start the ceremonyclient service 69 | #echo "Starting ceremonyclient service..." 70 | #sudo service ceremonyclient start || { echo "Failed to start ceremonyclient service. Exiting."; exit 1; } 71 | 72 | echo "Update completed successfully!" 73 | echo "Start your services manually" -------------------------------------------------------------------------------- /old/qnode_proof_rate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Description: 4 | # This script analyzes proof submission rates from either the qmaster or ceremonyclient service. 5 | # It calculates submission rates, trends, and provides statistical analysis over a specified time window. 6 | # The script automatically checks for qmaster service first, falling back to ceremonyclient if not found. 7 | # 8 | # Usage: ./script.sh [minutes] 9 | # Default time window is 180 minutes (3 hours) 10 | 11 | command -v bc >/dev/null 2>&1 || { echo "Installing bc..." >&2; sudo apt install -y bc >/dev/null 2>&1; } 12 | command -v awk >/dev/null 2>&1 || { echo "Installing awk..." >&2; sudo apt install -y gawk >/dev/null 2>&1; } 13 | 14 | # Check if qmaster service exists 15 | if systemctl list-units --full -all | grep -Fq "qmaster.service"; then 16 | SERVICE_NAME=qmaster 17 | else 18 | SERVICE_NAME=ceremonyclient 19 | fi 20 | 21 | # Colors and formatting 22 | BOLD='\033[1m' 23 | BLUE='\033[34m' 24 | GREEN='\033[32m' 25 | RED='\033[31m' 26 | YELLOW='\033[33m' 27 | CYAN='\033[36m' 28 | RESET='\033[0m' 29 | SEPARATOR="━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" 30 | 31 | # Helper function for section headers 32 | print_header() { 33 | echo -e "\n${BOLD}${BLUE}$1${RESET}" 34 | echo -e "${BLUE}$SEPARATOR${RESET}" 35 | } 36 | 37 | # Helper function for values with units 38 | format_value() { 39 | local value=$1 40 | local unit=$2 41 | printf "${BOLD}%9.2f${RESET} ${CYAN}%-10s${RESET}" "$value" "$unit" 42 | } 43 | 44 | # Time window in minutes (default: 180 minutes = 3 hours) 45 | MINUTES_AGO=${1:-180} 46 | 47 | # Convert minutes to hours for journalctl 48 | HOURS_AGO=$((MINUTES_AGO / 60)) 49 | 50 | # Temporary files 51 | TEMP_FILE=$(mktemp) 52 | RATE_DATA=$(mktemp) 53 | 54 | print_header "📊 COLLECTING DATA" 55 | echo -e "Analyzing proof submissions for the last ${BOLD}$MINUTES_AGO${RESET} minutes..." 56 | 57 | # Get the last complete log entry and extract ring and workers 58 | LAST_LOG=$(journalctl -u $SERVICE_NAME.service --since "${HOURS_AGO} hours ago" | grep -F "msg\":\"submitting data proof" | tail -n 1) 59 | RING_NUMBER=$(echo "$LAST_LOG" | grep -o '"ring":[0-9]*' | cut -d':' -f2) 60 | ACTIVE_WORKERS=$(echo "$LAST_LOG" | grep -o '"active_workers":[0-9]*' | cut -d':' -f2) 61 | 62 | # Extract timestamps 63 | journalctl -u $SERVICE_NAME.service --since "${HOURS_AGO} hours ago" | \ 64 | grep -F "msg\":\"submitting data proof" | \ 65 | sed -E 's/.*"ts":([0-9]+\.[0-9]+).*/\1/' > "$TEMP_FILE" 66 | 67 | # Calculate statistics if we have data 68 | if [ -s "$TEMP_FILE" ]; then 69 | # Get first and last timestamp 70 | FIRST_TS=$(head -n 1 "$TEMP_FILE") 71 | LAST_TS=$(tail -n 1 "$TEMP_FILE") 72 | 73 | # Count total proofs 74 | TOTAL_PROOFS=$(wc -l < "$TEMP_FILE") 75 | 76 | # Calculate time difference in hours and minutes 77 | TIME_DIFF=$(echo "$LAST_TS - $FIRST_TS" | bc) 78 | HOURS=$(echo "$TIME_DIFF / 3600" | bc -l) 79 | MINUTES=$(echo "$TIME_DIFF / 60" | bc -l) 80 | 81 | # Calculate overall rates 82 | RATE_PER_HOUR=$(echo "$TOTAL_PROOFS / $HOURS" | bc -l) 83 | RATE_PER_MINUTE=$(echo "$TOTAL_PROOFS / $MINUTES" | bc -l) 84 | 85 | # Divide time window into 10-minute intervals for regression 86 | INTERVAL=600 # 10 minutes in seconds 87 | current_ts=$FIRST_TS 88 | while (( $(echo "$current_ts < $LAST_TS" | bc -l) )); do 89 | next_ts=$(echo "$current_ts + $INTERVAL" | bc -l) 90 | count=$(awk -v start="$current_ts" -v end="$next_ts" '$1 >= start && $1 < end' "$TEMP_FILE" | wc -l) 91 | time_offset=$(echo "($current_ts - $FIRST_TS) / 3600" | bc -l) 92 | rate=$(echo "$count * (3600 / $INTERVAL)" | bc -l) 93 | echo "$time_offset $rate" >> "$RATE_DATA" 94 | current_ts=$next_ts 95 | done 96 | 97 | # Calculate linear regression 98 | REGRESSION=$(awk ' 99 | BEGIN { 100 | sum_x = 0; sum_y = 0 101 | sum_xy = 0; sum_xx = 0 102 | n = 0 103 | } 104 | { 105 | x = $1; y = $2 106 | sum_x += x; sum_y += y 107 | sum_xy += x * y 108 | sum_xx += x * x 109 | n++ 110 | } 111 | END { 112 | if (n < 2) { 113 | printf "0 0 0" 114 | exit 115 | } 116 | slope = (n * sum_xy - sum_x * sum_y) / (n * sum_xx - sum_x * sum_x) 117 | r_squared = (sum_xy - sum_x * sum_y / n)^2 / \ 118 | ((sum_xx - sum_x^2/n) * (sum_yy - sum_y^2/n)) 119 | printf "%.6f %.6f", slope, r_squared 120 | }' "$RATE_DATA") 121 | 122 | SLOPE=$(echo "$REGRESSION" | cut -d' ' -f1) 123 | R_SQUARED=$(echo "$REGRESSION" | cut -d' ' -f2) 124 | 125 | # Calculate percentage change per hour 126 | PCT_CHANGE_PER_HOUR=$(echo "($SLOPE / $RATE_PER_HOUR) * 100" | bc -l) 127 | 128 | # Determine trend and confidence 129 | if (( $(echo "$SLOPE > 0" | bc -l) )); then 130 | TREND_COLOR=$GREEN 131 | TREND_ARROW="↑" 132 | TREND="Increasing" 133 | elif (( $(echo "$SLOPE < 0" | bc -l) )); then 134 | TREND_COLOR=$RED 135 | TREND_ARROW="↓" 136 | TREND="Decreasing" 137 | else 138 | TREND_COLOR=$YELLOW 139 | TREND_ARROW="→" 140 | TREND="Stable" 141 | fi 142 | 143 | if (( $(echo "$R_SQUARED > 0.7" | bc -l) )); then 144 | CONFIDENCE_COLOR=$GREEN 145 | CONFIDENCE="High" 146 | elif (( $(echo "$R_SQUARED > 0.3" | bc -l) )); then 147 | CONFIDENCE_COLOR=$YELLOW 148 | CONFIDENCE="Medium" 149 | else 150 | CONFIDENCE_COLOR=$RED 151 | CONFIDENCE="Low" 152 | fi 153 | 154 | echo 155 | echo "This script is still in BETA, feel free to post" 156 | echo "your suggestions for improvements in the Q1 Telegram channel" 157 | 158 | 159 | print_header "📈 OVERALL STATISTICS" 160 | echo -e "Time Window: ${BOLD}$(printf "%.1f" $HOURS)${RESET} hours (${BOLD}$(printf "%.1f" $MINUTES)${RESET} minutes)" 161 | echo -e "Total Proofs: ${BOLD}$TOTAL_PROOFS${RESET}" 162 | echo -e "Ring Number: ${BOLD}$RING_NUMBER${RESET}" 163 | echo -e "Active Workers: ${BOLD}$ACTIVE_WORKERS${RESET}" 164 | 165 | print_header "🚀 PROOF SUBMISSION RATES" 166 | echo -e "Hourly Rate: $(format_value $RATE_PER_HOUR "proofs/hr")" 167 | echo -e "Minute Rate: $(format_value $RATE_PER_MINUTE "proofs/min")" 168 | 169 | print_header "📉 TREND ANALYSIS" 170 | echo -e "Rate Change: $(format_value $SLOPE "proofs/hr²")" 171 | echo -e "Change Rate: ${TREND_COLOR}$(printf "%+.2f" $PCT_CHANGE_PER_HOUR)%%${RESET} per hour" 172 | echo -e "Trend: ${TREND_COLOR}$TREND_ARROW ${BOLD}$TREND${RESET}" 173 | echo -e "Confidence: ${CONFIDENCE_COLOR}$CONFIDENCE${RESET} confidence (R² = $(printf "%.4f" $R_SQUARED))" 174 | 175 | print_header "📋 SUMMARY" 176 | echo -e "${BOLD}${TREND_COLOR}$TREND_ARROW${RESET} Proof submission rate is ${TREND_COLOR}${BOLD}$TREND${RESET} at" 177 | echo -e " ${BOLD}$(printf "%+.2f" $PCT_CHANGE_PER_HOUR)%%${RESET} per hour with ${CONFIDENCE_COLOR}${BOLD}$CONFIDENCE${RESET} confidence" 178 | else 179 | echo -e "\n${RED}${BOLD}No proofs found in the last $MINUTES_AGO minutes${RESET}" 180 | fi 181 | 182 | # Cleanup 183 | rm -f "$TEMP_FILE" "$RATE_DATA" 184 | 185 | # Print footer with usage information 186 | echo -e "\n${BOLD}${BLUE}ℹ️ USAGE INFO${RESET}" 187 | echo -e "${BLUE}$SEPARATOR${RESET}" 188 | echo -e "To run for a different time window you can run:" 189 | echo -e "$HOME/scripts/qnode_proof_rate.sh x, where x is a number of minutes," 190 | echo -e "e.g. $HOME/scripts/qnode_proof_rate.sh 600" -------------------------------------------------------------------------------- /old/qnode_restart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | start_process() { 4 | GOEXPERIMENT=arenas go run ./... & 5 | main_process_id=$! 6 | local child_process_pid=$(pgrep -P $main_process_id) 7 | echo "Process started with PID $main_process_id and child PID $child_process_pid" 8 | } 9 | 10 | is_process_running() { 11 | ps -p $main_process_id > /dev/null 2>&1 12 | return $? 13 | } 14 | 15 | kill_process() { 16 | local process_count=$(pgrep -c "exe/node") 17 | local process_pids=$(pgrep "exe/node") 18 | 19 | if [ $process_count -gt 0 ]; then 20 | echo "Killing processes $process_pids" 21 | kill $process_pids 22 | else 23 | echo "No processes running" 24 | fi 25 | } 26 | 27 | # Move to the directory where the script resides 28 | cd ~/ceremonyclient/node || exit 29 | 30 | 31 | kill_process 32 | start_process 33 | 34 | while true; do 35 | if ! is_process_running; then 36 | echo "Process crashed or stopped. Restarting..." 37 | start_process 38 | fi 39 | 40 | sleep 60 41 | done 42 | -------------------------------------------------------------------------------- /old/qnode_service_installer_bin_cpuquota.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Set CPU limit percent 4 | #CPU_LIMIT_PERCENT=80 5 | 6 | cat <<- EOF 7 | 8 | ===================================================================================================== 9 | ✨ QUILIBRIUM NODE INSTALLER ✨ 10 | CPU LIMIT $CPU_LIMIT_PERCENT % 11 | ===================================================================================================== 12 | This script will install your node as a service. It will run your node form the binary file. 13 | It will also set a CPUQuota limit of $CPU_LIMIT_PERCENT % 14 | 15 | Made with 🔥 by LaMat - https://quilibrium.one 16 | ===================================================================================================== 17 | 18 | Processing... ⏳ 19 | 20 | EOF 21 | 22 | sleep 5 23 | 24 | # Exit on any error 25 | set -e 26 | 27 | # Step 1: Define a function for displaying exit messages 28 | exit_message() { 29 | echo "❌ Oops! There was an error during the script execution and the process stopped. No worries!" 30 | echo "🔄 You can try to run the script from scratch again." 31 | echo "🛠️ If you still receive an error, you may want to proceed manually, step by step instead of using the auto-installer." 32 | } 33 | trap exit_message ERR 34 | 35 | # Step 2: Backup existing configuration files if they exist 36 | if [ -d ~/ceremonyclient ]; then 37 | mkdir -p ~/backup/qnode_keys 38 | [ -f ~/ceremonyclient/node/.config/keys.yml ] && cp ~/ceremonyclient/node/.config/keys.yml ~/backup/qnode_keys/ && echo "✅ Backup of keys.yml created in ~/backup/qnode_keys folder" 39 | [ -f ~/ceremonyclient/node/.config/config.yml ] && cp ~/ceremonyclient/node/.config/config.yml ~/backup/qnode_keys/ && echo "✅ Backup of config.yml created in ~/backup/qnode_keys folder" 40 | fi 41 | 42 | # Step 3: Download Ceremonyclient 43 | echo "⏳ Downloading Ceremonyclient" 44 | sleep 1 # Add a 1-second delay 45 | cd ~ 46 | if [ -d "ceremonyclient" ]; then 47 | echo "Directory ceremonyclient already exists, skipping git clone..." 48 | else 49 | attempt=0 50 | max_attempts=3 51 | while [ $attempt -lt $max_attempts ]; do 52 | if git clone https://source.quilibrium.com/quilibrium/ceremonyclient.git; then 53 | echo "✅ Successfully cloned from https://source.quilibrium.com/quilibrium/ceremonyclient.git" 54 | break 55 | elif git clone https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git; then 56 | echo "✅ Successfully cloned from https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git" 57 | break 58 | elif git clone https://github.com/QuilibriumNetwork/ceremonyclient.git; then 59 | echo "✅ Successfully cloned from https://github.com/QuilibriumNetwork/ceremonyclient.git" 60 | break 61 | else 62 | attempt=$((attempt+1)) 63 | echo "Git clone failed (attempt $attempt of $max_attempts), retrying..." 64 | sleep 2 65 | fi 66 | done 67 | 68 | if [ $attempt -ge $max_attempts ]; then 69 | echo "❌ Error: Failed to clone the repository after $max_attempts attempts." >&2 70 | exit 1 71 | fi 72 | fi 73 | 74 | cd ~/ceremonyclient/ 75 | git checkout release 76 | 77 | # Step 4: Set up environment variables 78 | export GOROOT=/usr/local/go 79 | export GOPATH=$HOME/go 80 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 81 | 82 | # Step 5: Verify if go is correctly installed 83 | if ! command -v go &> /dev/null; then 84 | echo "❌ Go is not installed or not found in PATH" 85 | exit 1 86 | fi 87 | 88 | # Step 6: Build Ceremonyclient qClient 89 | echo "⏳ Building qClient..." 90 | sleep 1 # Add a 1-second delay 91 | cd ~/ceremonyclient/client 92 | GOEXPERIMENT=arenas go build -o qclient main.go 93 | if [ $? -ne 0 ]; then 94 | echo "❌ Build failed" 95 | exit 1 96 | fi 97 | 98 | # Step 9: Determine the ExecStart line based on the architecture 99 | HOME=$(eval echo ~$USER) 100 | NODE_PATH="$HOME/ceremonyclient/node" 101 | 102 | # Step 7: Set the version number 103 | VERSION=$(cat $NODE_PATH/config/version.go | grep -A 1 "func GetVersion() \[\]byte {" | grep -Eo '0x[0-9a-fA-F]+' | xargs printf "%d.%d.%d") 104 | 105 | # Step 8: Get the system architecture 106 | ARCH=$(uname -m) 107 | 108 | if [ "$ARCH" = "x86_64" ]; then 109 | EXEC_START="$NODE_PATH/node-$VERSION-linux-amd64" 110 | elif [ "$ARCH" = "aarch64" ]; then 111 | EXEC_START="$NODE_PATH/node-$VERSION-linux-arm64" 112 | elif [ "$ARCH" = "arm64" ]; then 113 | EXEC_START="$NODE_PATH/node-$VERSION-darwin-arm64" 114 | else 115 | echo "Unsupported architecture: $ARCH" 116 | exit 1 117 | fi 118 | 119 | # Step 10: Create Ceremonyclient Service 120 | echo "⏳ Creating Ceremonyclient Service" 121 | sleep 2 # Add a 2-second delay 122 | 123 | if [ -f "/lib/systemd/system/ceremonyclient.service" ]; then 124 | sudo rm /lib/systemd/system/ceremonyclient.service 125 | echo "ceremonyclient.service file removed." 126 | else 127 | echo "ceremonyclient.service file does not exist. No action taken." 128 | fi 129 | 130 | # Calculate the number of vCores 131 | vCORES=$(nproc) 132 | 133 | # Calculate the CPUQuota value 134 | CPU_QUOTA=$(($CPU_LIMIT_PERCENT * $vCORES)) 135 | 136 | sudo tee /lib/systemd/system/ceremonyclient.service > /dev/null <&2 103 | exit 1 104 | fi 105 | fi 106 | 107 | cd ~/ceremonyclient/ 108 | git checkout release 109 | 110 | # Set up environment variables 111 | export GOROOT=/usr/local/go 112 | export GOPATH=$HOME/go 113 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 114 | 115 | # Verify if go is correctly installed 116 | if ! command -v go &> /dev/null; then 117 | echo "❌ Go is not installed or not found in PATH" 118 | exit 1 119 | fi 120 | 121 | # Build Ceremonyclient qClient 122 | echo "⏳ Building qClient..." 123 | sleep 1 # Add a 1-second delay 124 | cd ~/ceremonyclient/client 125 | GOEXPERIMENT=arenas go build -o qclient main.go 126 | if [ $? -ne 0 ]; then 127 | echo "❌ Build failed" 128 | exit 1 129 | fi 130 | 131 | # ================== 132 | # Setup service file 133 | # ================== 134 | # Set the version number 135 | 136 | VERSION=$(cat $NODE_PATH/config/version.go | grep -A 1 "func GetVersion() \[\]byte {" | grep -Eo '0x[0-9a-fA-F]+' | xargs printf "%d.%d.%d") 137 | 138 | # Get the system architecture 139 | ARCH=$(uname -m) 140 | 141 | # Determine the ExecStart line based on the architecture 142 | HOME=$(eval echo ~$USER) 143 | NODE_PATH="$HOME/ceremonyclient/node" 144 | 145 | if [ "$ARCH" = "x86_64" ]; then 146 | EXEC_START="$NODE_PATH/node-$VERSION-linux-amd64" 147 | elif [ "$ARCH" = "aarch64" ]; then 148 | EXEC_START="$NODE_PATH/node-$VERSION-linux-arm64" 149 | elif [ "$ARCH" = "arm64" ]; then 150 | EXEC_START="$NODE_PATH/node-$VERSION-darwin-arm64" 151 | else 152 | echo "Unsupported architecture: $ARCH" 153 | exit 1 154 | fi 155 | 156 | # Step 10: Create Ceremonyclient Service 157 | echo "⏳ Creating Ceremonyclient Service" 158 | sleep 2 # Add a 2-second delay 159 | 160 | if [ -f "/lib/systemd/system/ceremonyclient.service" ]; then 161 | sudo rm /lib/systemd/system/ceremonyclient.service 162 | echo "ceremonyclient.service file removed." 163 | else 164 | echo "ceremonyclient.service file does not exist. No action taken." 165 | fi 166 | 167 | # Calculate the number of vCores 168 | vCORES=$(nproc) 169 | 170 | # Calculate the CPUQuota value 171 | CPU_QUOTA=$(($CPU_LIMIT_PERCENT * $vCORES)) 172 | 173 | sudo tee /lib/systemd/system/ceremonyclient.service > /dev/null < /dev/null; then 29 | echo "Go is not installed. Please install Go and try again." 30 | exit 1 31 | fi 32 | 33 | # Build binary file 34 | echo "Building binary file" 35 | cd ~/ceremonyclient/node 36 | GOEXPERIMENT=arenas go install ./... 37 | 38 | # Verify that the node executable exists 39 | NODE_EXECUTABLE="$GOPATH/bin/node" 40 | if [ ! -f "$NODE_EXECUTABLE" ]; then 41 | echo "Error: The node executable was not found at $NODE_EXECUTABLE" 42 | exit 1 43 | fi 44 | 45 | # Create Ceremonyclient Service 46 | echo "Creating Ceremonyclient Service" 47 | sleep 1 # Add a 1-second delay 48 | sudo tee /lib/systemd/system/ceremonyclient.service > /dev/null <&2 18 | fi 19 | sleep 1 20 | 21 | # Step 2: Move to the ceremonyclient directory 22 | echo "📂 Moving to the ceremonyclient directory..." 23 | cd ~/ceremonyclient || { echo "❌ Error: Directory ~/ceremonyclient does not exist."; exit 1; } 24 | 25 | # Function to install a package if it is not already installed 26 | install_package() { 27 | echo "⏳ Installing $1..." 28 | if apt-get install -y "$1"; then 29 | echo "✅ $1 installed successfully." 30 | else 31 | echo "❌ Failed to install $1. You will have to do this manually." >&2 32 | fi 33 | } 34 | 35 | # Install required packages 36 | install_package cpulimit 37 | install_package gawk 38 | 39 | echo "✅ cpulimit and gawk are installed and up to date." 40 | 41 | # Step 4: Download Binary 42 | echo "⏳ Downloading New Release..." 43 | 44 | # Temporarily mark the file as assume unchanged 45 | git update-index --assume-unchanged node/release_autostart.sh 46 | 47 | # Set the remote URL and verify access 48 | for url in \ 49 | "https://source.quilibrium.com/quilibrium/ceremonyclient.git" \ 50 | "https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git" \ 51 | "https://github.com/QuilibriumNetwork/ceremonyclient.git"; do 52 | if git remote set-url origin "$url" && git fetch origin; then 53 | echo "✅ Remote URL set to $url" 54 | break 55 | fi 56 | done 57 | 58 | # Check if the URL was set and accessible 59 | if ! git remote -v | grep -q origin; then 60 | echo "❌ Error: Failed to set and access remote URL." >&2 61 | exit 1 62 | fi 63 | 64 | # Check if release_autostart.sh has changed in the latest commit 65 | if git diff --name-only origin/release | grep -q "node/release_autostart.sh"; then 66 | echo "📄 release_autostart.sh has changed. Downloading the new version as release_autostart_remote.sh." 67 | git checkout origin/release -- node/release_autostart.sh 68 | cp node/release_autostart.sh node/release_autostart_remote.sh 69 | # Revert to your local version 70 | git checkout -- node/release_autostart.sh 71 | 72 | # Read both files into arrays 73 | mapfile -t local_lines < node/release_autostart.sh 74 | mapfile -t remote_lines < node/release_autostart_remote.sh 75 | 76 | # Function to extract cpulimit commands 77 | extract_cpulimit() { 78 | grep -o 'cpulimit -l [0-9]\{1,3\}' <<< "$1" 79 | } 80 | 81 | # Extract cpulimit commands 82 | local_cpulimits=() 83 | remote_cpulimits=() 84 | for line in "${local_lines[@]}"; do 85 | local_cpulimits+=( $(extract_cpulimit "$line") ) 86 | done 87 | for line in "${remote_lines[@]}"; do 88 | remote_cpulimits+=( $(extract_cpulimit "$line") ) 89 | done 90 | 91 | # Update remote cpulimit commands with local ones if they differ 92 | if [ "${#local_cpulimits[@]}" -eq "${#remote_cpulimits[@]}" ]; then 93 | for ((i = 0; i < ${#local_cpulimits[@]}; i++)); do 94 | if [ "${local_cpulimits[i]}" != "${remote_cpulimits[i]}" ]; then 95 | remote_lines=("${remote_lines[@]/${remote_cpulimits[i]}/${local_cpulimits[i]}}") 96 | fi 97 | done 98 | else 99 | echo "❌ Error: Mismatched number of cpulimit commands. Please check the files manually." >&2 100 | exit 1 101 | fi 102 | 103 | # Write the updated remote lines back to release_autostart_remote.sh 104 | printf "%s\n" "${remote_lines[@]}" > node/release_autostart_remote.sh 105 | 106 | # Rename files 107 | [ -f node/release_autostart.sh.bak ] && rm node/release_autostart.sh.bak 108 | mv node/release_autostart.sh node/release_autostart.sh.bak 109 | mv node/release_autostart_remote.sh node/release_autostart.sh 110 | 111 | else 112 | echo "✅ release_autostart.sh has not changed." 113 | fi 114 | 115 | # Pull the latest changes 116 | git pull || { echo "❌ Error: Failed to download the latest changes." >&2; exit 1; } 117 | git checkout release || { echo "❌ Error: Failed to checkout release." >&2; exit 1; } 118 | 119 | # Revert the assume unchanged mark 120 | git update-index --no-assume-unchanged node/release_autostart.sh 121 | 122 | echo "✅ Downloaded the latest changes successfully." 123 | 124 | # Get the current user's home directory 125 | HOME=$(eval echo ~$HOME_DIR) 126 | 127 | # Use the home directory in the path 128 | NODE_PATH="$HOME/ceremonyclient/node" 129 | EXEC_START="$NODE_PATH/release_autorun.sh" 130 | 131 | # Step 5: Re-Create or Update Ceremonyclient Service 132 | echo "🔧 Rebuilding Ceremonyclient Service..." 133 | sleep 2 # Add a 2-second delay 134 | SERVICE_FILE="/lib/systemd/system/ceremonyclient.service" 135 | if [ ! -f "$SERVICE_FILE" ]; then 136 | echo "📝 Creating new ceremonyclient service file..." 137 | if ! sudo tee "$SERVICE_FILE" > /dev/null <&2 153 | exit 1 154 | fi 155 | else 156 | echo "🔍 Checking existing ceremonyclient service file..." 157 | 158 | # Check if the required lines exist, if they are different, or if CPUQuota exists 159 | if ! grep -q "WorkingDirectory=$NODE_PATH" "$SERVICE_FILE" || ! grep -q "ExecStart=$EXEC_START" "$SERVICE_FILE" || grep -q '^CPUQuota=[0-9]*%' "$SERVICE_FILE"; then 160 | echo "🔄 Updating existing ceremonyclient service file..." 161 | # Replace the existing lines with new values 162 | sudo sed -i "s|WorkingDirectory=.*|WorkingDirectory=$NODE_PATH|" "$SERVICE_FILE" 163 | sudo sed -i "s|ExecStart=.*|ExecStart=$EXEC_START|" "$SERVICE_FILE" 164 | # Remove any line containing CPUQuota=x% 165 | if grep -q '^CPUQuota=[0-9]*%' "$SERVICE_FILE"; then 166 | echo "✅ CPUQuota line found. Deleting..." 167 | sudo sed -i '/^CPUQuota=[0-9]*%/d' "$SERVICE_FILE" 168 | echo "✅ CPUQuota line deleted. You don't need this anymore!" 169 | fi 170 | else 171 | echo "✅ No changes needed." 172 | fi 173 | fi 174 | 175 | # Step 6: Start the ceremonyclient service 176 | echo "✅ Starting Ceremonyclient Service" 177 | sleep 2 # Add a 2-second delay 178 | systemctl daemon-reload 179 | systemctl enable ceremonyclient 180 | service ceremonyclient start 181 | 182 | # Showing the node logs 183 | echo "🌟Your Qnode is now updated!" 184 | echo "⏳ Showing the node log... (CTRL+C to exit)" 185 | echo "" 186 | echo "" 187 | sleep 3 # Add a 3-second delay 188 | sudo journalctl -u ceremonyclient.service -f --no-hostname -o cat 189 | -------------------------------------------------------------------------------- /old/qnode_system_cleanup_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Step 0: Welcome 4 | echo "✨ Welcome! This script will clean up your system from temporary files and old log entries ✨" 5 | echo "It will stop/start the Quilibrium node service as well." 6 | echo "" 7 | echo "Made with 🔥 by LaMat - https://quilibrium.one" 8 | echo "=====================================================================================" 9 | echo "" 10 | echo "Processing... ⏳" 11 | sleep 7 # Add a 7-second delay 12 | 13 | # Function to print a separator line 14 | print_separator() { 15 | echo "======================================================================" 16 | } 17 | 18 | # Function to capture disk space 19 | capture_disk_space() { 20 | df -h / | grep '/' | awk '{print $4}' 21 | } 22 | 23 | # Function to vacuum journal logs 24 | vacuum_journal_logs() { 25 | echo "Vacuuming journalctl logs..." 26 | sudo journalctl --vacuum-size=500M 27 | print_separator 28 | } 29 | 30 | # Function to clean system caches and temporary files 31 | clean_system() { 32 | echo "Cleaning system caches and temporary files..." 33 | sudo apt-get clean 34 | sudo apt-get autoclean # Remove obsolete deb-packages 35 | sudo rm -rf /var/cache/apt/archives 36 | sudo rm -rf /tmp/* 37 | sudo rm -rf /var/tmp/* 38 | sudo rm -rf ~/.cache/* 39 | echo "System cleanup complete." 40 | print_separator 41 | } 42 | 43 | # Function to stop ceremonyclient service 44 | stop_ceremonyclient_service() { 45 | echo "Stopping ceremonyclient service..." 46 | sudo service ceremonyclient stop 47 | echo "Ceremonyclient service stopped." 48 | print_separator 49 | } 50 | 51 | # Function to start ceremonyclient service 52 | start_ceremonyclient_service() { 53 | echo "Starting ceremonyclient service..." 54 | sudo service ceremonyclient start 55 | echo "Ceremonyclient service started." 56 | print_separator 57 | } 58 | 59 | # Main function 60 | main() { 61 | echo "Starting system cleanup..." 62 | 63 | # Stop ceremonyclient service 64 | stop_ceremonyclient_service 65 | 66 | # Capture initial disk space 67 | echo "Initial free disk space: $(capture_disk_space)" 68 | 69 | # Vacuum journal logs 70 | vacuum_journal_logs 71 | 72 | # Clean system caches and temporary files 73 | clean_system 74 | 75 | # Capture final disk space 76 | echo "Final free disk space: $(capture_disk_space)" 77 | 78 | # Start ceremonyclient service 79 | start_ceremonyclient_service 80 | 81 | echo "🌟 Cleanup process completed successfully." 82 | } 83 | 84 | # Call the main function 85 | main 86 | -------------------------------------------------------------------------------- /old/qone_setup_old.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check if wget is installed, and install it if necessary 4 | if ! command -v wget &> /dev/null; then 5 | echo "⌛️ wget is not installed. Installing wget..." 6 | sleep 1 7 | sudo apt update 8 | sudo apt install wget -y 9 | if [ $? -ne 0 ]; then 10 | echo "❌ Error: Failed to install wget." 11 | exit 1 12 | fi 13 | fi 14 | 15 | # Remove existing qone.sh if it exists 16 | if [ -e ~/qone.sh ]; then 17 | rm ~/qone.sh 18 | if [ $? -ne 0 ]; then 19 | echo "❌ Error: Failed to remove qone.sh" 20 | fi 21 | fi 22 | 23 | # Download the qone.sh script 24 | wget -O ~/qone.sh https://github.com/lamat1111/QuilibriumScripts/raw/main/qone.sh 25 | if [ $? -ne 0 ]; then 26 | echo "❌ Error: Failed to download qone.sh script." 27 | exit 1 28 | fi 29 | 30 | # Make qone.sh executable 31 | chmod +x ~/qone.sh 32 | if [ $? -ne 0 ]; then 33 | echo "❌ Error: Failed to make qone.sh executable. You will have to do this manually." 34 | sleep 1 35 | # Continue execution even if chmod fails 36 | fi 37 | 38 | # Check if the qone.sh setup section is already present in .bashrc 39 | if grep -Fxq "# === qone.sh setup ===" ~/.bashrc; then 40 | echo "⚠️ The qone.sh setup section is already present in .bashrc." 41 | echo "Skipping the setup steps..." 42 | else 43 | # Check if there's already a section for another script in .bashrc 44 | if grep -q "# === [^=]*setup ===" ~/.bashrc; then 45 | echo "⚠️ Warning: Another script seems to be already set up to run on login." 46 | echo "To avoid conflicts, qone.sh will not be executed on login, but aliases will be set up." 47 | sleep 1 48 | # Define the section to add in .bashrc without the execution line 49 | bashrc_section=$(cat << 'EOF' 50 | 51 | # === qone.sh setup === 52 | # this allows you to call the qone menu with "q1" or "qone" 53 | alias q1='~/qone.sh' 54 | alias qone='~/qone.sh' 55 | # === end qone.sh setup === 56 | EOF 57 | ) 58 | else 59 | # Define the section to add in .bashrc with the execution line 60 | bashrc_section=$(cat << 'EOF' 61 | 62 | # === qone.sh setup === 63 | # this allows you to call the qone menu with "q1" or "qone" 64 | alias q1='~/qone.sh' 65 | alias qone='~/qone.sh' 66 | # === end qone.sh setup === 67 | EOF 68 | ) 69 | fi 70 | 71 | # Add the section to the end of .bashrc if not already present 72 | echo "$bashrc_section" >> ~/.bashrc 73 | if [ $? -ne 0 ]; then 74 | echo "❌ Error: Failed to add section to .bashrc. No worries, this is optional." 75 | sleep 1 76 | # Continue execution even if adding section to .bashrc fails 77 | fi 78 | fi 79 | -------------------------------------------------------------------------------- /old/release_autorun_createnew.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Stop ceremonyclient service 4 | echo "🛑 Stopping ceremonyclient service..." 5 | service ceremonyclient stop 6 | sleep 3 7 | 8 | # Remove old release_autorun.sh 9 | echo "🗑️ Removing old release_autorun.sh..." 10 | rm ~/ceremonyclient/node/release_autorun.sh 11 | sleep 1 12 | 13 | # Create new release_autorun.sh 14 | echo "📝 Creating new release_autorun.sh..." 15 | cat < ~/ceremonyclient/node/release_autorun.sh 16 | #!/bin/bash 17 | 18 | start_process() { 19 | version=\$(cat config/version.go | grep -A 1 "func GetVersion() \[\]byte {" | grep -Eo '0x[0-9a-fA-F]+' | xargs printf "%d.%d.%d") 20 | if [[ "\$OSTYPE" == "linux-gnu"* ]]; then 21 | if [[ \$(uname -m) == "aarch64"* ]]; then 22 | ./node-\$version-linux-arm64 & 23 | main_process_id=\$! 24 | else 25 | ./node-\$version-linux-amd64 & 26 | main_process_id=\$! 27 | fi 28 | elif [[ "\$OSTYPE" == "darwin"* ]]; then 29 | ./node-\$version-darwin-arm64 & 30 | main_process_id=\$! 31 | else 32 | echo "unsupported OS for releases, please build from source" 33 | exit 1 34 | fi 35 | 36 | echo "process started with PID \$main_process_id" 37 | } 38 | 39 | is_process_running() { 40 | ps -p \$main_process_id > /dev/null 2>&1 41 | return \$? 42 | } 43 | 44 | kill_process() { 45 | local process_count=\$(ps -ef | grep "node-\$version" | grep -v grep | wc -l) 46 | local process_pids=\$(ps -ef | grep "node-\$version" | grep -v grep | awk '{print \$2}' | xargs) 47 | 48 | if [ \$process_count -gt 0 ]; then 49 | echo "killing processes \$process_pids" 50 | kill \$process_pids 51 | else 52 | echo "no processes running" 53 | fi 54 | } 55 | 56 | kill_process 57 | 58 | start_process 59 | 60 | while true; do 61 | if ! is_process_running; then 62 | echo "process crashed or stopped. restarting..." 63 | start_process 64 | fi 65 | 66 | git fetch 67 | 68 | local_head=\$(git rev-parse HEAD) 69 | remote_head=\$(git rev-parse @{u}) 70 | 71 | if [ "\$local_head" != "\$remote_head" ]; then 72 | kill_process 73 | 74 | git pull 75 | 76 | start_process 77 | fi 78 | 79 | sleep 43200 80 | done 81 | EOF 82 | 83 | # Give permissions 84 | echo "🔑 Giving permissions to release_autorun.sh..." 85 | chmod +x ~/ceremonyclient/node/release_autorun.sh 86 | sleep 2 87 | 88 | # Start ceremonyclient service 89 | echo "🚀 Starting ceremonyclient service..." 90 | service ceremonyclient start 91 | sleep 2 92 | 93 | # Show node log 94 | echo "📜 Displaying node log..." 95 | sudo journalctl -u ceremonyclient.service -f --no-hostname -o cat 96 | -------------------------------------------------------------------------------- /old/server_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -i 2 | 3 | # Step 0: Welcome 4 | echo "✨ Welcome! This script will prepare your server for the Quilibrium node installation. ✨" 5 | echo "Made with 🔥 by LaMat" 6 | echo "Processing... ⏳" 7 | sleep 7 # Add a 7-second delay 8 | 9 | # Define a function for displaying exit messages 10 | exit_message() { 11 | echo "❌ Oops! There was an error during the script execution and the process stopped. No worries!" 12 | echo "🔄 You can try to run the script from scratch again." 13 | echo "🛠️ If you still receive an error, you may want to proceed manually, step by step instead of using the auto-installer." 14 | } 15 | 16 | # Step 1: Check sudo availability 17 | if ! [ -x "$(command -v sudo)" ]; then 18 | echo "⚠️ Sudo is not installed! This script requires sudo to run. Exiting..." 19 | exit_message 20 | exit 1 21 | fi 22 | 23 | # Step 2: Update and Upgrade the Machine 24 | echo "🔄 Updating the machine..." 25 | echo "Processing... ⏳" 26 | sleep 2 # Add a 2-second delay 27 | sudo apt-get update 28 | sudo apt-get upgrade -y 29 | 30 | # Step 3: Install required packages 31 | echo "🔧 Installing useful packages..." 32 | sudo apt-get install git wget tmux tar -y || { echo "❌ Failed to install useful packages! Exiting..."; exit_message; exit 1; } 33 | 34 | #!/bin/bash 35 | 36 | # Step 4: Download and extract Go based on system architecture 37 | if [[ $(go version) == *"go1.20.1"* || $(go version) == *"go1.20.2"* || $(go version) == *"go1.20.3"* || $(go version) == *"go1.20.4"* ]]; then 38 | echo "✅ Correct version of Go is already installed, moving on..." 39 | else 40 | echo "⬇️ Installing the necessary version of Go..." 41 | 42 | # Get the system architecture 43 | ARCH=$(uname -m) 44 | 45 | # Determine the correct Go version to download based on architecture 46 | if [ "$ARCH" = "x86_64" ]; then 47 | GO_URL="https://go.dev/dl/go1.20.14.linux-amd64.tar.gz" 48 | elif [ "$ARCH" = "aarch64" ]; then 49 | GO_URL="https://go.dev/dl/go1.20.14.linux-arm64.tar.gz" 50 | elif [ "$ARCH" = "arm64" ]; then 51 | GO_URL="https://go.dev/dl/go1.20.14.linux-arm64.tar.gz" 52 | else 53 | echo "Unsupported architecture: $ARCH" 54 | exit 1 55 | fi 56 | 57 | # Download the selected Go version 58 | wget -4 $GO_URL || { echo "❌ Failed to download Go! Exiting..."; exit_message; exit 1; } 59 | 60 | # Extract the downloaded archive 61 | sudo tar -C /usr/local -xzf $(basename $GO_URL) || { echo "❌ Failed to extract Go! Exiting..."; exit_message; exit 1; } 62 | 63 | # Remove the downloaded archive 64 | sudo rm $(basename $GO_URL) || { echo "❌ Failed to remove downloaded archive! Exiting..."; exit_message; exit 1; } 65 | 66 | fi 67 | 68 | 69 | # Step 5: Set Go environment variables 70 | echo "🌍 Setting Go environment variables..." 71 | 72 | # Check if GOROOT is already set 73 | if grep -q 'export GOROOT=/usr/local/go' ~/.bashrc; then 74 | echo "✅ GOROOT already set in ~/.bashrc." 75 | else 76 | echo 'export GOROOT=/usr/local/go' >> ~/.bashrc 77 | echo "✅ GOROOT set in ~/.bashrc." 78 | fi 79 | 80 | # Check if GOPATH is already set 81 | if grep -q 'export GOPATH=$HOME/go' ~/.bashrc; then 82 | echo "✅ GOPATH already set in ~/.bashrc." 83 | else 84 | echo 'export GOPATH=$HOME/go' >> ~/.bashrc 85 | echo "✅ GOPATH set in ~/.bashrc." 86 | fi 87 | 88 | # Check if PATH is already set for Go 89 | if grep -q 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' ~/.bashrc; then 90 | echo "✅ PATH already set in ~/.bashrc." 91 | else 92 | echo 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >> ~/.bashrc 93 | echo "✅ PATH set in ~/.bashrc." 94 | fi 95 | 96 | # Check if GO111MODULE is already set 97 | if grep -q 'export GO111MODULE=on' ~/.bashrc; then 98 | echo "✅ GO111MODULE already set in ~/.bashrc." 99 | else 100 | echo 'export GO111MODULE=on' >> ~/.bashrc 101 | echo "✅ GO111MODULE set in ~/.bashrc." 102 | fi 103 | 104 | # Check if GOPROXY is already set 105 | if grep -q 'export GOPROXY=https://goproxy.cn,direct' ~/.bashrc; then 106 | echo "✅ GOPROXY already set in ~/.bashrc." 107 | else 108 | echo 'export GOPROXY=https://goproxy.cn,direct' >> ~/.bashrc 109 | echo "✅ GOPROXY set in ~/.bashrc." 110 | fi 111 | 112 | # Step 5.1: Temporarily add variables - redundant but it help solving the command go not found error 113 | export GOROOT=/usr/local/go 114 | export GOPATH=$HOME/go 115 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 116 | 117 | # Source the ~/.bashrc to apply changes 118 | source ~/.bashrc 119 | sleep 2 # Add a 2-second delay 120 | 121 | # Step 6: Adjust network buffer sizes 122 | echo "🌐 Adjusting network buffer sizes..." 123 | if grep -q "^net.core.rmem_max=600000000$" /etc/sysctl.conf; then 124 | echo "✅ net.core.rmem_max=600000000 found inside /etc/sysctl.conf, skipping..." 125 | else 126 | 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 127 | fi 128 | if grep -q "^net.core.wmem_max=600000000$" /etc/sysctl.conf; then 129 | echo "✅ net.core.wmem_max=600000000 found inside /etc/sysctl.conf, skipping..." 130 | else 131 | 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 132 | fi 133 | sudo sysctl -p 134 | 135 | # Step 7: Install gRPCurl 136 | echo "📦 Installing gRPCurl..." 137 | sleep 1 # Add a 1-second delay 138 | 139 | # Try installing gRPCurl using go install 140 | if go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest; then 141 | echo "✅ gRPCurl installed successfully via go install." 142 | else 143 | echo "⚠️ Failed to install gRPCurl via go install. Trying apt-get..." 144 | # Try installing gRPCurl using apt-get 145 | if sudo apt-get install grpcurl -y; then 146 | echo "✅ gRPCurl installed successfully via apt-get." 147 | else 148 | echo "❌ Failed to install gRPCurl via apt-get! Moving on to the next step..." 149 | # Optionally, perform additional error handling here 150 | fi 151 | fi 152 | 153 | 154 | # Step 8: Install ufw and configure firewall 155 | echo "🛡️ Installing ufw (Uncomplicated Firewall)..." 156 | sudo apt-get update 157 | sudo apt-get install ufw -y || { echo "❌ Failed to install ufw! Moving on to the next step..."; } 158 | 159 | # Attempt to enable ufw 160 | echo "🛡️ Configuring firewall..." 161 | if command -v ufw >/dev/null 2>&1; then 162 | echo "y" | sudo ufw enable || { echo "❌ Failed to enable firewall! No worries, you can do it later manually."; } 163 | else 164 | echo "⚠️ ufw (Uncomplicated Firewall) is not installed. Skipping firewall configuration." 165 | fi 166 | 167 | # Check if ufw is available and configured 168 | if command -v ufw >/dev/null 2>&1 && sudo ufw status | grep -q "Status: active"; then 169 | # Allow required ports 170 | for port in 22 8336 443; do 171 | if ! ufw_rule_exists "${port}"; then 172 | sudo ufw allow "${port}" || echo "⚠️ Error: Failed to allow port ${port}! You will need to allow port 8336 manually for the node to connect." 173 | fi 174 | done 175 | 176 | # Display firewall status 177 | sudo ufw status 178 | echo "✅ Firewall setup was successful." 179 | else 180 | echo "⚠️ Failed to configure firewall or ufw is not installed. No worries, you can do it later manually. Moving on to the next step..." 181 | fi 182 | 183 | # Step 9: Creating some useful folders 184 | echo "📂 Creating /root/backup/ folder..." 185 | sudo mkdir -p /root/backup/ 186 | echo "✅ Done." 187 | 188 | echo "📂 Creating /root/scripts/ folder..." 189 | sudo mkdir -p /root/scripts/ 190 | echo "✅ Done." 191 | 192 | echo "📂 Creating /root/scripts/log/ folder..." 193 | sudo mkdir -p /root/scripts/log/ 194 | echo "✅ Done." 195 | 196 | # Step 10: Prompt for reboot 197 | echo "🎉 Server setup is finished!" 198 | echo "🔄 Type 'sudo reboot' and press ENTER to reboot your server." 199 | echo "🔗 Then follow the online guide for the next steps" 200 | echo " to install your Quilibrium node as a service: https://iri.quest/quilibrium-node-guide" 201 | -------------------------------------------------------------------------------- /old/store_kickstart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Step 0: Welcome 4 | echo "✨ Welcome! This script will change your Qnode store folder with another one for fast syncing. ✨" 5 | echo "You must be running the node as a service, otherwise the script won't work." 6 | echo "If you are not running as a service, follow the step-by-step process at https://iri.quest/qnode-store." 7 | echo "Made with 🔥 by LaMat" 8 | echo "" 9 | echo "Processing... ⏳" 10 | sleep 7 # Add a 7-second delay 11 | 12 | # Function to handle errors and exit the script 13 | handle_error() { 14 | echo "❌ Error occurred in script at line: $1" 15 | echo "ℹ️ Error message: $2" 16 | exit 1 17 | } 18 | 19 | # Trap errors and call the handle_error function 20 | trap 'handle_error $LINENO "$BASH_COMMAND"' ERR 21 | 22 | # Download store from the internet 23 | echo "🌐 Downloading store from the internet..." 24 | wget -P ~/ceremonyclient/node/.config https://snapshots.cherryservers.com/quilibrium/store.zip || { 25 | echo "❌ It was not possible to download the store.zip from the internet." 26 | echo "If you have a store.zip locally, please proceed with the step-by-step method instead and use that one." 27 | echo "More info on this page https://iri.quest/qstore-upload" 28 | exit 1 29 | } 30 | echo "✅ Download completed successfully." 31 | sleep 1 32 | 33 | # Check if ceremonyclient service exists 34 | if ! systemctl list-unit-files | grep -q 'ceremonyclient.service'; then 35 | echo "❌ The 'ceremonyclient' service does not exist." 36 | echo "Please make sure you are running the node as a service." 37 | echo "If you are not running as a service, follow the step-by-step process at https://iri.quest/qnode-store" 38 | exit 1 39 | fi 40 | 41 | # Check if zip and unzip are installed 42 | if ! command -v zip &> /dev/null; then 43 | echo "🚨 Zip utility is not installed. Installing..." 44 | sudo apt-get update && sudo apt-get install -y zip || handle_error $LINENO "Failed to install zip utility." 45 | echo "✅ Zip utility installed successfully." 46 | fi 47 | 48 | if ! command -v unzip &> /dev/null; then 49 | echo "🚨 Unzip utility is not installed. Installing..." 50 | sudo apt-get update && sudo apt-get install -y unzip || handle_error $LINENO "Failed to install unzip utility." 51 | echo "✅ Unzip utility installed successfully." 52 | fi 53 | 54 | # Stop node service if it's not already stopped 55 | if systemctl is-active --quiet ceremonyclient; then 56 | echo "🛑 Stopping node service..." 57 | sudo service ceremonyclient stop 58 | echo "✅ Node service stopped successfully." 59 | else 60 | echo "🟢 Node service is already stopped. Moving on..." 61 | fi 62 | sleep 1 63 | 64 | # Rename store to store-original if it exists 65 | echo "🔄 Renaming store to store-original if it exists..." 66 | if [ -d ~/ceremonyclient/node/.config/store ]; then 67 | mv ~/ceremonyclient/node/.config/store ~/ceremonyclient/node/.config/store-original 68 | echo "✅ Store renamed successfully." 69 | else 70 | echo "🟢 'store' folder not found. Skipping renaming." 71 | fi 72 | sleep 1 73 | 74 | # Extract archive in store folder without showing output 75 | echo "📦 Extracting archive in store folder..." 76 | cd ~/ceremonyclient/node/.config 77 | unzip store.zip -d . > /dev/null 78 | echo "✅ Archive extracted successfully." 79 | 80 | # Delete store.zip 81 | echo "🗑️ Deleting store.zip" 82 | rm ~/ceremonyclient/node/.config/store.zip 83 | echo "✅ store.zip deleted successfully." 84 | 85 | # Delete store-original if it exists 86 | echo "🗑️ Deleting store-original if it exists..." 87 | if [ -d ~/ceremonyclient/node/.config/store-original]; then 88 | rm -rf ~/ceremonyclient/node/.config/store-original 89 | echo "✅ 'store-original' folder deleted successfully." 90 | else 91 | echo "🟢 'store-original' folder not found. Skipping deletion." 92 | fi 93 | sleep 1 94 | 95 | # Restart node service 96 | echo "🔄 Restarting node service..." 97 | service ceremonyclient start 98 | echo "✅ Node service started successfully." 99 | 100 | echo -e "\n📜 I will now show the node log (CTRL+C to detach)" 101 | echo "" 102 | echo "" 103 | 104 | # Show node log 105 | sudo journalctl -u ceremonyclient.service -f --no-hostname -o cat 106 | -------------------------------------------------------------------------------- /test/qnode_autoupdate_edit_timer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check if running as root 4 | if [ "$EUID" -ne 0 ]; then 5 | echo "Please run as root" 6 | exit 1 7 | fi 8 | 9 | # Create the new timer configuration 10 | cat > /etc/systemd/system/qnode-autoupdate.timer << 'EOF' 11 | [Unit] 12 | Description=Run QNode Service Update every 5 minutes 13 | 14 | [Timer] 15 | OnBootSec=5min 16 | OnCalendar=*:0/5 17 | Persistent=true 18 | Unit=qnode-autoupdate.service 19 | 20 | [Install] 21 | WantedBy=timers.target 22 | EOF 23 | 24 | # [Unit] 25 | # Description=Run QNode Service Update every hour at a consistent random minute 26 | 27 | # [Timer] 28 | # OnBootSec=5min 29 | # OnCalendar=hourly 30 | # RandomizedDelaySec=3600 31 | # Persistent=true 32 | # Unit=qnode-autoupdate.service 33 | 34 | # [Install] 35 | # WantedBy=timers.target 36 | 37 | 38 | # Check if the file was written successfully 39 | if [ $? -ne 0 ]; then 40 | echo "Failed to write timer configuration" 41 | exit 1 42 | fi 43 | 44 | # Reload systemd daemon 45 | systemctl daemon-reload 46 | if [ $? -ne 0 ]; then 47 | echo "Failed to reload systemd daemon" 48 | exit 1 49 | fi 50 | 51 | # Restart the timer 52 | systemctl enable qnode-autoupdate.timer 53 | systemctl restart qnode-autoupdate.timer 54 | if [ $? -ne 0 ]; then 55 | echo "Failed to restart timer" 56 | exit 1 57 | fi 58 | 59 | # Verify the timer is running 60 | if systemctl is-active --quiet qnode-autoupdate.timer; then 61 | echo "Timer successfully updated and running" 62 | echo "Next trigger times:" 63 | systemctl list-timers qnode-autoupdate.timer 64 | else 65 | echo "Timer is not running. Please check the configuration" 66 | exit 1 67 | fi -------------------------------------------------------------------------------- /test/qnode_balancelog_migration.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | check_and_migrate() { 4 | echo "Migrating date and time to new format in balance log..." 5 | local flag_file="$HOME/scripts/balance_log_fix_applied" 6 | 7 | # Skip if already migrated 8 | [ -f "$flag_file" ] && { rm "$flag_file"; } 9 | 10 | local filename="$HOME/scripts/balance_log.csv" 11 | local temp_file="$filename.tmp" 12 | 13 | [ ! -f "$filename" ] && { echo "❌ Error: Migration failed"; exit 1; } 14 | [ ! -r "$filename" ] && { echo "❌ Error: Migration failed"; exit 1; } 15 | 16 | head -n 1 "$filename" > "$temp_file" 17 | 18 | tail -n +2 "$filename" | while IFS= read -r line; do 19 | local balance=$(echo "$line" | sed 's/^[^,]*,"\(.*\)"$/\1/') 20 | local time=$(echo "$line" | sed 's/^"\(.*\)",.*$/\1/') 21 | 22 | # Convert balance format (comma to dot) 23 | balance=$(echo "$balance" | sed 's/,/\./') 24 | 25 | # Only convert date if it matches DD/MM/YYYY format 26 | if echo "$time" | grep -q '^[0-9]\{1,2\}/[0-9]\{1,2\}/[0-9]\{4\}'; then 27 | time=$(echo "$time" | sed 's/\([0-9]*\)\/\([0-9]*\)\/\([0-9]*\) \(.*\)/\3-\2-\1 \4/') 28 | fi 29 | 30 | echo "\"$time\",\"$balance\"" >> "$temp_file" 31 | done 32 | 33 | if [ -s "$temp_file" ]; then 34 | cp "$filename" "$filename.backup" 35 | mv "$temp_file" "$filename" 36 | touch "$flag_file" 37 | echo "✅ Done!" 38 | else 39 | rm "$temp_file" 40 | echo "❌ Error: Migration failed." 41 | exit 1 42 | fi 43 | } 44 | 45 | check_and_migrate -------------------------------------------------------------------------------- /test/qnode_check_frames.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ##################### 4 | # Colors 5 | ##################### 6 | YELLOW='\033[1;33m' 7 | NC='\033[0m' # No Color 8 | 9 | ##################### 10 | # Logs - add 11 | ##################### 12 | 13 | # Log configuration 14 | LOG_DIR="$HOME/scripts/logs" 15 | LOG_FILE="$LOG_DIR/qnode_check_for_frames.log" 16 | LOG_ENTRIES=1000 17 | 18 | # Create log directory if needed 19 | if [ ! -d "$LOG_DIR" ]; then 20 | echo -e "${YELLOW}WARNING: Log directory does not exist. Creating $LOG_DIR...${NC}" 21 | if ! mkdir -p "$LOG_DIR" 2>/dev/null; then 22 | echo "ERROR: Failed to create log directory $LOG_DIR" 23 | exit 1 24 | fi 25 | fi 26 | 27 | # Set up logging with timestamps 28 | exec 1> >(while read line; do echo "[$(date '+%Y-%m-%d %H:%M:%S')] $line"; done | tee -a "$LOG_FILE") 2>&1 29 | 30 | ##################### 31 | # Script 32 | ##################### 33 | 34 | # Parse command line arguments 35 | DIFF=7200 # Default value for diff 36 | 37 | if [ -z "$QUIL_SERVICE_NAME" ]; then 38 | QUIL_SERVICE_NAME="ceremonyclient" 39 | fi 40 | 41 | while [[ $# -gt 0 ]]; do 42 | case $1 in 43 | --diff) 44 | DIFF="$2" 45 | shift 2 46 | ;; 47 | *) 48 | echo -e "${YELLOW}WARNING: Unknown option: $1${NC}" 49 | exit 1 50 | ;; 51 | esac 52 | done 53 | 54 | echo "Using diff: $DIFF seconds" 55 | 56 | # Function to get the latest timestamp 57 | get_latest_frame_received_timestamp() { 58 | journalctl -u $QUIL_SERVICE_NAME --no-hostname -g "received new leading frame" --output=cat -r -n 1 | jq -r '.ts' 59 | } 60 | 61 | get_latest_timestamp() { 62 | journalctl -u $QUIL_SERVICE_NAME --no-hostname --output=cat -r -n 1 | jq -r '.ts' 63 | } 64 | 65 | restart_application() { 66 | echo -e "${YELLOW}WARNING: Restarting the node...${NC}" 67 | echo "" 68 | service $QUIL_SERVICE_NAME restart 69 | } 70 | 71 | # Get the initial timestamp 72 | last_timestamp=$(get_latest_frame_received_timestamp | awk '{print int($1)}') 73 | 74 | if [ -z "$last_timestamp" ]; then 75 | echo -e "${YELLOW}WARNING: No frames received timestamp found at all in latest logs. Restarting the node...${NC}" 76 | restart_application 77 | exit 1 78 | fi 79 | 80 | # Get the current timestamp 81 | current_timestamp=$(get_latest_timestamp | awk '{print int($1)}') 82 | 83 | echo "Last timestamp: $last_timestamp" 84 | echo "Current timestamp: $current_timestamp" 85 | 86 | # Calculate the time difference 87 | time_diff=$(echo "$current_timestamp - $last_timestamp" | bc) 88 | 89 | echo "Time difference: $time_diff seconds" 90 | 91 | # If the time difference is more than $DIFF, restart the node 92 | if [ $time_diff -gt $DIFF ]; then 93 | echo -e "${YELLOW}WARNING: No new leading frame received in the last $DIFF seconds. Restarting the node...${NC}" 94 | restart_application 95 | else 96 | echo "New leading frame received within the last $DIFF seconds. No action needed." 97 | echo "" 98 | fi 99 | 100 | ##################### 101 | # Logs - clean 102 | ##################### 103 | 104 | # At the end of script, rotate logs 105 | tail -n $LOG_ENTRIES "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE" -------------------------------------------------------------------------------- /test/qnode_check_frames_installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Colors for output 4 | RED='\033[0;31m' 5 | GREEN='\033[0;32m' 6 | YELLOW='\033[1;33m' 7 | NC='\033[0m' # No Color 8 | 9 | # Check if running as root or with sudo 10 | if [ "$EUID" -ne 0 ]; then 11 | echo -e "${RED}Please run with sudo privileges to install required packages${NC}" 12 | exit 1 13 | fi 14 | 15 | echo -e "${YELLOW}Starting installation of QNode frame checker...${NC}" 16 | echo 17 | sleep 1 18 | 19 | # Function to install required packages 20 | install_dependencies() { 21 | local pkg_name 22 | echo -e "${YELLOW}Installing/checking required packages${NC}" 23 | apt update -qq 24 | 25 | for pkg_name in "jq" "bc" "cron"; do 26 | if ! apt install -y "$pkg_name"; then 27 | echo -e "${RED}Failed to install $pkg_name${NC}" 28 | return 1 29 | fi 30 | echo -e "${GREEN}$pkg_name installed/updated${NC}" 31 | done 32 | 33 | echo 34 | sleep 1 35 | return 0 36 | } 37 | 38 | # Install dependencies 39 | if ! install_dependencies; then 40 | exit 1 41 | fi 42 | 43 | # Create scripts directory 44 | if ! mkdir -p ~/scripts; then 45 | echo -e "${RED}Failed to create scripts directory${NC}" 46 | exit 1 47 | fi 48 | 49 | # Download the script 50 | echo "Downloading qnode_check_for_frames.sh..." 51 | if ! curl -sSL "https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/test/qnode_check_frames.sh" -o ~/scripts/qnode_check_frames.sh; then 52 | echo -e "${RED}Failed to download the script${NC}" 53 | exit 1 54 | fi 55 | echo -e "${GREEN}Download completed successfully${NC}" 56 | echo 57 | sleep 1 58 | 59 | # Make script executable 60 | if ! chmod +x ~/scripts/qnode_check_frames.sh; then 61 | echo -e "${RED}Failed to make script executable${NC}" 62 | exit 1 63 | fi 64 | echo -e "${GREEN}Script permissions set successfully${NC}" 65 | echo 66 | sleep 1 67 | 68 | # Set up cron job 69 | TEMP_CRON=$(mktemp) 70 | TEMP_CRON_NEW=$(mktemp) 71 | 72 | # Export current crontab 73 | crontab -l > "$TEMP_CRON" 2>/dev/null 74 | 75 | # Check for existing frame checker cron entries 76 | if grep -q "check-for-frames.sh\|qnode_check_frames.sh" "$TEMP_CRON"; then 77 | echo -e "${YELLOW}Found existing frame checker cron job(s). Removing...${NC}" 78 | grep -v "check-frames.sh\|qnode_check_frames.sh" "$TEMP_CRON" > "$TEMP_CRON_NEW" 79 | mv "$TEMP_CRON_NEW" "$TEMP_CRON" 80 | echo -e "${GREEN}Old cron jobs removed successfully${NC}" 81 | fi 82 | 83 | # Add new cron job (changed to run every hour) 84 | echo "0 */2 * * * ${HOME}/scripts/qnode_check_frames.sh" >> "$TEMP_CRON" 85 | 86 | # Install new crontab 87 | if ! crontab "$TEMP_CRON"; then 88 | echo -e "${RED}Failed to install cron job${NC}" 89 | rm "$TEMP_CRON" "$TEMP_CRON_NEW" 2>/dev/null 90 | exit 1 91 | fi 92 | echo -e "${GREEN}Cron job installed successfully${NC}" 93 | 94 | # Clean up temporary files 95 | rm "$TEMP_CRON" "$TEMP_CRON_NEW" 2>/dev/null 96 | 97 | # Check and remove old script if it exists 98 | if [ -f "$HOME/check-frames.sh" ]; then 99 | echo -e "${YELLOW}Found old script at $HOME/check-frames.sh${NC}" 100 | if rm "$HOME/check-frames.sh"; then 101 | echo -e "${GREEN}Successfully removed old script${NC}" 102 | echo 103 | sleep 1 104 | else 105 | echo -e "${RED}Failed to remove old script${NC}" 106 | echo 107 | sleep 1 108 | fi 109 | fi 110 | 111 | LOG_DIR="$HOME/scripts/logs" 112 | 113 | # Create log directory if it doesn't exist 114 | if [ ! -d "$LOG_DIR" ]; then 115 | echo "Log directory does not exist. Creating $LOG_DIR..." 116 | if ! mkdir -p "$LOG_DIR" 2>/dev/null; then 117 | echo -e "${RED}ERROR: Failed to create log directory $LOG_DIR${NC}" 118 | exit 1 119 | fi 120 | echo -e "${GREEN}Log directory created successfully${NC}" 121 | fi 122 | 123 | echo -e "${GREEN}Installation completed successfully!${NC}" 124 | echo "Script location: ~/scripts/qnode_check_frames.sh" 125 | echo "Cron job will run every hour" 126 | echo 127 | sleep 1 128 | 129 | echo -e "${YELLOW}Current crontab entries:${NC}" 130 | crontab -l 131 | echo -------------------------------------------------------------------------------- /test/qnode_check_peers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Step 5.1: Temporarily add variables - redundant but it helps solve the command go not found error 4 | export GOROOT=/usr/local/go 5 | export GOPATH=$HOME/go 6 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 7 | 8 | # Function to check if a command exists 9 | command_exists() { 10 | command -v "$1" >/dev/null 2>&1 11 | } 12 | 13 | # Install grpcurl using go install 14 | install_grpcurl() { 15 | echo "Installing grpcurl using go install..." 16 | go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest || { echo "Error: Failed to install grpcurl using go install. Please install it manually." >&2; exit 1; } 17 | } 18 | 19 | # Check if grpcurl is installed, if not, attempt to install it 20 | if ! command_exists grpcurl; then 21 | if ! install_grpcurl; then 22 | echo "Error: Failed to install grpcurl. Please install it manually." >&2 23 | exit 1 24 | fi 25 | fi 26 | 27 | # Check if jq is installed, if not, install it 28 | if ! command_exists jq; then 29 | echo "jq is not installed. Installing..." 30 | sudo apt-get update && sudo apt-get install -y jq || { echo "Error: Failed to install jq. Please install it manually." >&2; exit 1; } 31 | fi 32 | 33 | # Retrieve the network information from the node 34 | network_info=$(grpcurl -plaintext localhost:8337 quilibrium.node.node.pb.NodeService.GetNetworkInfo 2>&1) 35 | 36 | # Check if grpcurl encountered an error 37 | if [[ "$network_info" == *"command not found"* ]]; then 38 | echo "Error: grpcurl command not found. Please install grpcurl manually." >&2 39 | exit 1 40 | fi 41 | 42 | # Extract peerIds and peerScores 43 | peer_ids=$(echo "$network_info" | jq -r '.networkInfo[].peerId') 44 | peer_scores=$(echo "$network_info" | jq -r '.networkInfo[] | select(.peerScore) | .peerScore') 45 | 46 | # Count the total number of peers 47 | peer_count=$(echo "$peer_ids" | wc -l) 48 | 49 | # Initialize variable for counting peers with peerScore of -10000 50 | peer_score_count=0 51 | 52 | # Loop through each peerScore and count occurrences of -10000 53 | while IFS= read -r score; do 54 | if [ "$score" == "-10000" ]; then 55 | ((peer_score_count++)) 56 | fi 57 | done <<< "$peer_scores" 58 | 59 | # Output the results 60 | echo "" 61 | echo "You are connected to $peer_count peers on the network" 62 | if [ "$peer_score_count" -gt 0 ]; then 63 | echo "$peer_score_count peers have a peerScore of -10000" 64 | fi 65 | echo "" 66 | -------------------------------------------------------------------------------- /test/qnode_cleanup_releases_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << "EOF" 4 | 5 | Q1Q1Q1\ Q1\ 6 | Q1 __Q1\ Q1Q1 | 7 | Q1 | Q1 |\_Q1 | 8 | Q1 | Q1 | Q1 | 9 | Q1 | Q1 | Q1 | 10 | Q1 Q1Q1 | Q1 | 11 | \Q1Q1Q1 / Q1Q1Q1\ 12 | \___Q1Q\ \______| QUILIBRIUM.ONE 13 | \___| 14 | 15 | =========================================================================== 16 | ✨ CEREMONYCLIENT CLEANUP TEST SCRIPT ✨ 17 | =========================================================================== 18 | 19 | This script will test the cleanup function for your node and qclient binaries. 20 | It will show you what files would be deleted and what files would be kept. 21 | 22 | Made with 🔥 by LaMat - https://quilibrium.one 23 | =========================================================================== 24 | 25 | EOF 26 | 27 | # Set up test variables 28 | NODE_DIR="$HOME/ceremonyclient/node" 29 | CLIENT_DIR="$HOME/ceremonyclient/client" 30 | release_os="linux" 31 | [ "$(uname -m)" = "x86_64" ] && release_arch="amd64" || release_arch="arm64" 32 | 33 | # The cleanup function 34 | cleanup_old_releases() { 35 | local directory=$1 36 | local prefix=$2 37 | 38 | echo "⏳ Cleaning up old $prefix releases in $directory..." 39 | 40 | # Find the latest executable binary (will be the one we want to keep) 41 | local current_binary=$(find "$directory" -name "${prefix}-[0-9]*" ! -name "*.dgst" ! -name "*.sig*" -type f -executable 2>/dev/null | sort -V | tail -n 1) 42 | 43 | if [ -z "$current_binary" ]; then 44 | echo "❌ No current $prefix binary found" 45 | return 1 46 | fi 47 | 48 | # Get just the filename without the path 49 | current_binary=$(basename "$current_binary") 50 | echo "Current binary: $current_binary" 51 | 52 | # Find and delete old files in one go - simpler approach 53 | find "$directory" -type f -name "${prefix}-[0-9.]*-${release_os}-${release_arch}*" ! -name "${current_binary}*" -delete -print 54 | 55 | echo "✅ Cleanup completed for $prefix" 56 | } 57 | 58 | echo 59 | echo "Current architecture: $release_os-$release_arch" 60 | echo 61 | 62 | # Test node cleanup 63 | echo "Testing Node Cleanup..." 64 | echo "------------------------" 65 | echo "Current node files:" 66 | ls -la "$NODE_DIR" | grep "node-" 67 | echo "------------------------" 68 | cleanup_old_releases "$NODE_DIR" "node" 69 | echo "------------------------" 70 | echo "Remaining node files:" 71 | ls -la "$NODE_DIR" | grep "node-" 72 | echo "------------------------" 73 | 74 | # Test qclient cleanup 75 | echo "Testing Qclient Cleanup..." 76 | echo "------------------------" 77 | echo "Current qclient files:" 78 | ls -la "$CLIENT_DIR" | grep "qclient-" 79 | echo "------------------------" 80 | cleanup_old_releases "$CLIENT_DIR" "qclient" 81 | echo "------------------------" 82 | echo "Remaining qclient files:" 83 | ls -la "$CLIENT_DIR" | grep "qclient-" 84 | 85 | echo 86 | echo "Test completed! Check the results above to see what was cleaned up." 87 | echo -------------------------------------------------------------------------------- /test/qnode_cpulimit_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # CPU limit checks snippet - to be added to node update script 4 | 5 | #=========================== 6 | # Set variables 7 | #=========================== 8 | # Set service file path 9 | SERVICE_FILE="/lib/systemd/system/ceremonyclient.service" 10 | # User working folder 11 | HOME=$(eval echo ~$USER) 12 | # Node path 13 | NODE_PATH="$HOME/ceremonyclient/node" 14 | 15 | #=========================== 16 | # Check if ceremonyclient directory exists 17 | #=========================== 18 | HOME=$(eval echo ~$USER) 19 | CEREMONYCLIENT_DIR="$HOME/ceremonyclient" 20 | 21 | if [ ! -d "$CEREMONYCLIENT_DIR" ]; then 22 | echo "❌ Error: You don't have a node installed yet. Nothing to update. Exiting..." 23 | exit 1 24 | fi 25 | 26 | #=========================== 27 | # CPU limit cheks 28 | #=========================== 29 | # Calculate the number of vCores 30 | vCORES=$(nproc) 31 | 32 | # Check if CPUQuota exists 33 | if grep -q "CPUQuota=" "$SERVICE_FILE"; then 34 | # Extract the current CPU limit percentage 35 | CURRENT_CPU_LIMIT=$(grep -oP '(?<=CPUQuota=)\d+' "$SERVICE_FILE") 36 | 37 | # Calculate the current CPUQuota value 38 | CURRENT_CPU_QUOTA=$(( $CURRENT_CPU_LIMIT / $vCORES )) 39 | 40 | # Ask the user if they want to change the current CPU limit 41 | read -p "Your CPU is already limited to $CURRENT_CPU_QUOTA%. Do you want to change this? (Y/N): " CHANGE_CPU_LIMIT 42 | 43 | if [[ "$CHANGE_CPU_LIMIT" =~ ^[Yy]$ ]]; then 44 | while true; do 45 | read -p "Enter the new CPU limit percentage (0-100) - enter 0 for no limit: " CPU_LIMIT_PERCENT 46 | 47 | # Validate the input 48 | if [[ "$CPU_LIMIT_PERCENT" =~ ^[0-9]+$ ]] && [ "$CPU_LIMIT_PERCENT" -ge 0 ] && [ "$CPU_LIMIT_PERCENT" -le 100 ]; then 49 | break # Break out of the loop if the input is valid 50 | else 51 | echo "❌ Invalid input. Please enter a number between 0 and 100." 52 | fi 53 | done 54 | 55 | if [ "$CPU_LIMIT_PERCENT" -eq 0 ]; then 56 | echo "⚠️ No CPUQuota will be set." 57 | else 58 | echo "✅ CPU limit percentage set to: $CPU_LIMIT_PERCENT%" 59 | sleep 1 60 | 61 | # Calculate the new CPUQuota value 62 | CPU_QUOTA=$(( ($CPU_LIMIT_PERCENT * $vCORES) / 100 )) 63 | echo "☑️ Your CPUQuota value will be $CPU_LIMIT_PERCENT% of $vCORES vCores = $CPU_QUOTA%" 64 | sleep 1 65 | 66 | # Add CPUQuota to the service file 67 | echo "➕ Adding CPUQuota to ceremonyclient service file..." 68 | if ! sudo sed -i "/\[Service\]/a CPUQuota=${CPU_QUOTA}%" "$SERVICE_FILE"; then 69 | echo "❌ Error: Failed to add CPUQuota to ceremonyclient service file." >&2 70 | exit 1 71 | else 72 | echo "✅ A CPU limit of $CPU_LIMIT_PERCENT% has been applied" 73 | echo "You can change this manually later in your service file if you need" 74 | fi 75 | sleep 1 # Add a 1-second delay 76 | fi 77 | elif [[ "$CHANGE_CPU_LIMIT" =~ ^[Nn]$ ]]; then 78 | echo "🔄 CPUQuota will not be changed. Moving on..." 79 | else 80 | echo "❌ Invalid input. CPUQuota will not be changed. Moving on..." 81 | fi 82 | else 83 | # CPUQuota does not exist, proceed with setting a new CPU limit 84 | while true; do 85 | read -p "Enter the CPU limit percentage (0-100) - enter 0 for no limit: " CPU_LIMIT_PERCENT 86 | 87 | # Validate the input 88 | if [[ "$CPU_LIMIT_PERCENT" =~ ^[0-9]+$ ]] && [ "$CPU_LIMIT_PERCENT" -ge 0 ] && [ "$CPU_LIMIT_PERCENT" -le 100 ]; then 89 | break # Break out of the loop if the input is valid 90 | else 91 | echo "❌ Invalid input. Please enter a number between 0 and 100." 92 | fi 93 | done 94 | 95 | if [ "$CPU_LIMIT_PERCENT" -eq 0 ]; then 96 | echo "⚠️ No CPUQuota will be set." 97 | else 98 | echo "✅ CPU limit percentage set to: $CPU_LIMIT_PERCENT%" 99 | sleep 1 100 | 101 | # Calculate the CPUQuota value 102 | CPU_QUOTA=$(( $CPU_LIMIT_PERCENT * $vCORES )) 103 | echo "☑️ Your CPUQuota value will be $CPU_LIMIT_PERCENT% of $vCORES vCores = $CPU_QUOTA%" 104 | sleep 1 105 | 106 | # Add CPUQuota to the service file 107 | echo "➕ Adding CPUQuota to ceremonyclient service file..." 108 | if ! sudo sed -i "/\[Service\]/a CPUQuota=${CPU_QUOTA}%" "$SERVICE_FILE"; then 109 | echo "❌ Error: Failed to add CPUQuota to ceremonyclient service file." >&2 110 | exit 1 111 | else 112 | echo "✅ A CPU limit of $CPU_LIMIT_PERCENT% has been applied" 113 | echo "You can change this manually later in your service file if you need" 114 | fi 115 | sleep 1 # Add a 1-second delay 116 | fi 117 | fi 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /test/qnode_monitor_proofs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Quick check for required tools 4 | if ! command -v gawk >/dev/null 2>&1 || ! command -v journalctl >/dev/null 2>&1 || ! command -v grep >/dev/null 2>&1; then 5 | echo "Some required tools are missing. Please install them:" 6 | echo 7 | if command -v apt-get >/dev/null 2>&1; then 8 | echo "Run: sudo apt-get install gawk systemd grep" 9 | elif command -v yum >/dev/null 2>&1; then 10 | echo "Run: sudo yum install gawk systemd grep" 11 | elif command -v apk >/dev/null 2>&1; then 12 | echo "Run: apk add gawk systemd grep" 13 | else 14 | echo "Please install: gawk, systemd, and grep" 15 | fi 16 | exit 1 17 | fi 18 | 19 | # Check if terminal supports colors 20 | if [ -t 1 ] && command -v tput >/dev/null 2>&1 && tput colors >/dev/null 2>&1; then 21 | # Terminal supports colors 22 | YELLOW='\033[1;33m' 23 | RED='\033[0;31m' 24 | NC='\033[0m' # No Color 25 | BOLD='\033[1m' 26 | else 27 | # No color support - use empty strings 28 | YELLOW='' 29 | RED='' 30 | NC='' 31 | BOLD='' 32 | fi 33 | 34 | echo "Checking your log (this will take a minute)..." 35 | 36 | #minutes in the past to check 37 | TIME_CHECK="120" 38 | 39 | get_proof_entries() { 40 | journalctl -u ceremonyclient.service --no-hostname --since "$TIME_CHECK minutes ago" -r | \ 41 | grep "proof batch.*increment" | \ 42 | tac 43 | } 44 | 45 | # Get the proof entries 46 | log_entries=$(get_proof_entries) 47 | 48 | # Check if we have any entries 49 | count_proofs=$(echo "$log_entries" | wc -l) 50 | 51 | if [ -z "$log_entries" ]; then 52 | echo "WARNING: No proof submissions found in the last $TIME_CHECK minutes!" 53 | echo "This could also true if you have already minted all your rewards." 54 | echo "If you don't see your full balance now, you likely have more rewards to mint, and your proof submission process may be just stuck" 55 | exit 1 56 | fi 57 | 58 | # Process entries with awk 59 | echo 60 | echo "=== Proof submissions in last $TIME_CHECK minutes ===" 61 | echo "___________________________________________________________" 62 | 63 | # Modified awk command with color support check 64 | echo "$log_entries" | awk -v current_time="$(date +%s)" \ 65 | -v use_colors="$([[ -n $YELLOW ]] && echo 1 || echo 0)" \ 66 | -v time_check="$TIME_CHECK" ' 67 | BEGIN { 68 | # Set color codes based on terminal support 69 | if (use_colors) { 70 | yellow="\033[1;33m"; 71 | red="\033[0;31m"; 72 | nc="\033[0m"; 73 | bold="\033[1m"; 74 | } else { 75 | yellow=""; 76 | red=""; 77 | nc=""; 78 | bold=""; 79 | } 80 | 81 | total_time=0; 82 | total_decrement=0; 83 | gap_count=0; 84 | first_entry = 1; 85 | total_entries = 0; 86 | } 87 | { 88 | # Count each entry 89 | total_entries++; 90 | 91 | # Extract timestamp and increment from JSON format 92 | match($0, /"ts":([0-9]+\.[0-9]+)/, ts); 93 | match($0, /"increment":([0-9]+)/, inc); 94 | 95 | entry_time = ts[1]; 96 | increment = inc[1]; 97 | 98 | if (first_entry) { 99 | first_time = entry_time; 100 | first_increment = increment; 101 | first_entry = 0; 102 | } 103 | 104 | if (previous_time) { 105 | time_gap = entry_time - previous_time; 106 | decrement = previous_increment - increment; 107 | if (decrement > 0) { 108 | total_time += time_gap; 109 | total_decrement += decrement; 110 | gap_count++; 111 | } 112 | } 113 | 114 | previous_time = entry_time; 115 | previous_increment = increment; 116 | } 117 | END { 118 | if (gap_count == 0) { 119 | printf "%sNo increment changes detected%s\n", yellow, nc; 120 | exit 1; 121 | } 122 | 123 | # Check if increment has reached 0 124 | if (previous_increment == 0) { 125 | printf "\n🎉 Congratulations! 🎉\n"; 126 | printf "%sYou have already minted all your rewards!%s\n\n", bold, nc; 127 | printf "___________________________________________________________\n"; 128 | exit 0; 129 | } 130 | 131 | # Calculate time since last proof 132 | last_decrement_gap = current_time - previous_time; 133 | minutes_since_last = last_decrement_gap / 60; 134 | 135 | # Calculate time span of the proofs (only valid intervals) 136 | span_minutes = (previous_time - first_time) / 60; 137 | avg_interval = gap_count > 0 ? span_minutes / gap_count : 0; 138 | 139 | # Calculate batch statistics 140 | avg_time_per_batch = (gap_count > 0 && total_decrement > 0) ? (total_time / (total_decrement/200)) : 0; 141 | total_decrease = first_increment - previous_increment; 142 | 143 | # Increment Information 144 | printf "=== Current State ===\n"; 145 | printf "Starting increment: %d\n", first_increment; 146 | printf "Current increment: %d\n", previous_increment; 147 | printf "Total decrease: %d\n\n", total_decrease; 148 | 149 | # Time Analysis 150 | printf "=== Time Analysis ===\n"; 151 | 152 | # Time statistics with improved clarity 153 | if (minutes_since_last > 30) { 154 | printf "%sWARNING: No recent proofs!\n", yellow; 155 | printf "Last batch submitted: %.2f minutes ago%s\n\n", minutes_since_last, nc; 156 | } else { 157 | printf "Last batch submitted: %.2f minutes ago\n\n", minutes_since_last; 158 | } 159 | 160 | printf "When active, batches were submitted every %.2f minutes\n", avg_interval; 161 | printf "The analyzed %d batches were submitted within %.2f minutes\n\n", total_entries, span_minutes; 162 | 163 | # Add warning if last proof is much older than the average interval 164 | if (minutes_since_last > (avg_interval * 10)) { 165 | printf "%sNote: Proof submission delay detected%s\n", yellow, nc; 166 | printf "Last proof is older than the average interval\n"; 167 | printf "This could be normal and the node could recover on its own\n"; 168 | printf "If needed, wait at least 1 hour between restarts\n\n"; 169 | } 170 | 171 | # Processing Speed 172 | printf "=== Processing Speed ===\n"; 173 | if (avg_time_per_batch > 0) { 174 | printf "Avg Time per Batch (200 increments): %.2f Seconds\n\n", avg_time_per_batch; 175 | 176 | # Completion Estimates 177 | printf "=== Completion Estimates (don'\''t take this too seriously) ===\n"; 178 | days_to_complete = (previous_increment * (avg_time_per_batch/200)) / 86400; 179 | printf "Time to complete your %d remaining Increments: %.2f days\n\n", 180 | previous_increment, days_to_complete; 181 | } else { 182 | printf "%sWARNING: Could not calculate average batch time%s\n\n", yellow, nc; 183 | } 184 | 185 | printf "___________________________________________________________\n"; 186 | }' 187 | 188 | echo -------------------------------------------------------------------------------- /test/qnode_monitor_proofs_autorestarter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Color definitions for output 4 | RED='\033[0;31m' 5 | YELLOW='\033[1;33m' 6 | GREEN='\033[0;32m' 7 | NC='\033[0m' # No Color 8 | 9 | SCRIPT_PATH="$0" 10 | GITHUB_URL="https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/test/qnode_monitor_proofs_autorestarter.sh" 11 | 12 | # Log configuration 13 | LOG_DIR="$HOME/scripts/logs" 14 | LOG_FILE="$LOG_DIR/qnode_monitor_proofs.log" 15 | LOG_ENTRIES=1000 16 | 17 | # Function to print colored messages 18 | print_message() { 19 | local color=$1 20 | local message=$2 21 | echo -e "${color}${message}${NC}" 22 | } 23 | 24 | # Function to check for updates 25 | check_for_update() { 26 | print_message "$NC" "Checking for updates..." 27 | 28 | local temp_file="/tmp/qnode_monitor_update.sh" 29 | if ! curl -s -L "$GITHUB_URL" -o "$temp_file"; then 30 | print_message "$YELLOW" "Warning: Could not check for updates" 31 | return 1 32 | } 33 | 34 | if ! cmp -s "$SCRIPT_PATH" "$temp_file"; then 35 | print_message "$GREEN" "New version found. Updating..." 36 | if cp "$temp_file" "$SCRIPT_PATH"; then 37 | chmod +x "$SCRIPT_PATH" 38 | print_message "$GREEN" "Update successful. Restarting script..." 39 | rm "$temp_file" 40 | exec "$SCRIPT_PATH" 41 | exit 0 42 | else 43 | print_message "$RED" "Error: Update failed" 44 | fi 45 | else 46 | print_message "$NC" "No updates found." 47 | rm "$temp_file" 48 | fi 49 | } 50 | 51 | # Function to check for and remove monitoring cronjob 52 | check_and_remove_crontab() { 53 | print_message "$YELLOW" "Checking for existing monitoring cronjob..." 54 | 55 | if crontab -l 2>/dev/null | grep -q "qnode_monitor_proofs_autorestarter.sh"; then 56 | print_message "$YELLOW" "Found existing cronjob. Removing..." 57 | crontab -l 2>/dev/null | grep -v "qnode_monitor_proofs_autorestarter.sh" | crontab - 58 | print_message "$GREEN" "Successfully removed monitoring cronjob." 59 | else 60 | print_message "$GREEN" "No existing monitoring cronjob found." 61 | fi 62 | } 63 | 64 | # Function to add monitoring cronjob 65 | add_monitoring_crontab() { 66 | print_message "$NC" "Checking crontab configuration..." 67 | 68 | if crontab -l 2>/dev/null | grep -q "0 \* \* \* \* .*qnode_monitor_proofs_autorestarter.sh"; then 69 | print_message "$YELLOW" "Found hourly cron schedule. Updating to run every 30 minutes..." 70 | (crontab -l 2>/dev/null | grep -v "qnode_monitor_proofs_autorestarter.sh"; \ 71 | echo "*/30 * * * * $SCRIPT_PATH") | crontab - 72 | print_message "$GREEN" "Crontab updated successfully" 73 | else 74 | if ! crontab -l 2>/dev/null | grep -q "qnode_monitor_proofs_autorestarter.sh"; then 75 | print_message "$NC" "No monitoring cron found. Adding 30-minute schedule..." 76 | (crontab -l 2>/dev/null; echo "*/30 * * * * $SCRIPT_PATH") | crontab - 77 | print_message "$GREEN" "Crontab entry added successfully" 78 | else 79 | print_message "$NC" "Correct crontab entry already exists" 80 | fi 81 | fi 82 | } 83 | 84 | # Function to setup logging 85 | setup_logging() { 86 | if [ ! -d "$LOG_DIR" ]; then 87 | print_message "$YELLOW" "WARNING: Log directory does not exist. Creating $LOG_DIR..." | tee -a "$LOG_FILE" 88 | if ! mkdir -p "$LOG_DIR" 2>/dev/null; then 89 | print_message "$RED" "ERROR: Failed to create log directory $LOG_DIR" | tee -a "$LOG_FILE" 90 | exit 1 91 | fi 92 | fi 93 | } 94 | 95 | # Function to log with timestamp and print to console 96 | log_and_print() { 97 | echo "[$(date '+%Y-%m-%d %H:%M:%S')] $(echo "$1" | sed 's/\x1b\[[0-9;]*m//g')" >> "$LOG_FILE" 98 | echo -e "$1" 99 | } 100 | 101 | # Function to check proofs 102 | check_proofs() { 103 | log_and_print "Checking proofs from the last 30 minutes..." 104 | 105 | local log_entries=$(journalctl -u ceremonyclient.service --no-hostname --since "30 minutes ago" -r | \ 106 | grep "proof batch.*increment") 107 | 108 | if echo "$log_entries" | grep -q '"increment":0'; then 109 | log_and_print "==========================================" 110 | log_and_print "${GREEN}All proofs have been submitted!${NC}" 111 | log_and_print "==========================================" 112 | log_and_print "Removing monitoring crontab..." 113 | 114 | check_and_remove_crontab 115 | 116 | log_and_print "Monitoring script will no longer run." 117 | log_and_print "==========================================" 118 | log_and_print "" 119 | exit 0 120 | fi 121 | 122 | local entry_count=$(echo "$log_entries" | grep -c "proof batch") 123 | 124 | if [ $entry_count -eq 0 ]; then 125 | log_and_print "Error: No proofs found in the last 30 minutes" 126 | log_and_print "Restarting ceremonyclient service..." 127 | log_and_print "" 128 | systemctl restart ceremonyclient 129 | exit 1 130 | fi 131 | 132 | local first_increment=$(echo "$log_entries" | tail -n1 | grep -o '"increment":[0-9]*' | cut -d':' -f2) 133 | local last_increment=$(echo "$log_entries" | head -n1 | grep -o '"increment":[0-9]*' | cut -d':' -f2) 134 | 135 | if [ "$first_increment" -le "$last_increment" ]; then 136 | log_and_print "Error: Increments are not decreasing" 137 | log_and_print "First increment: $first_increment" 138 | log_and_print "Latest increment: $last_increment" 139 | log_and_print "Restarting ceremonyclient service..." 140 | log_and_print "" 141 | systemctl restart ceremonyclient 142 | exit 1 143 | fi 144 | 145 | log_and_print "==========================================" 146 | log_and_print "Proof check passed!" 147 | log_and_print "==========================================" 148 | log_and_print "First increment: $first_increment" 149 | log_and_print "Latest increment: $last_increment" 150 | log_and_print "------------------------------------------" 151 | log_and_print "Total increment decrease: $((first_increment - last_increment))" 152 | log_and_print "Number of batches: $(((first_increment - last_increment) / 200))" 153 | log_and_print "Avg batch time: $(echo "scale=2; (30*60)/$(((first_increment - last_increment) / 200))" | bc) seconds" 154 | log_and_print "------------------------------------------" 155 | log_and_print "Proof messages: $entry_count" 156 | log_and_print "==========================================" 157 | log_and_print "" 158 | } 159 | 160 | # Function to rotate logs 161 | rotate_logs() { 162 | tail -n $LOG_ENTRIES "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE" 163 | } 164 | 165 | # Main function 166 | main() { 167 | # Check if we just want to remove the cronjob 168 | if [ "$1" = "remove_cron" ]; then 169 | check_and_remove_crontab 170 | exit 0 171 | fi 172 | 173 | # Regular script execution 174 | check_for_update 175 | #setup_logging 176 | #check_proofs 177 | #rotate_logs 178 | } 179 | 180 | # Run the script with command line arguments 181 | main -------------------------------------------------------------------------------- /test/qnode_monitor_proofs_autorestarter_installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Color definitions 4 | GREEN='\033[0;32m' 5 | YELLOW='\033[1;33m' 6 | RED='\033[0;31m' 7 | NC='\033[0m' 8 | 9 | echo "Installing proof monitor script..." 10 | 11 | # Download and install the script 12 | if mkdir -p ~/scripts && \ 13 | curl -sSL "https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/test/qnode_monitor_proofs_autorestarter.sh" -o ~/scripts/qnode_monitor_proofs_autorestarter.sh && \ 14 | chmod +x ~/scripts/qnode_monitor_proofs_autorestarter.sh; then 15 | echo -e "${GREEN}Script downloaded and installed successfully${NC}" 16 | else 17 | echo -e "${RED}Failed to download and install the script${NC}" 18 | exit 1 19 | fi 20 | 21 | # Check if cron job already exists 22 | CRON_CMD="0 * * * * $HOME/scripts/qnode_monitor_proofs_autorestarter.sh" 23 | if crontab -l 2>/dev/null | grep -F "$HOME/scripts/qnode_monitor_proofs_autorestarter.sh" >/dev/null; then 24 | echo -e "${YELLOW}Cron job already exists, skipping...${NC}" 25 | else 26 | # Add new cron job 27 | (crontab -l 2>/dev/null; echo "$CRON_CMD") | crontab - 28 | echo -e "${GREEN}Added hourly cron job${NC}" 29 | fi 30 | 31 | echo -e "${GREEN}Installation completed:${NC}" 32 | echo "- Script installed at: ~/scripts/qnode_monitor_proofs_autorestarter.sh" 33 | echo "- Script will run every hour" 34 | echo "- Logs will be stored in: ~/scripts/logs/qnode_monitor_proofs.log" -------------------------------------------------------------------------------- /test/qnode_service_change_autorun_to_bin_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Comment out for automatic creation of the node version 4 | #NODE_VERSION=2.0 5 | 6 | #BUGS!!! 7 | # 8 | 9 | 10 | cat << "EOF" 11 | 12 | QQQQQQQQQ 1111111 13 | QQ:::::::::QQ 1::::::1 14 | QQ:::::::::::::QQ 1:::::::1 15 | Q:::::::QQQ:::::::Q111:::::1 16 | Q::::::O Q::::::Q 1::::1 17 | Q:::::O Q:::::Q 1::::1 18 | Q:::::O Q:::::Q 1::::1 19 | Q:::::O Q:::::Q 1::::l 20 | Q:::::O Q:::::Q 1::::l 21 | Q:::::O Q:::::Q 1::::l 22 | Q:::::O QQQQ:::::Q 1::::l 23 | Q::::::O Q::::::::Q 1::::l 24 | Q:::::::QQ::::::::Q111::::::111 25 | QQ::::::::::::::Q 1::::::::::1 26 | QQ:::::::::::Q 1::::::::::1 27 | QQQQQQQQ::::QQ111111111111 28 | Q:::::Q 29 | QQQQQQ QUILIBRIUM.ONE 30 | 31 | 32 | =========================================================================== 33 | ✨ QNODE SERVICE FILE UPDATER ✨ 34 | =========================================================================== 35 | This script will update your service file for running the node directly 36 | via binary and will add settings to stop the node gracefully 37 | in order to avoid penalties. 38 | 39 | Follow the guide at https://docs.quilibrium.one 40 | 41 | Made with 🔥 by LaMat - https://quilibrium.one 42 | =========================================================================== 43 | 44 | Processing... ⏳ 45 | 46 | EOF 47 | 48 | sleep 3 49 | 50 | #========================== 51 | # INSTALL APPS 52 | #========================== 53 | 54 | # Function to check and install a package 55 | check_and_install() { 56 | if ! command -v $1 &> /dev/null 57 | then 58 | echo "$1 could not be found" 59 | echo "⏳ Installing $1..." 60 | su -c "apt install $1 -y" 61 | else 62 | echo "✅ $1 is installed" 63 | fi 64 | } 65 | 66 | # For DEBIAN OS - Check if sudo, git, and curl are installed 67 | check_and_install sudo 68 | check_and_install git 69 | check_and_install curl 70 | 71 | sleep 1 72 | 73 | echo 74 | 75 | #========================== 76 | # CREATE PATH VARIABLES 77 | #========================== 78 | 79 | # Determine the ExecStart line based on the architecture 80 | ARCH=$(uname -m) 81 | OS=$(uname -s) 82 | 83 | # Determine node latest version 84 | # Check if NODE_VERSION is empty 85 | if [ -z "$NODE_VERSION" ]; then 86 | NODE_VERSION=$(curl -s https://releases.quilibrium.com/release | grep -E "^node-[0-9]+(\.[0-9]+)*" | grep -v "dgst" | sed 's/^node-//' | cut -d '-' -f 1 | head -n 1) 87 | if [ -z "$NODE_VERSION" ]; then 88 | echo "❌ Error: Unable to determine NODE_VERSION automatically." 89 | echo "The script cannot proceed without a correct node version number." 90 | echo "Please try the manual step by step installation instead:" 91 | echo "https://docs.quilibrium.one/start/tutorials/node-step-by-step-installation" 92 | echo 93 | exit 1 94 | else 95 | echo "✅ Automatically determined NODE_VERSION: $NODE_VERSION" 96 | fi 97 | else 98 | echo "✅ Using specified NODE_VERSION: $NODE_VERSION" 99 | fi 100 | 101 | 102 | # Determine the node binary name based on the architecture and OS 103 | if [ "$ARCH" = "x86_64" ]; then 104 | if [ "$OS" = "Linux" ]; then 105 | NODE_BINARY="node-$NODE_VERSION-linux-amd64" 106 | elif [ "$OS" = "Darwin" ]; then 107 | NODE_BINARY="node-$NODE_VERSION-darwin-amd64" 108 | fi 109 | elif [ "$ARCH" = "aarch64" ]; then 110 | if [ "$OS" = "Linux" ]; then 111 | NODE_BINARY="node-$NODE_VERSION-linux-arm64" 112 | elif [ "$OS" = "Darwin" ]; then 113 | NODE_BINARY="node-$NODE_VERSION-darwin-arm64" 114 | fi 115 | else 116 | echo "❌ Error: Unsupported system architecture ($ARCH) or operating system ($OS)." 117 | exit 1 118 | fi 119 | 120 | sleep 1 121 | 122 | #========================== 123 | # SERVICE UPDATE 124 | #========================== 125 | 126 | #Set variables 127 | HOME=$(eval echo ~$HOME_DIR) 128 | 129 | NODE_PATH="$HOME/ceremonyclient/node" 130 | EXEC_START="$NODE_PATH/$NODE_BINARY" 131 | 132 | SERVICE_FILE="/lib/systemd/system/ceremonyclient.service" 133 | 134 | # Check if the node is running via cluster script or para.sh and skip 135 | if [ -f "$SERVICE_FILE" ] && (grep -q "ExecStart=/root/scripts/qnode_cluster_run.sh" "$SERVICE_FILE" || grep -q "ExecStart=.*para\.sh" "$SERVICE_FILE"); then 136 | echo "⚠️ You are running a cluster or para.sh script. Skipping service file update..." 137 | echo 138 | else 139 | # Build service file 140 | echo "⏳ Rebuilding Ceremonyclient Service..." 141 | if [ ! -f "$SERVICE_FILE" ]; then 142 | echo "⏳ Creating new ceremonyclient service file..." 143 | if ! sudo tee "$SERVICE_FILE" > /dev/null <&2 164 | exit 1 165 | fi 166 | else 167 | echo "⏳ Checking existing ceremonyclient service file..." 168 | 169 | # Function to add or update a line in the [Service] section 170 | # Function to add or update a line in the [Service] section 171 | update_service_section() { 172 | local key="$1" 173 | local value="$2" 174 | if grep -q "^$key=" "$SERVICE_FILE"; then 175 | current_value=$(grep "^$key=" "$SERVICE_FILE" | cut -d'=' -f2-) 176 | if [ "$current_value" != "$value" ]; then 177 | echo "⏳ Updating $key from $current_value to $value in the service file..." 178 | sudo sed -i "s|^$key=.*|$key=$value|" "$SERVICE_FILE" 179 | else 180 | echo "✅ $key=$value already exists and is correct." 181 | fi 182 | else 183 | echo "⏳ Adding $key=$value to the service file..." 184 | sudo sed -i "/^\[Service\]/,/^\[Install\]/ { 185 | /^$/,/^\[Install\]/ { 186 | /^$/i $key=$value 187 | /^\[Install\]/i \\ 188 | 189 | } 190 | }" "$SERVICE_FILE" 191 | fi 192 | } 193 | 194 | # Function to ensure proper formatting of the service file 195 | ensure_proper_formatting() { 196 | # Remove any duplicate empty lines 197 | sudo sed -i '/^$/N;/^\n$/D' "$SERVICE_FILE" 198 | 199 | # Ensure there's exactly one empty line before [Install] 200 | sudo sed -i '/^\[Install\]/i \\' "$SERVICE_FILE" 201 | sudo sed -i '/^\[Install\]/!{/^$/N;/^\n$/D}' "$SERVICE_FILE" 202 | } 203 | 204 | # Update all required lines in the [Service] section 205 | update_service_section "WorkingDirectory" "$NODE_PATH" 206 | update_service_section "ExecStart" "$EXEC_START" 207 | update_service_section "ExecStop" "/bin/kill -s SIGINT \$MAINPID" 208 | update_service_section "KillSignal" "SIGINT" 209 | update_service_section "FinalKillSignal" "SIGINT" 210 | update_service_section "TimeoutStopSec" "30s" 211 | 212 | # Ensure proper formatting after all updates 213 | ensure_proper_formatting 214 | fi 215 | fi 216 | 217 | sleep 1 218 | 219 | # Show the current service file 220 | echo 221 | echo "Showing your updated service file:" 222 | echo "=================================" 223 | cat /lib/systemd/system/ceremonyclient.service 224 | echo "=================================" 225 | echo 226 | 227 | sleep 1 228 | # Ask for user confirmation 229 | read -p "Is everything correct in the service file? (Y/N): " confirm 230 | 231 | if [[ $confirm == [Yy]* ]]; then 232 | echo "⏳ Reloading daemon and restarting the node to apply the new settings..." 233 | sudo systemctl daemon-reload 234 | sudo systemctl restart ceremonyclient 235 | echo "✅ Service file update completed and applied." 236 | else 237 | echo "Please manually correct the service file at /lib/systemd/system/ceremonyclient.service" 238 | echo "After corrections, please run the following commands:" 239 | echo "sudo systemctl daemon-reload" 240 | echo "sudo systemctl restart ceremonyclient" 241 | fi 242 | -------------------------------------------------------------------------------- /test/test_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo="This is a test script!" 3 | sleep 3 4 | -------------------------------------------------------------------------------- /test/testnet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | SCRIPT_VERSION="1.3" 5 | 6 | # Set the version number 7 | NODE_VERSION="2.0.3-b9-testnet" 8 | QCLIENT_VERSION="2.0.3" 9 | 10 | # Get the current user's home directory 11 | HOME=$(eval echo ~$HOME_DIR) 12 | 13 | # Use the home directory in the path 14 | NODE_PATH="$HOME/testnet" 15 | EXEC_START="$NODE_PATH/node" 16 | CONFIG_FILE="$HOME/testnet/.config/config.yml" 17 | 18 | cat << EOF 19 | 20 | Q1Q1Q1\ Q1\ 21 | Q1 __Q1\ Q1Q1 | 22 | Q1 | Q1 |\_Q1 | 23 | Q1 | Q1 | Q1 | 24 | Q1 | Q1 | Q1 | 25 | Q1 Q1Q1 | Q1 | 26 | \Q1Q1Q1 / Q1Q1Q1\ 27 | \___Q1Q\ \______| QUILIBRIUM.ONE 28 | \___| 29 | 30 | =========================================================================== 31 | ✨ TESTNET NODE INSTALLER - $SCRIPT_VERSION ✨ 32 | =========================================================================== 33 | This script will install a testet Quilibrium node. 34 | If you are running this ona machine hosting a mainnet node, 35 | you have to stop that one first. 36 | 37 | The testnet node will be installed ina different folder, 38 | and won't interfere with your mainnet node files. 39 | 40 | Made with 🔥 by LaMat - https://quilibrium.one 41 | =========================================================================== 42 | 43 | Processing... ⏳ 44 | 45 | EOF 46 | 47 | sleep 3 48 | 49 | # Check and stop ceremonyclient service if it exists 50 | if systemctl list-units --full -all | grep -Fq "ceremonyclient.service"; then 51 | echo "⚠️ Detected existing ceremonyclient service" 52 | echo "⏳ Stopping ceremonyclient service..." 53 | sudo systemctl stop ceremonyclient.service 54 | sleep 2 55 | echo "✅ ceremonyclient service stopped" 56 | else 57 | echo "ℹ️ No existing ceremonyclient service detected" 58 | fi 59 | 60 | 61 | 62 | # For DEBIAN OS - Check if sudo is installed 63 | if ! command -v sudo &> /dev/null; then 64 | echo "sudo could not be found" 65 | echo "Installing sudo..." 66 | su -c "apt update && apt install sudo -y" 67 | else 68 | echo "sudo is installed" 69 | fi 70 | 71 | # Determine the ExecStart line based on the architecture 72 | ARCH=$(uname -m) 73 | OS=$(uname -s) 74 | 75 | # Determine the node binary name based on the architecture and OS 76 | if [ "$ARCH" = "x86_64" ]; then 77 | if [ "$OS" = "Linux" ]; then 78 | NODE_BINARY="node-$NODE_VERSION-linux-amd64" 79 | QCLIENT_BINARY="qclient-$QCLIENT_VERSION-linux-amd64" 80 | elif [ "$OS" = "Darwin" ]; then 81 | NODE_BINARY="node-$NODE_VERSION-darwin-amd64" 82 | QCLIENT_BINARY="qclient-$QCLIENT_VERSION-darwin-arm64" 83 | fi 84 | elif [ "$ARCH" = "aarch64" ]; then 85 | if [ "$OS" = "Linux" ]; then 86 | NODE_BINARY="node-$NODE_VERSION-linux-arm64" 87 | elif [ "$OS" = "Darwin" ]; then 88 | NODE_BINARY="node-$NODE_VERSION-darwin-arm64" 89 | QCLIENT_BINARY="qclient-$QCLIENT_VERSION-linux-arm64" 90 | fi 91 | fi 92 | 93 | echo "⏳ Creating Testnet Directories: ~/testnet/node" 94 | sleep 1 95 | mkdir -p $HOME/testnet && cd ~/testnet 96 | 97 | # Step 6: Create or Update Ceremonyclient Service 98 | echo "⏳ Stopping Qtest Service if running" 99 | sudo systemctl stop qtest.service 2>/dev/null || true 100 | sleep 2 101 | 102 | #========================== 103 | # NODE BINARY DOWNLOAD 104 | #========================== 105 | 106 | # Step 4: Download qClient 107 | echo "⏳Downloading qClient" 108 | sleep 1 109 | # Always download and overwrite 110 | wget -O $NODE_BINARY https://releases.quilibrium.com/$NODE_BINARY 111 | chmod +x $NODE_BINARY 112 | rm -f ./node 113 | echo "removed node old version" 114 | cp -p ./$NODE_BINARY ./node 115 | echo "copied $NODE_BINARY to node" 116 | echo "✅ Node binary for testnet downloaded and permissions configured completed." 117 | 118 | #========================== 119 | # qCLIENT BINARY DOWNLOAD 120 | #========================== 121 | # Always download and overwrite 122 | wget -O $QCLIENT_BINARY https://releases.quilibrium.com/$QCLIENT_BINARY 123 | chmod +x $QCLIENT_BINARY 124 | rm -f ./qclient 125 | echo "removed qclient old version" 126 | cp -p ./$QCLIENT_BINARY ./qclient 127 | echo "copied $QCLIENT_BINARY to qclient" 128 | echo "✅ qClient binary for testnet downloaded and permissions configured completed." 129 | echo 130 | 131 | # Check if this is a cluster node by examining the existing service file 132 | if [ -f "/lib/systemd/system/qtest.service" ]; then 133 | if grep -q "qnode_cluster_run_testnet.sh" "/lib/systemd/system/qtest.service"; then 134 | echo "⚠️ Detected cluster node configuration." 135 | echo "✅ Cluster nodes have different configurations. Your existing setup will be preserved." 136 | echo "⚠️ Please restart your cluster manually when ready." 137 | exit 0 138 | fi 139 | fi 140 | 141 | echo "⏳ Creating/Updating Ceremonyclient Testnet Service" 142 | sleep 2 143 | 144 | # Create a temporary service file 145 | TMP_SERVICE_FILE=$(mktemp) 146 | cat > "$TMP_SERVICE_FILE" </dev/null; then 165 | sudo mv "$TMP_SERVICE_FILE" "/lib/systemd/system/qtest.service" 166 | sudo systemctl daemon-reload 167 | echo "Service file updated" 168 | else 169 | rm "$TMP_SERVICE_FILE" 170 | echo "Service file unchanged" 171 | fi 172 | 173 | # Generate config.yml file 174 | echo "⏳ Generating .config/config.yml file" 175 | ./node --signature-check=false -peer-id 176 | sleep 5 177 | 178 | 179 | echo "⏳ Editing config.yml file" 180 | # Update bootstrap peers only if they haven't been updated 181 | if ! grep -q "91.242.214.79" "$CONFIG_FILE"; then 182 | # Comment out existing bootstrap peers 183 | sed -i '/bootstrapPeers:/,/^[^ ]/s/^ -/# -/' "$CONFIG_FILE" 184 | # Add the new bootstrap peer if it's not already there 185 | sed -i '/bootstrapPeers:/a\ - /ip4/91.242.214.79/udp/8336/quic-v1/p2p/QmNSGavG2DfJwGpHmzKjVmTD6CVSyJsUFTXsW4JXt2eySR' "$CONFIG_FILE" 186 | echo "Bootstrap peers updated in $CONFIG_FILE" 187 | else 188 | echo "Bootstrap peers already updated, skipping" 189 | fi 190 | 191 | # Update GRPC and REST multiaddr settings 192 | if grep -q '^listenGrpcMultiaddr: ""' "$CONFIG_FILE" || grep -q '^listenRESTMultiaddr: ""' "$CONFIG_FILE"; then 193 | # Update the multiaddr settings 194 | sed -i 's|^listenGrpcMultiaddr: ""|listenGrpcMultiaddr: "/ip4/127.0.0.1/tcp/8337"|' "$CONFIG_FILE" 195 | sed -i 's|^listenRESTMultiaddr: ""|listenRESTMultiaddr: "/ip4/127.0.0.1/tcp/8338"|' "$CONFIG_FILE" 196 | echo "Updated GRPC and REST multiaddr settings" 197 | else 198 | echo "GRPC and REST multiaddr settings already configured, skipping" 199 | fi 200 | 201 | # Restart service only if config was changed 202 | if [ $? -eq 0 ]; then 203 | echo "Restarting service with new configuration" 204 | sudo systemctl restart qtest.service 205 | fi 206 | 207 | echo 208 | echo "Important info:" 209 | echo "------------------------------------------------------------" 210 | echo "Installation folder: $NODE_PATH" 211 | echo "Current node version: $NODE_VERSION \\(renamed as simply 'node'\\)" 212 | echo 213 | echo "service name: qtest" 214 | echo "Start service: service qtest start" 215 | echo "Stop service: service qtest stop" 216 | echo "node log: journalctl -u qtest.service -f --no-hostname -o cat" 217 | echo "-------------------------------------------------------------" 218 | sleep 3 219 | echo 220 | echo "Showing node logs:" 221 | sudo journalctl -u qtest.service -f --no-hostname -o cat -------------------------------------------------------------------------------- /tools/CPU_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Color definitions 4 | RED='\033[0;31m' 5 | GREEN='\033[0;32m' 6 | YELLOW='\033[0;33m' 7 | BLUE='\033[0;34m' 8 | NC='\033[0m' # No Color 9 | 10 | # Function to print colored output 11 | print_color() { 12 | color=$1 13 | text=$2 14 | echo -e "${color}${text}${NC}" 15 | } 16 | 17 | # Function to check if a command exists 18 | command_exists() { 19 | command -v "$1" >/dev/null 2>&1 20 | } 21 | 22 | # Function to install a package if it doesn't exist 23 | install_package() { 24 | if ! command_exists "$1"; then 25 | echo "Installing $1..." 26 | sudo apt-get update && sudo apt-get install -y "$1" 27 | fi 28 | } 29 | 30 | # Function to get CPU information 31 | get_cpu_info() { 32 | lscpu | grep -E "Model name|CPU MHz" 33 | } 34 | 35 | # Function to get total RAM in GB 36 | get_ram_info() { 37 | free -h | awk '/^Mem:/ {print $2}' 38 | } 39 | 40 | # Function to check CPU boost status 41 | check_cpu_boost() { 42 | if [ -f "/sys/devices/system/cpu/cpufreq/boost" ]; then 43 | boost_status=$(cat /sys/devices/system/cpu/cpufreq/boost) 44 | if [ "$boost_status" -eq 1 ]; then 45 | echo "CPU Boost: Enabled" 46 | else 47 | echo "CPU Boost: Disabled" 48 | fi 49 | else 50 | echo "CPU Boost: Status not available" 51 | fi 52 | } 53 | 54 | # Function to check CPU governor (performance mode) 55 | check_cpu_governor() { 56 | if [ -f "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" ]; then 57 | governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) 58 | echo "CPU Governor: $governor" 59 | else 60 | echo "CPU Governor: Not available" 61 | fi 62 | } 63 | 64 | # Install necessary tools 65 | install_package sysbench 66 | install_package stress-ng 67 | install_package lm-sensors 68 | install_package dmidecode 69 | 70 | # Create log file 71 | LOG_FILE=~/CPU_benchmark_results.txt 72 | 73 | # Function to run tests and output results 74 | run_tests() { 75 | { 76 | print_color $BLUE "System Information:" 77 | print_color $BLUE "===================" 78 | echo "Hostname: $(hostname)" 79 | echo "IP Address: $(hostname -I | awk '{print $1}')" 80 | echo "OS: $(lsb_release -ds)" 81 | echo "Kernel: $(uname -r)" 82 | echo 83 | 84 | print_color $BLUE "CPU Information:" 85 | print_color $BLUE "=================" 86 | get_cpu_info 87 | echo "CPU Cores: $(nproc)" 88 | echo "Total RAM: $(get_ram_info)" 89 | echo 90 | 91 | print_color $BLUE "CPU Settings:" 92 | print_color $BLUE "==============" 93 | check_cpu_boost 94 | check_cpu_governor 95 | echo 96 | 97 | print_color $BLUE "CPU Frequency Information:" 98 | print_color $BLUE "===========================" 99 | cat /proc/cpuinfo | grep "MHz" 100 | echo 101 | 102 | print_color $BLUE "Memory Information:" 103 | print_color $BLUE "====================" 104 | free -h 105 | echo 106 | 107 | print_color $GREEN "CPU Benchmark Results:" 108 | print_color $GREEN "======================" 109 | 110 | print_color $YELLOW "1. Sysbench CPU Test (Multi-threaded, Prime Numbers):" 111 | sysbench cpu --cpu-max-prime=20000 --threads=$(nproc) run | grep -E "total time:|events per second:|total number of events:" 112 | echo 113 | 114 | print_color $YELLOW "2. Sysbench Single-threaded CPU Test:" 115 | sysbench cpu --cpu-max-prime=20000 --threads=1 run | grep -E "total time:|events per second:|total number of events:" 116 | echo 117 | 118 | print_color $YELLOW "3. Stress-ng CPU Test (1 minute):" 119 | stress-ng --cpu $(nproc) --timeout 1m --metrics-brief 120 | echo 121 | 122 | print_color $YELLOW "4. Sysbench Memory Test:" 123 | sysbench memory --memory-block-size=1K --memory-total-size=10G run | grep -E "Operations|Transferred|total time:" 124 | echo 125 | 126 | print_color $YELLOW "5. Processor Information:" 127 | lscpu | grep -E "Model name|Vendor ID|CPU family|CPU MHz|Cache" 128 | echo 129 | 130 | print_color $YELLOW "6. CPU Temperature (if available):" 131 | if command_exists sensors; then 132 | sensors | grep -i "core" 133 | else 134 | echo "Temperature information not available (lm-sensors not installed)" 135 | fi 136 | echo 137 | 138 | print_color $YELLOW "7. Additional CPU Details:" 139 | sudo dmidecode -t processor 140 | echo 141 | 142 | } | tee $LOG_FILE 143 | } 144 | 145 | # Run tests and display results 146 | run_tests 147 | print_color $GREEN "Comprehensive CPU benchmark completed. Results are saved in $LOG_FILE" 148 | -------------------------------------------------------------------------------- /tools/qclient_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Determine the architecture and OS 4 | ARCH=$(uname -m) 5 | OS=$(uname -s) 6 | 7 | BASE_URL="https://releases.quilibrium.com" 8 | 9 | #QCLIENT_VERSION=2.0.0 10 | 11 | # Determine qclient latest version 12 | # Check if QCLIENT_VERSION is empty 13 | if [ -z "$QCLIENT_VERSION" ]; then 14 | QCLIENT_VERSION=$(curl -s https://releases.quilibrium.com/qclient-release | grep -E "^qclient-[0-9]+(\.[0-9]+)*" | sed 's/^qclient-//' | cut -d '-' -f 1 | head -n 1) 15 | if [ -z "$QCLIENT_VERSION" ]; then 16 | echo "⚠️ Warning: Unable to determine the Qclient version automatically. Continuing without it." 17 | echo "The script cannot proceed without a correct qclientversion number." 18 | echo 19 | echo "This could be caused by your provider blocking access to quilibrium.com" 20 | echo "A solution could be to change your machine DNS and try again the update script." 21 | echo "You can change your machine DNS with the command below:" 22 | echo "sudo sh -c 'echo "nameserver 8.8.8.8" | tee /etc/systemd/resolved.conf.d/dns_servers.conf > /dev/null && systemctl restart systemd-resolved'" 23 | echo 24 | echo "Or, you can try the manual step by step installation instead:" 25 | echo "https://docs.quilibrium.one/start/tutorials/node-step-by-step-installation" 26 | echo 27 | exit 1 28 | else 29 | echo "✅ Latest Qclient release: $QCLIENT_VERSION" 30 | fi 31 | else 32 | echo "✅ Using specified Qclient version: $QCLIENT_VERSION" 33 | fi 34 | 35 | echo 36 | 37 | # Determine the node binary name based on the architecture and OS 38 | if [ "$ARCH" = "x86_64" ]; then 39 | if [ "$OS" = "Linux" ]; then 40 | [ -n "$QCLIENT_VERSION" ] && QCLIENT_BINARY="qclient-$QCLIENT_VERSION-linux-amd64" 41 | elif [ "$OS" = "Darwin" ]; then 42 | [ -n "$QCLIENT_VERSION" ] && QCLIENT_BINARY="qclient-$QCLIENT_VERSION-darwin-amd64" 43 | fi 44 | elif [ "$ARCH" = "aarch64" ]; then 45 | if [ "$OS" = "Linux" ]; then 46 | [ -n "$QCLIENT_VERSION" ] && QCLIENT_BINARY="qclient-$QCLIENT_VERSION-linux-arm64" 47 | elif [ "$OS" = "Darwin" ]; then 48 | [ -n "$QCLIENT_VERSION" ] && QCLIENT_BINARY="qclient-$QCLIENT_VERSION-darwin-arm64" 49 | fi 50 | else 51 | echo "❌ Error: Unsupported system architecture ($ARCH) or operating system ($OS)." 52 | exit 1 53 | fi 54 | 55 | 56 | echo "QCLIENT_BINARY set to: $QCLIENT_BINARY" 57 | 58 | # Create directories if they don't exist 59 | mkdir -p "$HOME/ceremonyclient/client" 60 | 61 | echo "Directories created successfully." 62 | 63 | # Change to the download directory 64 | if ! cd ~/ceremonyclient/client; then 65 | echo "❌ Error: Unable to change to the download directory" 66 | exit 1 67 | fi 68 | 69 | # Function to download file and overwrite if it exists 70 | download_and_overwrite() { 71 | local url="$1" 72 | local filename="$2" 73 | if wget -q -O "$filename" "$url"; then 74 | echo "✅ Successfully downloaded $filename" 75 | return 0 76 | else 77 | echo "❌ Error: Failed to download $filename" 78 | return 1 79 | fi 80 | } 81 | 82 | # Download the main binary 83 | echo "Downloading $QCLIENT_BINARY..." 84 | if download_and_overwrite "$BASE_URL/$QCLIENT_BINARY" "$QCLIENT_BINARY"; then 85 | chmod +x $QCLIENT_BINARY 86 | # Rename the binary to qclient, overwriting if it exists 87 | #mv -f "$QCLIENT_BINARY" qclient 88 | #chmod +x qclient 89 | #echo "✅ Renamed to qclient and made executable" 90 | else 91 | echo "❌ Error during download: manual installation may be required." 92 | exit 1 93 | fi 94 | 95 | # Download the .dgst file 96 | echo "Downloading ${QCLIENT_BINARY}.dgst..." 97 | download_and_overwrite "$BASE_URL/${QCLIENT_BINARY}.dgst" "${QCLIENT_BINARY}.dgst" 98 | 99 | # Download signature files 100 | echo "Downloading signature files..." 101 | for i in {1..20}; do 102 | sig_file="${QCLIENT_BINARY}.dgst.sig.${i}" 103 | if wget -q --spider "$BASE_URL/$sig_file" 2>/dev/null; then 104 | download_and_overwrite "$BASE_URL/$sig_file" "$sig_file" 105 | fi 106 | done 107 | 108 | echo "Download process completed." -------------------------------------------------------------------------------- /tools/qnode_balance_checker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_VERSION="1.6.3" 4 | 5 | ################### 6 | # Constants 7 | ################### 8 | 9 | readonly NODE_DIR="$HOME/ceremonyclient/node" 10 | readonly SCRIPTS_DIR="$HOME/scripts" 11 | readonly BALANCE_LOG="$SCRIPTS_DIR/balance_log.csv" 12 | readonly MIGRATION_FLAG="$SCRIPTS_DIR/balance_log_fix_applied" 13 | 14 | ################### 15 | # Utility Functions 16 | ################### 17 | 18 | check_for_updates() { 19 | LATEST_VERSION=$(curl -s "https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/tools/qnode_balance_checker.sh" | grep 'SCRIPT_VERSION="' | head -1 | cut -d'"' -f2) 20 | if [ "$SCRIPT_VERSION" != "$LATEST_VERSION" ]; then 21 | curl -s -o "$SCRIPTS_DIR/qnode_balance_checker.sh" "https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/tools/qnode_balance_checker.sh" 22 | chmod +x "$SCRIPTS_DIR/qnode_balance_checker.sh" 23 | sleep 1 24 | fi 25 | } 26 | 27 | check_and_migrate() { 28 | local temp_file="$BALANCE_LOG.tmp" 29 | 30 | # Skip if already migrated 31 | [ -f "$MIGRATION_FLAG" ] && { rm "$MIGRATION_FLAG"; return 0; } 32 | 33 | # Check file existence and readability 34 | if [ ! -f "$BALANCE_LOG" ] || [ ! -r "$BALANCE_LOG" ]; then 35 | echo 36 | echo "❌ Error: Migration failed - File not found or not readable" 37 | echo "This is ok if you are installing the script for the first time" 38 | echo 39 | return 1 40 | fi 41 | 42 | head -n 1 "$BALANCE_LOG" > "$temp_file" 43 | 44 | tail -n +2 "$BALANCE_LOG" | while IFS= read -r line; do 45 | local balance=$(echo "$line" | sed 's/^[^,]*,"\(.*\)"$/\1/') 46 | local time=$(echo "$line" | sed 's/^"\(.*\)",.*$/\1/') 47 | 48 | # Convert balance format (comma to dot) 49 | balance=$(echo "$balance" | sed 's/,/\./') 50 | 51 | # Only convert date if it matches DD/MM/YYYY format 52 | if echo "$time" | grep -q '^[0-9]\{1,2\}/[0-9]\{1,2\}/[0-9]\{4\}'; then 53 | time=$(echo "$time" | sed 's/\([0-9]*\)\/\([0-9]*\)\/\([0-9]*\) \(.*\)/\3-\2-\1 \4/') 54 | fi 55 | 56 | echo "\"$time\",\"$balance\"" >> "$temp_file" 57 | done 58 | 59 | if [ -s "$temp_file" ]; then 60 | cp "$BALANCE_LOG" "$BALANCE_LOG.backup" 61 | mv "$temp_file" "$BALANCE_LOG" 62 | touch "$MIGRATION_FLAG" 63 | echo "✅ Done" 64 | else 65 | rm "$temp_file" 66 | echo "❌ Error: Migration failed - Processing error" 67 | return 1 68 | fi 69 | } 70 | 71 | ################### 72 | # Core Functions 73 | ################### 74 | 75 | get_node_binary() { 76 | local binary_name 77 | binary_name=$(find "$NODE_DIR" -name "node-[0-9]*" ! -name "*.dgst*" ! -name "*.sig*" -type f -executable 2>/dev/null | sort -V | tail -n 1 | xargs basename) 78 | 79 | if [ -z "$binary_name" ]; then 80 | echo "ERROR: No executable node binary found in $NODE_DIR" 81 | return 1 82 | fi 83 | 84 | echo "$binary_name" 85 | } 86 | 87 | get_unclaimed_balance() { 88 | local NODE_BINARY 89 | NODE_BINARY=$(get_node_binary) 90 | 91 | if [ "$NODE_BINARY" == "ERROR:"* ]; then 92 | echo "ERROR" 93 | return 1 94 | fi 95 | 96 | local node_command="./$NODE_BINARY -balance" 97 | local output 98 | output=$(cd "$NODE_DIR" && $node_command 2>&1) 99 | 100 | local balance 101 | balance=$(echo "$output" | grep "Owned balance" | awk '{print $3}' | sed 's/QUIL//g' | tr -d ' ') 102 | 103 | if [[ "$balance" =~ ^[0-9.]+$ ]]; then 104 | echo "$balance" 105 | else 106 | echo "ERROR" 107 | fi 108 | } 109 | 110 | write_to_csv() { 111 | local data="$1" 112 | 113 | if [ ! -f "$BALANCE_LOG" ] || [ ! -s "$BALANCE_LOG" ]; then 114 | echo "time,balance" > "$BALANCE_LOG" 115 | fi 116 | 117 | local time=$(echo "$data" | cut -d',' -f1) 118 | local balance=$(echo "$data" | cut -d',' -f2) 119 | 120 | if [ "$balance" != "ERROR" ]; then 121 | balance=$(echo "$balance" | tr ',' '.' | sed 's/[[:space:]]//g') 122 | 123 | if ! echo "$balance" | grep -E '^[0-9]+\.?[0-9]*$' > /dev/null; then 124 | echo "❌ Error: Invalid number format: $balance" 125 | return 1 126 | fi 127 | 128 | local formatted_data="\"$time\",\"$balance\"" 129 | echo "$formatted_data" >> "$BALANCE_LOG" 130 | return 0 131 | else 132 | echo "❌ Error: Failed to retrieve balance." 133 | return 1 134 | fi 135 | } 136 | 137 | ################### 138 | # Main Function 139 | ################### 140 | 141 | main() { 142 | # Initialize 143 | check_and_migrate 144 | check_for_updates 145 | 146 | # Get current balance 147 | local current_time 148 | current_time=$(date +'%Y-%m-%d %H:%M') 149 | 150 | local balance 151 | balance=$(get_unclaimed_balance) 152 | 153 | # Write balance to log 154 | if [ "$balance" != "ERROR" ]; then 155 | local data_to_write="$current_time,$balance" 156 | if ! write_to_csv "$data_to_write"; then 157 | exit 1 158 | fi 159 | else 160 | echo "❌ Error: Failed to retrieve balance." 161 | exit 1 162 | fi 163 | } 164 | 165 | main -------------------------------------------------------------------------------- /tools/qnode_balance_checker_installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | cat << "EOF" 6 | 7 | Q1Q1Q1\ Q1\ 8 | Q1 __Q1\ Q1Q1 | 9 | Q1 | Q1 |\_Q1 | 10 | Q1 | Q1 | Q1 | 11 | Q1 | Q1 | Q1 | 12 | Q1 Q1Q1 | Q1 | 13 | \Q1Q1Q1 / Q1Q1Q1\ 14 | \___Q1Q\ \______| QUILIBRIUM.ONE 15 | \___| 16 | 17 | =============================================================== 18 | ✨ NODE BALANCE CHECKER - INSTALLER ✨ 19 | =============================================================== 20 | This installer sets up a script to check your node balance 21 | and then sets up a cronjob to log your balance every hour. 22 | 23 | Made with 🔥 by LaMat - https://quilibrium.one 24 | =============================================================== 25 | 26 | Processing... ⏳ 27 | 28 | EOF 29 | 30 | sleep 7 31 | 32 | # If your node version is not 1.4.19 and your system architecture is not 'amd64', 33 | # you will need to manually change this variable at the beginning of the script: 34 | # '~/scripts/qnode_balance_checker.sh' 35 | 36 | #echo "Installing Python 3 and pip3..." 37 | #sudo apt install -y python3 python3-pip > /dev/null || { echo "❌ Failed to install Python 3 and pip3."; exit 1; } 38 | #sleep 1 39 | 40 | echo "Removing existing script if it exists..." 41 | echo 42 | rm -f $HOME/scripts/qnode_balance_checker.sh 43 | sleep 1 44 | 45 | echo "Creating directory for scripts..." 46 | mkdir -p $HOME/scripts 47 | sleep 1 48 | 49 | echo "Downloading new script..." 50 | curl -s -o "$HOME/scripts/qnode_balance_checker.sh" https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/tools/qnode_balance_checker.sh 51 | sleep 1 52 | 53 | echo "Setting executable permissions for the script..." 54 | chmod +x $HOME/scripts/qnode_balance_checker.sh 55 | sleep 1 56 | 57 | echo "Checking if a cronjob exists for qnode_balance_checker.py and deleting it if found..." 58 | crontab -l | grep -v "qnode_balance_checker.sh" | crontab - 59 | sleep 1 60 | 61 | echo "Setting up cronjob to run the script once every hour..." 62 | (crontab -l ; echo "0 * * * * $HOME/scripts/qnode_balance_checker.sh") | crontab - 63 | sleep 1 64 | 65 | echo "Installing the balance log downloader script..." 66 | curl -s -o "$HOME/scripts/qnode_balance_log_download.sh" https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/tools/qnode_balance_log_download.sh 67 | chmod +x ~/scripts/qnode_balance_log_download.sh 68 | 69 | echo 70 | echo "✅ The script will now log your node balance every hour in $HOME/scripts/balance_log.csv" 71 | echo 72 | echo "Testing..." 73 | $HOME/scripts/qnode_balance_checker.sh 74 | echo 75 | echo "ℹ️ To see the log just run 'cat $HOME/scripts/balance_log.csv'" 76 | echo 77 | echo "ℹ️ To download your balance CSV file you can run '$HOME/scripts/qnode_balance_log_download.sh'" 78 | echo 79 | 80 | exit 0 -------------------------------------------------------------------------------- /tools/qnode_balance_log_download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script version 4 | SCRIPT_VERSION="1.2.1" 5 | 6 | # Function to check for newer script version 7 | check_for_updates() { 8 | #echo "⚙️ Checking for script updates..." 9 | LATEST_VERSION=$(wget -qO- "https://github.com/lamat1111/QuilibriumScripts/raw/main/tools/qnode_balance_log_download.sh" | grep 'SCRIPT_VERSION="' | head -1 | cut -d'"' -f2) 10 | if [ "$SCRIPT_VERSION" != "$LATEST_VERSION" ]; then 11 | wget -O ~/scripts/qnode_balance_log_download.sh "https://github.com/lamat1111/QuilibriumScripts/raw/main/tools/qnode_balance_log_download.sh" 12 | chmod +x ~/scripts/qnode_balance_log_download.sh 13 | echo "✅ New version downloaded: V $SCRIPT_VERSION." 14 | echo 15 | sleep 1 16 | fi 17 | } 18 | 19 | # Check for updates and update if available 20 | check_for_updates 21 | 22 | # Function to check and install Python 3 if not already installed 23 | check_python3() { 24 | if ! command -v python3 &> /dev/null; then 25 | echo "⌛️ Python 3 is not installed. Installing it now..." 26 | sudo apt update 27 | sudo apt install -y python3 28 | echo "Python 3 installed successfully." 29 | echo 30 | fi 31 | } 32 | 33 | # Install lsof if it's not present 34 | if ! command -v lsof >/dev/null 2>&1; then 35 | echo "⌛️ Installing lsof..." 36 | if [ "$(id -u)" -eq 0 ]; then 37 | apt-get update >/dev/null 2>&1 38 | apt-get install -y lsof >/dev/null 2>&1 39 | else 40 | sudo apt-get update >/dev/null 2>&1 41 | sudo apt-get install -y lsof >/dev/null 2>&1 42 | fi 43 | fi 44 | 45 | # Check if the script is run as root 46 | if [ "$(id -u)" -eq 0 ]; then 47 | SUDO="" 48 | else 49 | SUDO="sudo" 50 | fi 51 | 52 | # Get the external IP address 53 | IP_ADDRESS=$(curl -s -4 icanhazip.com) 54 | 55 | # Function to find an available port 56 | find_available_port() { 57 | while true; do 58 | PORT=$(shuf -i 1025-65535 -n 1) 59 | if ! lsof -i:$PORT > /dev/null 2>&1; then 60 | echo $PORT 61 | return 62 | fi 63 | done 64 | } 65 | 66 | # Find a random available port above 1024 67 | PORT=$(find_available_port) 68 | 69 | # Variables to track if we opened the port 70 | UFW_OPENED=false 71 | FIREWALL_CMD_OPENED=false 72 | 73 | # Check if the firewall is blocking the port and open it if necessary 74 | if command -v ufw > /dev/null 2>&1; then 75 | if $SUDO ufw status | grep -q "Status: active"; then 76 | if ! $SUDO ufw status | grep -q "$PORT/tcp"; then 77 | $SUDO ufw allow $PORT/tcp > /dev/null 2>&1 78 | UFW_OPENED=true 79 | fi 80 | fi 81 | elif command -v firewall-cmd > /dev/null 2>&1; then 82 | if $SUDO firewall-cmd --state | grep -q "running"; then 83 | if ! $SUDO firewall-cmd --list-ports | grep -q "$PORT/tcp"; then 84 | $SUDO firewall-cmd --add-port=$PORT/tcp --permanent > /dev/null 2>&1 85 | $SUDO firewall-cmd --reload > /dev/null 2>&1 86 | FIREWALL_CMD_OPENED=true 87 | fi 88 | fi 89 | else 90 | echo "No recognized firewall management tool found." 91 | fi 92 | 93 | # Function to clean up and exit 94 | cleanup() { 95 | echo "Stopping the web server and cleaning up..." 96 | kill $SERVER_PID 97 | 98 | # Close the port if it was opened by this script 99 | if $UFW_OPENED; then 100 | echo "Closing port $PORT in the firewall..." 101 | $SUDO ufw delete allow $PORT/tcp > /dev/null 2>&1 102 | fi 103 | 104 | if $FIREWALL_CMD_OPENED; then 105 | echo "Closing port $PORT in the firewall..." 106 | $SUDO firewall-cmd --remove-port=$PORT/tcp --permanent > /dev/null 2>&1 107 | $SUDO firewall-cmd --reload > /dev/null 2>&1 108 | fi 109 | } 110 | 111 | # Trap SIGINT (Ctrl+C) and call cleanup function 112 | trap "echo 'Then press ENTER to stop the web server.'; trap - SIGINT" SIGINT 113 | 114 | # Start a temporary web server 115 | cd $HOME/scripts 116 | python3 -m http.server $PORT > /dev/null 2>&1 & 117 | SERVER_PID=$! 118 | 119 | # Open port in UFW 120 | sudo ufw allow $PORT/tcp 121 | 122 | # Give URL for downloading 123 | echo 124 | DOWNLOAD_URL="http://$IP_ADDRESS:$PORT/balance_log.csv" 125 | echo "✅ Copy or click the below URL to download your balance log" 126 | echo "$DOWNLOAD_URL" 127 | 128 | # Provide instructions for copying the URL 129 | echo 130 | echo "Then press ENTER to stop the web server." 131 | 132 | # Wait for the user to press Enter 133 | read -p "" 134 | 135 | # Call cleanup function 136 | cleanup -------------------------------------------------------------------------------- /tools/qnode_cpuquota_remover.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << "EOF" 4 | 5 | Q1Q1Q1\ Q1\ 6 | Q1 __Q1\ Q1Q1 | 7 | Q1 | Q1 |\_Q1 | 8 | Q1 | Q1 | Q1 | 9 | Q1 | Q1 | Q1 | 10 | Q1 Q1Q1 | Q1 | 11 | \Q1Q1Q1 / Q1Q1Q1\ 12 | \___Q1Q\ \______| QUILIBRIUM.ONE 13 | \___| 14 | 15 | =================================================================== 16 | ✨ QNODE CPUQUOTA REMOVER ✨ 17 | =================================================================== 18 | This script will remove the CPUQuota limit from your 19 | node service file. 20 | 21 | Made with 🔥 by LaMat - https://quilibrium.one 22 | ==================================================================== 23 | 24 | Processing... ⏳ 25 | 26 | EOF 27 | 28 | sleep 7 # Add a 7-second delay 29 | 30 | #variables 31 | HOME=$(eval echo ~$USER) 32 | NODE_PATH="$HOME/ceremonyclient/node" 33 | SERVICE_FILE="/lib/systemd/system/ceremonyclient.service" 34 | 35 | # Stop the ceremonyclient service 36 | echo "🛑 Stopping Ceremonyclient Service" 37 | service ceremonyclient stop 38 | sleep 5 39 | 40 | # Find and comment out the CPUQuota line in the service file 41 | if grep -q "^CPUQuota=" "$SERVICE_FILE"; then 42 | sed -i 's/^CPUQuota=.*$/# &/' "$SERVICE_FILE" 43 | echo "✅ CPUQuota line commented out in $SERVICE_FILE" 44 | else 45 | echo "ℹ️ No CPUQuota line found in $SERVICE_FILE" 46 | fi 47 | 48 | 49 | # Remove the SELF_TEST file 50 | if [ -f "$NODE_PATH/.config/SELF_TEST" ]; then 51 | echo "🗑️ Removing SELF_TEST file..." 52 | if rm "$NODE_PATH/.config/SELF_TEST"; then 53 | echo "✅ SELF_TEST file removed successfully." 54 | else 55 | echo "❌ Error: Failed to remove SELF_TEST file." >&2 56 | exit 1 57 | fi 58 | else 59 | echo "ℹ️ No SELF_TEST file found at $NODE_PATH/.config/SELF_TEST." 60 | fi 61 | sleep 1 # Add a 1-second delay 62 | 63 | 64 | # Start the ceremonyclient service 65 | echo "✅ Starting Ceremonyclient Service" 66 | sleep 2 # Add a 2-second delay 67 | systemctl daemon-reload 68 | systemctl enable ceremonyclient 69 | service ceremonyclient start 70 | echo "✅ All done!" 71 | echo "Here is your service file" 72 | echo ="" 73 | # Display the service file 74 | cat "$SERVICE_FILE" 75 | -------------------------------------------------------------------------------- /tools/qnode_cron_manager.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Function to display usage 4 | show_usage() { 5 | echo "Usage: $0 [MODE]" 6 | echo "Available modes:" 7 | echo " 0 - Run normally with interactive prompts" 8 | echo " 1 - Deactivate all monitoring cronjobs" 9 | echo " 2 - Activate all monitoring cronjobs" 10 | echo " 3 - Deactivate qnode_rewards_to_gsheet_2.py only" 11 | echo " 4 - Deactivate qnode_rewards_to_gsheet.py only" 12 | echo " 5 - Activate qnode_rewards_to_gsheet_2.py only" 13 | echo " 6 - Activate qnode_rewards_to_gsheet.py only" 14 | echo "Example: $0 1" 15 | } 16 | 17 | # Set execution mode from command line argument or default to 0 18 | EXECUTION_MODE=${1:-0} 19 | 20 | # Function to display current crontab 21 | show_crontab() { 22 | echo "Current crontab:" 23 | echo "================================" 24 | crontab -l 25 | echo "================================" 26 | } 27 | 28 | # Function to modify specific crontab entry 29 | modify_specific_crontab() { 30 | local script_name=$1 31 | local action=$2 32 | local temp_file=$(mktemp) 33 | 34 | crontab -l > "$temp_file" 35 | 36 | if [ "$action" = "deactivate" ]; then 37 | # Use word boundaries to ensure exact match 38 | sed -i "\|\b${script_name}\b|{/^#/!s/^/#/}" "$temp_file" 39 | echo "Deactivated cronjob for ${script_name}" 40 | elif [ "$action" = "activate" ]; then 41 | # Use word boundaries to ensure exact match 42 | sed -i "\|\b${script_name}\b|s/^#*//" "$temp_file" 43 | echo "Activated cronjob for ${script_name}" 44 | fi 45 | 46 | crontab "$temp_file" 47 | rm "$temp_file" 48 | } 49 | 50 | # Function to modify all monitoring crontabs 51 | modify_all_crontabs() { 52 | local action=$1 53 | local temp_file=$(mktemp) 54 | 55 | crontab -l > "$temp_file" 56 | 57 | if [ "$action" = "deactivate" ]; then 58 | # More precise matching for each script 59 | sed -i '\|\bqnode_rewards_to_gsheet_2\.py\b|{/^#/!s/^/#/}' "$temp_file" 60 | sed -i '\|\bqnode_rewards_to_gsheet\.py\b|{/^#/!s/^/#/}' "$temp_file" 61 | sed -i '\|\bqnode_balance_checker\.sh\b|{/^#/!s/^/#/}' "$temp_file" 62 | echo "Deactivated all node balance monitoring cronjobs." 63 | elif [ "$action" = "activate" ]; then 64 | sed -i '\|\bqnode_rewards_to_gsheet_2\.py\b|s/^#*//' "$temp_file" 65 | sed -i '\|\bqnode_rewards_to_gsheet\.py\b|s/^#*//' "$temp_file" 66 | sed -i '\|\bqnode_balance_checker\.sh\b|s/^#*//' "$temp_file" 67 | echo "Activated all node balance monitoring cronjobs." 68 | fi 69 | 70 | crontab "$temp_file" 71 | rm "$temp_file" 72 | } 73 | 74 | # Validate execution mode 75 | if ! [[ "$EXECUTION_MODE" =~ ^[0-6]$ ]]; then 76 | echo "Error: Invalid execution mode '$EXECUTION_MODE'" 77 | show_usage 78 | exit 1 79 | fi 80 | 81 | # Main execution logic 82 | case $EXECUTION_MODE in 83 | 0) 84 | # Run single command with prompts 85 | echo "Choose an option:" 86 | echo "1) Deactivate all cronjobs that query the node balance" 87 | echo "2) Activate all cronjobs that query the node balance" 88 | echo "3) Deactivate qnode_rewards_to_gsheet_2.py only" 89 | echo "4) Deactivate qnode_rewards_to_gsheet.py only" 90 | echo "5) Activate qnode_rewards_to_gsheet_2.py only" 91 | echo "6) Activate qnode_rewards_to_gsheet.py only" 92 | echo "7) Exit" 93 | read -p "Enter your choice (1-7): " choice 94 | 95 | case $choice in 96 | 1) 97 | modify_all_crontabs "deactivate" 98 | ;; 99 | 2) 100 | modify_all_crontabs "activate" 101 | ;; 102 | 3) 103 | modify_specific_crontab "qnode_rewards_to_gsheet_2.py" "deactivate" 104 | ;; 105 | 4) 106 | modify_specific_crontab "qnode_rewards_to_gsheet.py" "deactivate" 107 | ;; 108 | 5) 109 | modify_specific_crontab "qnode_rewards_to_gsheet_2.py" "activate" 110 | ;; 111 | 6) 112 | modify_specific_crontab "qnode_rewards_to_gsheet.py" "activate" 113 | ;; 114 | 7) 115 | echo "Exiting..." 116 | exit 0 117 | ;; 118 | *) 119 | echo "Invalid option. Please try again." 120 | exit 1 121 | ;; 122 | esac 123 | 124 | show_crontab 125 | ;; 126 | 1) 127 | modify_all_crontabs "deactivate" 128 | show_crontab 129 | ;; 130 | 2) 131 | modify_all_crontabs "activate" 132 | show_crontab 133 | ;; 134 | 3) 135 | modify_specific_crontab "qnode_rewards_to_gsheet_2.py" "deactivate" 136 | show_crontab 137 | ;; 138 | 4) 139 | modify_specific_crontab "qnode_rewards_to_gsheet.py" "deactivate" 140 | show_crontab 141 | ;; 142 | 5) 143 | modify_specific_crontab "qnode_rewards_to_gsheet_2.py" "activate" 144 | show_crontab 145 | ;; 146 | 6) 147 | modify_specific_crontab "qnode_rewards_to_gsheet.py" "activate" 148 | show_crontab 149 | ;; 150 | esac -------------------------------------------------------------------------------- /tools/qnode_download_node_binary.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #========================== 4 | # NODE BINARY DOWNLOAD 5 | #========================== 6 | 7 | get_os_arch() { 8 | local os=$(uname -s | tr '[:upper:]' '[:lower:]') 9 | local arch=$(uname -m) 10 | 11 | case "$os" in 12 | linux|darwin) ;; 13 | *) echo "Unsupported operating system: $os" >&2; return 1 ;; 14 | esac 15 | 16 | case "$arch" in 17 | x86_64|amd64) arch="amd64" ;; 18 | arm64|aarch64) arch="arm64" ;; 19 | *) echo "Unsupported architecture: $arch" >&2; return 1 ;; 20 | esac 21 | 22 | echo "${os}-${arch}" 23 | } 24 | 25 | # Base URL for the Quilibrium releases 26 | RELEASE_FILES_URL="https://releases.quilibrium.com/release" 27 | 28 | # Get the current OS and architecture 29 | OS_ARCH=$(get_os_arch) 30 | 31 | # Fetch the list of files from the release page 32 | # Updated regex to allow for an optional fourth version number 33 | RELEASE_FILES=$(curl -s $RELEASE_FILES_URL | grep -oE "node-[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-${OS_ARCH}(\.dgst)?(\.sig\.[0-9]+)?") 34 | 35 | # Change to the download directory 36 | mkdir -p ~/ceremonyclient/node 37 | cd ~/ceremonyclient/node 38 | 39 | # Download each file 40 | for file in $RELEASE_FILES; do 41 | echo "Downloading $file..." 42 | curl -L -o "$file" "https://releases.quilibrium.com/$file" 43 | 44 | # Check if the download was successful 45 | if [ $? -eq 0 ]; then 46 | echo "Successfully downloaded $file" 47 | # Check if the file is the base binary (without .dgst or .sig suffix) 48 | if [[ $file =~ ^node-[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-${OS_ARCH}$ ]]; then 49 | echo "Making $file executable..." 50 | chmod +x "$file" 51 | if [ $? -eq 0 ]; then 52 | echo "Successfully made $file executable" 53 | else 54 | echo "Failed to make $file executable" 55 | fi 56 | fi 57 | else 58 | echo "Failed to download $file" 59 | fi 60 | 61 | echo "------------------------" 62 | done 63 | 64 | echo "✅ Node binary download completed." -------------------------------------------------------------------------------- /tools/qnode_firewall_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Function to check if a UFW rule exists 4 | ufw_rule_exists() { 5 | sudo ufw status numbered | grep -qF "$1" 6 | } 7 | 8 | # Step 3: Configure Firewall 9 | echo "Configuring firewall..." 10 | echo "y" | sudo ufw enable || { echo "Failed to enable firewall! Exiting..."; exit 1; } 11 | 12 | for port in 22 8336 443; do 13 | if ! ufw_rule_exists "${port}"; then 14 | sudo ufw allow "${port}" || { echo "Error: Failed to allow port ${port}!" >&2; exit 1; } 15 | fi 16 | done 17 | 18 | sudo ufw status 19 | 20 | # Message at the end 21 | echo "Firewall setup was successful." 22 | -------------------------------------------------------------------------------- /tools/qnode_gRPC_calls_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << "EOF" 4 | 5 | Q1Q1Q1\ Q1\ 6 | Q1 __Q1\ Q1Q1 | 7 | Q1 | Q1 |\_Q1 | 8 | Q1 | Q1 | Q1 | 9 | Q1 | Q1 | Q1 | 10 | Q1 Q1Q1 | Q1 | 11 | \Q1Q1Q1 / Q1Q1Q1\ 12 | \___Q1Q\ \______| QUILIBRIUM.ONE 13 | \___| 14 | 15 | ============================================================================ 16 | ✨ gRPC Calls SETUP ✨ 17 | ============================================================================ 18 | This script will edit your .config/config.yml file and setup the gRPC calls. 19 | 20 | Follow the Quilibrium Node guide at https://docs.quilibrium.one 21 | 22 | Made with 🔥 by LaMat - https://quilibrium.one 23 | ============================================================================ 24 | 25 | EOF 26 | 27 | # Function to check if a line exists in a file 28 | line_exists() { 29 | grep -qF "$1" "$2" 30 | } 31 | 32 | # Function to add a line after a specific pattern 33 | add_line_after_pattern() { 34 | sudo sed -i "/^ *$1:/a\ $2" "$3" || { echo "❌ Failed to add line after '$1'! Exiting..."; exit 1; } 35 | } 36 | 37 | # Function to check and modify listenMultiaddr 38 | check_modify_listen_multiaddr() { 39 | echo "🔍 Checking listenMultiaddr..." 40 | 41 | # Using more flexible pattern matching with grep 42 | if grep -q "^[[:space:]]*listenMultiaddr:[[:space:]]*/ip4/0\.0\.0\.0/udp/8336/quic" .config/config.yml; then 43 | echo "🛠️ Modifying listenMultiaddr..." 44 | # Using perl-compatible regex for more reliable replacement 45 | sudo sed -i -E 's|^([[:space:]]*)listenMultiaddr:[[:space:]]*/ip4/0\.0\.0\.0/udp/8336/quic.*$|\1listenMultiaddr: /ip4/0.0.0.0/tcp/8336|' .config/config.yml 46 | 47 | if [ $? -eq 0 ]; then 48 | echo "✅ listenMultiaddr modified to use TCP protocol." 49 | else 50 | echo "❌ Failed to modify listenMultiaddr! Please check manually your config.yml file" 51 | fi 52 | else 53 | # Check for new TCP configuration 54 | if grep -q "^[[:space:]]*listenMultiaddr:[[:space:]]*/ip4/0\.0\.0\.0/tcp/8336" .config/config.yml; then 55 | echo "✅ New listenMultiaddr line found." 56 | else 57 | echo "❌ Neither old nor new listenMultiaddr found. This could cause issues. Please check manually your config.yml file" 58 | fi 59 | fi 60 | } 61 | 62 | # Function to set up local gRPC 63 | setup_local_grpc() { 64 | echo "🚀 Enabling local gRPC and REST..." 65 | sleep 1 66 | cd "$HOME/ceremonyclient/node" || { echo "❌ Failed to change directory to ~/ceremonyclient/node! Exiting..."; exit 1; } 67 | 68 | # Delete existing lines for listenGrpcMultiaddr and listenRESTMultiaddr if they exist 69 | sudo sed -i '/^ *listenGrpcMultiaddr:/d' .config/config.yml 70 | sudo sed -i '/^ *listenRESTMultiaddr:/d' .config/config.yml 71 | 72 | # Add listenGrpcMultiaddr: "/ip4/127.0.0.1/tcp/8337" 73 | echo "listenGrpcMultiaddr: \"/ip4/127.0.0.1/tcp/8337\"" | sudo tee -a .config/config.yml > /dev/null || { echo "❌ Failed to enable gRPC! Exiting..."; exit 1; } 74 | 75 | # Add listenRESTMultiaddr: "/ip4/127.0.0.1/tcp/8338" 76 | echo "listenRESTMultiaddr: \"/ip4/127.0.0.1/tcp/8338\"" | sudo tee -a .config/config.yml > /dev/null || { echo "❌ Failed to enable REST! Exiting..."; exit 1; } 77 | 78 | echo "✅ Local gRPC and REST setup completed." 79 | echo "⚠️ If you where on public RPC previously, and receive errors when querying your -node-info," 80 | echo "you may want to restart your node and let it run until it begins to sync." 81 | return 0 # Explicitly return success 82 | } 83 | 84 | # Function to set up alternative gRPC (blank gRPC, local REST) 85 | setup_public_grpc() { 86 | echo "🚀 Setting up alternative gRPC configuration..." 87 | sleep 1 88 | cd "$HOME/ceremonyclient/node" || { echo "❌ Failed to change directory to ~/ceremonyclient/node! Exiting..."; exit 1; } 89 | 90 | # Delete existing lines for listenGrpcMultiaddr and listenRESTMultiaddr if they exist 91 | sudo sed -i '/^ *listenGrpcMultiaddr:/d' .config/config.yml 92 | sudo sed -i '/^ *listenRESTMultiaddr:/d' .config/config.yml 93 | 94 | # Add blank gRPC and local REST settings 95 | echo "listenGrpcMultiaddr: \"\"" | sudo tee -a .config/config.yml > /dev/null || { echo "❌ Failed to set blank gRPC! Exiting..."; exit 1; } 96 | echo "listenRESTMultiaddr: \"/ip4/127.0.0.1/tcp/8338\"" | sudo tee -a .config/config.yml > /dev/null || { echo "❌ Failed to set REST! Exiting..."; exit 1; } 97 | 98 | echo "✅ Alternative gRPC setup completed (blank gRPC, local REST)." 99 | return 0 # Explicitly return success 100 | } 101 | 102 | # Function to setup stats collection 103 | setup_stats_collection() { 104 | echo "📊 Enabling Stats Collection..." 105 | if ! line_exists "statsMultiaddr: \"/dns/stats.quilibrium.com/tcp/443\"" .config/config.yml; then 106 | add_line_after_pattern "engine" "statsMultiaddr: \"/dns/stats.quilibrium.com/tcp/443\"" .config/config.yml 107 | echo "✅ Stats Collection enabled." 108 | else 109 | echo "✅ Stats Collection already enabled." 110 | fi 111 | } 112 | 113 | # Main menu with proper input handling 114 | while true; do 115 | echo -e "\nPlease select a setup option:" 116 | echo 117 | echo "1) Setup local gRPC" 118 | echo " Choose if you are running a node" 119 | echo 120 | echo "2) Setup public gRPC" 121 | echo " Choose if you want to run the Qclient without having a working node" 122 | echo 123 | read -r choice 124 | echo 125 | 126 | case $choice in 127 | 1) 128 | setup_local_grpc 129 | setup_stats_collection 130 | #check_modify_listen_multiaddr 131 | echo -e "\n✅ Configuration complete! You can check your settings with:" 132 | echo "cd $HOME/ceremonyclient/node/.config/ && cat config.yml" 133 | exit 0 # Exit with success 134 | ;; 135 | 2) 136 | setup_public_grpc 137 | setup_stats_collection 138 | #check_modify_listen_multiaddr 139 | echo -e "\n✅ Configuration complete! You can check your settings with:" 140 | echo "cd $HOME/ceremonyclient/node/.config/ && cat config.yml" 141 | exit 0 # Exit with success 142 | ;; 143 | *) 144 | echo "❌ Invalid option. Please select 1 or 2." 145 | continue # Continue the loop for invalid input 146 | ;; 147 | esac 148 | done -------------------------------------------------------------------------------- /tools/qnode_gsheet_config_update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check if running as part of a larger script 4 | PARENT_SCRIPT=${PARENT_SCRIPT:-0} 5 | 6 | set -e # Exit on error 7 | 8 | # CONFIG FILE UPDATE for "REWARDS TO GOOGLE SHEET SCRIPT" 9 | 10 | QNODE_DIR="$HOME/ceremonyclient/node" 11 | 12 | # Get current node binary name (just the executable, excluding .dgst and .sig files) 13 | QNODE_BINARY_NAME=$(find "$QNODE_DIR" -name "node-[0-9]*" ! -name "*.dgst*" ! -name "*.sig*" -type f -executable 2>/dev/null | sort -V | tail -n 1 | xargs basename) 14 | 15 | if [ -n "$QNODE_BINARY_NAME" ]; then 16 | echo "Found local node binary: $QNODE_BINARY_NAME" 17 | else 18 | echo "❌ Error: No local node binary found in $QNODE_DIR" 19 | if [ "$PARENT_SCRIPT" = "1" ]; then 20 | return 1 2>/dev/null 21 | else 22 | exit 1 23 | fi 24 | fi 25 | 26 | # Define the config files 27 | CONFIG_FILE1="$HOME/scripts/qnode_rewards_to_gsheet.config" 28 | CONFIG_FILE2="$HOME/scripts/qnode_rewards_to_gsheet_2.config" 29 | 30 | # Function to display section headers 31 | display_header() { 32 | echo 33 | echo "==============================================================" 34 | echo "$1" 35 | echo "==============================================================" 36 | echo 37 | } 38 | 39 | # Check if either of the config files exist 40 | if [ -f "$CONFIG_FILE1" ] || [ -f "$CONFIG_FILE2" ]; then 41 | display_header "UPDATING EXTRA CONFIG FILES (OPTIONAL)" 42 | 43 | echo "This is an optional section that almost nobody needs." 44 | echo "Don't worry if you receive errors." 45 | echo 46 | 47 | # Function to update config file 48 | update_config_file() { 49 | local config_file="$1" 50 | local status=0 51 | 52 | echo "✅ Checking node version in config file '$(basename "$config_file")'." 53 | 54 | if [ ! -w "$config_file" ]; then 55 | echo "❌ Error: Config file $config_file is not writable" 56 | return 1 57 | fi 58 | 59 | # Get the current NODE_BINARY from the config file 60 | config_node_binary=$(grep -E "^NODE_BINARY\s*=\s*" "$config_file" | sed -E 's/^NODE_BINARY\s*=\s*//' | tr -d '"' | tr -d "'") 61 | 62 | if [ -z "$config_node_binary" ]; then 63 | echo "❌ Error: Could not find NODE_BINARY in config file" 64 | return 1 65 | fi 66 | 67 | echo "Config file currently has: $config_node_binary" 68 | 69 | # Compare binary names 70 | if [ "$config_node_binary" = "$QNODE_BINARY_NAME" ]; then 71 | echo "✅ Node binary names match. No update needed." 72 | else 73 | echo "⏳ Node binary names differ. Updating config file..." 74 | echo "Current value: $config_node_binary" 75 | echo "New value: $QNODE_BINARY_NAME" 76 | 77 | # Create a backup of the config file 78 | if ! cp "$config_file" "${config_file}.backup"; then 79 | echo "❌ Error: Failed to create backup file" 80 | return 1 81 | fi 82 | 83 | # Update the config file preserving the original spacing format 84 | if grep -q "^NODE_BINARY\s*=\s*" "$config_file"; then 85 | # Format with spaces exists, preserve it 86 | original_format=$(grep -E "^NODE_BINARY\s*=\s*" "$config_file" | sed -E 's/NODE_BINARY(\s*=\s*).*/\1/') 87 | sed -E "s|^NODE_BINARY\s*=\s*.*|NODE_BINARY${original_format}${QNODE_BINARY_NAME}|" "$config_file" > "${config_file}.tmp" 88 | else 89 | # No spaces format 90 | sed "s|^NODE_BINARY=.*|NODE_BINARY=${QNODE_BINARY_NAME}|" "$config_file" > "${config_file}.tmp" 91 | fi 92 | 93 | if [ -s "${config_file}.tmp" ]; then 94 | if ! mv "${config_file}.tmp" "$config_file"; then 95 | echo "❌ Error: Failed to update config file" 96 | mv "${config_file}.backup" "$config_file" 97 | return 1 98 | fi 99 | echo "✅ Config file updated successfully." 100 | rm -f "${config_file}.backup" 101 | else 102 | echo "❌ Error: Generated empty config file" 103 | mv "${config_file}.backup" "$config_file" 104 | rm -f "${config_file}.tmp" 105 | return 1 106 | fi 107 | fi 108 | } 109 | 110 | # Array of config files 111 | config_files=("$CONFIG_FILE1" "$CONFIG_FILE2") 112 | overall_status=0 113 | 114 | # Loop through config files 115 | for config_file in "${config_files[@]}"; do 116 | if [ -f "$config_file" ]; then 117 | if ! update_config_file "$config_file"; then 118 | overall_status=1 119 | echo "⚠️ Warning: Failed to update $(basename "$config_file")" 120 | fi 121 | echo "-------------------" 122 | else 123 | echo "⚠️ Warning: Config file not found: $config_file" 124 | overall_status=1 125 | fi 126 | done 127 | 128 | echo "All config files processed." 129 | if [ $overall_status -ne 0 ]; then 130 | echo "⚠️ Warning: Some operations failed" 131 | if [ "$PARENT_SCRIPT" = "1" ]; then 132 | return $overall_status 2>/dev/null 133 | else 134 | exit $overall_status 135 | fi 136 | fi 137 | fi -------------------------------------------------------------------------------- /tools/qnode_listen_multiaddr_updater.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #!/bin/bash 4 | 5 | HOME=$(eval echo ~$USER) 6 | NODE_PATH="$HOME/ceremonyclient/node" 7 | CONFIG_FILE="$NODE_PATH/.config/config.yml" 8 | OLD_LINE="listenMultiaddr: /ip4/0.0.0.0/udp/8336/quic" 9 | NEW_LINE="listenMultiaddr: /ip4/0.0.0.0/tcp/8336" 10 | 11 | 12 | echo "This script will check if the line 'listenMultiaddr: /ip4/0.0.0.0/udp/8336/quic'" 13 | echo "exists in the file '$HOME/ceremonyclient/node/.config/config.yml'. " 14 | echo "If found, it will change it to 'listenMultiaddr: /ip4/0.0.0.0/tcp/8336'." 15 | sleep 3 16 | 17 | # Check if config file exists 18 | if [ ! -f "$CONFIG_FILE" ]; then 19 | echo "Error: Config file $CONFIG_FILE not found." 20 | exit 1 21 | fi 22 | 23 | # Check if the old line exists in the config file 24 | if grep -q "$OLD_LINE" "$CONFIG_FILE"; then 25 | # Replace the old line with the new one 26 | sed -i "s/$OLD_LINE/$NEW_LINE/" "$CONFIG_FILE" 27 | echo "Success: Line changed in $CONFIG_FILE" 28 | else 29 | echo "Error: The line $OLD_LINE does not exist in $CONFIG_FILE" 30 | fi 31 | -------------------------------------------------------------------------------- /tools/qnode_oom_sys_restart_installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << "EOF" 4 | 5 | Q1Q1Q1\ Q1\ 6 | Q1 __Q1\ Q1Q1 | 7 | Q1 | Q1 |\_Q1 | 8 | Q1 | Q1 | Q1 | 9 | Q1 | Q1 | Q1 | 10 | Q1 Q1Q1 | Q1 | 11 | \Q1Q1Q1 / Q1Q1Q1\ 12 | \___Q1Q\ \______| QUILIBRIUM.ONE 13 | \___| 14 | 15 | =================================================================== 16 | ✨ OOM Monitoring Script Installer ✨ 17 | =================================================================== 18 | This script will: 19 | 1. Create a monitoring script to check RAM usage 20 | 2. Set up a cron job to run the monitoring script every 10 minutes 21 | 3. The monitoring script will restart the ceremonyclient service 22 | if RAM usage exceeds 95% 23 | 24 | Made with 🔥 by LaMat - https://quilibrium.one 25 | ==================================================================== 26 | 27 | Processing... ⏳ 28 | 29 | EOF 30 | 31 | sleep 5 # add sleep time 32 | 33 | # Check if ceremonyclient.service exists 34 | SERVICE_FILE="/lib/systemd/system/ceremonyclient.service" 35 | if [ ! -f "$SERVICE_FILE" ]; then 36 | echo "❌ Error: The file $SERVICE_FILE does not exist. Ceremonyclient service setup failed." 37 | exit 1 38 | fi 39 | 40 | # Define variables 41 | SCRIPT_DIR=$HOME/scripts 42 | SCRIPT_FILE=$SCRIPT_DIR/qnode_oom_sys_restart.sh 43 | 44 | # Function to check if a command succeeded 45 | check_command() { 46 | if [ $? -ne 0 ]; then 47 | echo "❌ Error: $1" 48 | sleep 1 49 | exit 1 50 | fi 51 | } 52 | 53 | # Create the scripts directory if it doesn't exist 54 | echo "⌛️ Creating script directory..." 55 | sleep 1 56 | mkdir -p $SCRIPT_DIR 57 | check_command "Failed to create script directory" 58 | 59 | # Overwrite the monitoring script if it already exists 60 | echo "⌛️ Creating or overwriting monitoring script..." 61 | sleep 1 62 | cat << 'EOF' >| $SCRIPT_FILE 63 | #!/bin/bash 64 | 65 | LOG_DIR=~/scripts/log 66 | mkdir -p $LOG_DIR 67 | 68 | # Function to get the current RAM usage percentage 69 | get_ram_usage() { 70 | free | awk '/Mem/{printf("%.2f\n"), $3/$2*100}' 71 | } 72 | 73 | # Function to restart the ceremonyclient service 74 | restart_service() { 75 | local timestamp=$(date +"%Y-%m-%d %H:%M:%S") 76 | echo "$timestamp: RAM usage is above 95%. Restarting ceremonyclient service..." | tee -a $LOG_DIR/monitor.log 77 | if sudo service ceremonyclient restart; then 78 | sleep 5 79 | echo "$timestamp: ceremonyclient service restarted successfully." >> $LOG_DIR/qnode_oom_sys_restart.log 80 | else 81 | echo "$timestamp: Failed to restart ceremonyclient service." >> $LOG_DIR/qnode_oom_sys_restart.log 82 | fi 83 | } 84 | 85 | # Check RAM usage and restart service if necessary 86 | RAM_USAGE=$(get_ram_usage) 87 | if (( $(echo "$RAM_USAGE > 95.00" | bc -l) )); then 88 | restart_service 89 | fi 90 | EOF 91 | check_command "Failed to create or overwrite monitoring script" 92 | 93 | # Make the script executable 94 | echo "⌛️ Making the script executable..." 95 | sleep 1 96 | chmod +x $SCRIPT_FILE 97 | check_command "Failed to make script executable" 98 | 99 | # Check if cron job already exists 100 | echo "⌛️ Checking if cron job exists..." 101 | sleep 1 102 | if crontab -l | grep -q "$SCRIPT_FILE"; then 103 | echo "✅ Cron job already exists. Skipping..." 104 | else 105 | # Create a cron job to run the script every 10 minutes 106 | echo "⌛️ Setting up cron job..." 107 | sleep 1 108 | if (crontab -l 2>/dev/null; echo "*/10 * * * * $SCRIPT_FILE") | crontab -; then 109 | echo "✅ Cron job created successfully." 110 | sleep 1 111 | else 112 | echo "❌ Failed to create cron job. Please check your permissions." 113 | sleep 1 114 | exit 1 115 | fi 116 | fi 117 | 118 | echo "✅ Installation complete. The monitoring script has been set up and the cron job has been created or skipped." 119 | sleep 1 120 | echo "You can find the monitoring script at: $SCRIPT_FILE" 121 | sleep 1 122 | echo "Logs will be written to: ~/scripts/log/" 123 | sleep 1 124 | echo "To disable the script simply run 'crontab -e' and comment out the line:" 125 | echo "*/10 * * * * $SCRIPT_FILE" 126 | -------------------------------------------------------------------------------- /tools/qnode_peermanifest_checker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script installs grpcurl, jq, and base58 if they are not already installed, 4 | # then retrieves peer information from a Quilibrium node. 5 | 6 | 7 | 8 | cat << "EOF" 9 | 10 | Q1Q1Q1\ Q1\ 11 | Q1 __Q1\ Q1Q1 | 12 | Q1 | Q1 |\_Q1 | 13 | Q1 | Q1 | Q1 | 14 | Q1 | Q1 | Q1 | 15 | Q1 Q1Q1 | Q1 | 16 | \Q1Q1Q1 / Q1Q1Q1\ 17 | \___Q1Q\ \______| QUILIBRIUM.ONE 18 | \___| 19 | 20 | =========================================================================== 21 | ✨ QNODE PEER MANIFEST CHECKER ✨ 22 | =========================================================================== 23 | This script will retrieve your Quilibrium node peer manifest. 24 | 25 | Follow the guide at https://docs.quilibrium.one 26 | 27 | Made with 🔥 by LaMat - https://quilibrium.one 28 | =========================================================================== 29 | 30 | Processing... ⏳ 31 | 32 | EOF 33 | 34 | sleep 7 # Add a 7-second delay 35 | 36 | 37 | # Export some variables ot solve the gRPCurl not found error 38 | export GOROOT=/usr/local/go 39 | export GOPATH=$HOME/go 40 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 41 | 42 | # Install gRPCurl if not installed 43 | if which grpcurl >/dev/null; then 44 | echo "✅ gRPCurl is installed." 45 | else 46 | echo "❌ gRPCurl is not installed." 47 | echo "📦 Installing gRPCurl..." 48 | sleep 1 # Add a 1-second delay 49 | # Try installing gRPCurl using go install 50 | if go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest; then 51 | echo "✅ gRPCurl installed successfully via go install." 52 | echo 53 | else 54 | echo "⚠️ Failed to install gRPCurl via go install. Trying apt-get..." 55 | # Try installing gRPCurl using apt-get 56 | if sudo apt-get install grpcurl -y; then 57 | echo "✅ gRPCurl installed successfully via apt-get." 58 | echo 59 | else 60 | echo "❌ Failed to install gRPCurl via apt-get! Please install it manually." 61 | exit 1 62 | fi 63 | fi 64 | fi 65 | 66 | # Install jq if not installed 67 | if ! command_exists jq; then 68 | echo "📦 Installing jq..." 69 | sudo apt-get install -y jq 70 | fi 71 | 72 | # Install base58 if not installed 73 | if ! command_exists base58; then 74 | echo "📦 Installing base58..." 75 | sudo apt-get install -y base58 76 | fi 77 | 78 | # Command to retrieve peer information 79 | get_peer_info_command="peer_id_base64=\$(grpcurl -plaintext localhost:8337 quilibrium.node.node.pb.NodeService.GetNodeInfo | jq -r .peerId | base58 -d | base64) && grpcurl -plaintext -max-msg-sz 5000000 localhost:8337 quilibrium.node.node.pb.NodeService.GetPeerManifests | grep -A 15 -B 1 \"\$peer_id_base64\"" 80 | 81 | # Demipoet code https://quilibrium.guide/manage-node/node-difficulty-metric#2-getting-your-node-difficulty-metric 82 | #grpcurl -plaintext -max-msg-sz 5000000 localhost:8337 quilibrium.node.node.pb.NodeService.GetPeerManifests | less | grep -B 1 -A 16 $(echo -n Qmxxxxxxxxx | base58 -d | base64) 83 | 84 | # Execute the command 85 | echo "🚀 Retrieving peer information..." 86 | eval $get_peer_info_command 87 | 88 | # Check for errors 89 | if [ $? -ne 0 ]; then 90 | echo "❌ Error: Failed to retrieve peer information. Please make sure your Quilibrium node is running and accessible." 91 | echo "You can only retrieve the peer manifest on fresh nodes after 15-30 minutes that the node has been running." 92 | exit 1 93 | fi 94 | 95 | echo 96 | echo 97 | echo "🎉 Peer information retrieved successfully!" 98 | -------------------------------------------------------------------------------- /tools/qnode_rewards_monitor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_VERSION=1.7 4 | 5 | # Colors and formatting 6 | BOLD='\033[1m' 7 | BLUE='\033[94m' 8 | YELLOW='\033[33m' 9 | RED='\033[31m' 10 | NC='\033[0m' # No Color 11 | 12 | # Icons (Unicode) 13 | WARNING="⚠️" 14 | 15 | # Set default minutes to 60 if no argument provided 16 | if [ $# -eq 0 ]; then 17 | minutes=60 18 | else 19 | # Validate input is a positive number 20 | if ! [[ $1 =~ ^[0-9]+$ ]]; then 21 | echo -e "${RED}${WARNING} Error: Please provide a positive number of minutes${NC}" 22 | exit 1 23 | fi 24 | minutes=$1 25 | fi 26 | 27 | # Get current timestamp 28 | current_timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") 29 | 30 | # Function to check for newer script version 31 | check_for_updates() { 32 | LATEST_VERSION=$(curl -s "https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/tools/qnode_rewards_monitor.sh" | grep 'SCRIPT_VERSION=' | head -1 | cut -d'=' -f2) 33 | if [ "$SCRIPT_VERSION" != "$LATEST_VERSION" ]; then 34 | curl -s -o ~/scripts/qnode_rewards_monitor.sh "https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/tools/qnode_rewards_monitor.sh" 35 | chmod +x ~/scripts/qnode_rewards_monitor.sh 36 | fi 37 | } 38 | 39 | 40 | # Process the input data 41 | process_data() { 42 | while IFS= read -r line; do 43 | amount=$(echo "$line" | awk '{print $1}') 44 | timestamp=$(echo "$line" | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z') 45 | 46 | current_seconds=$(date -d "$current_timestamp" +%s) 47 | coin_seconds=$(date -d "$timestamp" +%s) 48 | time_diff=$(( (current_seconds - coin_seconds) / 60 )) 49 | 50 | if [ $time_diff -le $minutes ]; then 51 | echo "$timestamp $amount $time_diff" 52 | fi 53 | done | sort -k1,1 54 | } 55 | 56 | # Format timestamp to human readable 57 | format_timestamp() { 58 | local timestamp=$1 59 | date -d "$timestamp" "+%Y-%m-%d %H:%M:%S" 60 | } 61 | 62 | # Calculate statistics from the processed data 63 | calculate_stats() { 64 | local total=0 65 | local count=0 66 | local first_timestamp="" 67 | local last_timestamp="" 68 | 69 | while IFS=' ' read -r timestamp amount mins; do 70 | if [ -z "$first_timestamp" ]; then 71 | first_timestamp=$timestamp 72 | fi 73 | last_timestamp=$timestamp 74 | total=$(echo "$total + $amount" | bc) 75 | ((count++)) 76 | done 77 | 78 | if [ $count -eq 0 ]; then 79 | echo -e "${RED}${INFO} No data found for the last $minutes minutes${NC}" 80 | exit 0 81 | fi 82 | 83 | # Calculate average per coin 84 | average=$(echo "scale=8; $total / $count" | bc) 85 | 86 | # Calculate time span of available data 87 | start_seconds=$(date -d "$first_timestamp" +%s) 88 | end_seconds=$(date -d "$last_timestamp" +%s) 89 | span_minutes=$(( (end_seconds - start_seconds) / 60 )) 90 | 91 | # Calculate rewards per minute for projections 92 | rewards_per_minute=$(echo "scale=8; $total / $span_minutes" | bc) 93 | 94 | # Project hourly and daily rates 95 | hourly_rewards=$(echo "scale=8; $rewards_per_minute * 60" | bc) 96 | daily_rewards=$(echo "scale=8; $rewards_per_minute * 1440" | bc) 97 | 98 | # Format timestamps 99 | start_time=$(format_timestamp "$first_timestamp") 100 | end_time=$(format_timestamp "$last_timestamp") 101 | 102 | echo -e "${BOLD}Rewards analysis:${NC}" 103 | echo -e "---------------------------------------------------------------" 104 | echo -e "Time range: $start_time to $end_time" 105 | echo -e "Time span analyzed: $span_minutes minutes" 106 | echo "" 107 | echo -e "${BOLD}Current Data:${NC}" 108 | echo -e " Number of coins analyzed: ${BOLD}$count${NC}" 109 | echo -e " Average QUIL per coin: ${BOLD}$average${NC}" 110 | echo -e " Total QUIL rewards: ${BOLD}$total${NC}" 111 | echo "" 112 | echo -e "${BOLD}Projections:${NC}" 113 | echo -e " Hourly QUIL: ${BOLD}$hourly_rewards${NC}" 114 | echo -e " Daily QUIL: ${BOLD}$daily_rewards${NC}" 115 | echo "" 116 | 117 | if [ $span_minutes -lt 60 ]; then 118 | echo -e "${BLUE}Hourly projections are based on less than one hour of data${NC}" 119 | fi 120 | if [ $span_minutes -lt 1440 ]; then 121 | echo -e "${BLUE}Daily projections are based on less than 24 hours of data${NC}" 122 | fi 123 | echo "---------------------------------------------------------------" 124 | echo 125 | echo "To analyze a different time span add the number of minutes to the command, e.g.:" 126 | echo "$HOME/scripts/qnode_rewards_monitor.sh 180" 127 | echo 128 | echo "Version $SCRIPT_VERSION" 129 | } 130 | 131 | # Main execution 132 | check_for_updates 133 | 134 | # Show processing message 135 | echo -e "\n${BLUE}Processing... Please wait${NC}\n" 136 | 137 | qclient_output=$(qclient token coins metadata --config /root/ceremonyclient/node/.config --public-rpc) 138 | 139 | echo "$qclient_output" | process_data | calculate_stats -------------------------------------------------------------------------------- /tools/qnode_server_revert.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "===========================================================================" 4 | echo " 🔄 QNODE SERVER REVERT 🔄" 5 | echo "===========================================================================" 6 | echo "This script will revert changes made by the QNode server setup script." 7 | echo "Please run this script with sudo privileges." 8 | echo "===========================================================================" 9 | 10 | # Function to remove a line from a file if it exists 11 | remove_line_from_file() { 12 | if grep -q "$1" "$2"; then 13 | sudo sed -i "\|$1|d" "$2" 14 | echo "✅ Removed '$1' from $2." 15 | else 16 | echo "✅ '$1' not found in $2. No action needed." 17 | fi 18 | } 19 | 20 | # Uninstall packages 21 | echo "⏳ Uninstalling packages..." 22 | sudo apt-get remove -y git tar tmux cron jq grpcurl ufw fail2ban 23 | 24 | # Remove Go 25 | echo "⏳ Removing Go..." 26 | sudo rm -rf /usr/local/go 27 | remove_line_from_file 'export PATH=$PATH:/usr/local/go/bin' ~/.bashrc 28 | remove_line_from_file "export GOPATH=$HOME/go" ~/.bashrc 29 | remove_line_from_file "export GO111MODULE=on" ~/.bashrc 30 | remove_line_from_file "export GOPROXY=https://goproxy.cn,direct" ~/.bashrc 31 | 32 | # Remove gRPCurl 33 | echo "⏳ Removing gRPCurl..." 34 | sudo rm -f $(which grpcurl) 35 | 36 | # Revert network buffer sizes 37 | echo "⏳ Reverting network buffer sizes..." 38 | sudo sed -i '/net.core.rmem_max=600000000/d' /etc/sysctl.conf 39 | sudo sed -i '/net.core.wmem_max=600000000/d' /etc/sysctl.conf 40 | sudo sysctl -p 41 | 42 | # Remove UFW rules 43 | echo "⏳ Removing UFW rules..." 44 | sudo ufw --force reset 45 | 46 | # Remove Fail2Ban 47 | echo "⏳ Removing Fail2Ban..." 48 | sudo apt-get remove -y fail2ban 49 | sudo rm -rf /etc/fail2ban 50 | 51 | # Remove created folders 52 | echo "⏳ Removing created folders..." 53 | #sudo rm -rf /root/backup/ 54 | #sudo rm -rf /root/scripts/ 55 | 56 | # Clean up package manager 57 | echo "⏳ Cleaning up package manager..." 58 | sudo apt-get autoremove -y 59 | sudo apt-get clean 60 | 61 | echo "🎉 Revert process completed!" 62 | echo "You may want to reboot your server to ensure all changes take effect." 63 | echo "Type 'sudo reboot' and press ENTER to reboot your server." -------------------------------------------------------------------------------- /tools/qnode_store_backup_aws.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # [SCRIPT HEADER] 4 | 5 | cat << "EOF" 6 | 7 | QQQQQQQQQ 1111111 8 | QQ:::::::::QQ 1::::::1 9 | QQ:::::::::::::QQ 1:::::::1 10 | Q:::::::QQQ:::::::Q111:::::1 11 | Q::::::O Q::::::Q 1::::1 12 | Q:::::O Q:::::Q 1::::1 13 | Q:::::O Q:::::Q 1::::1 14 | Q:::::O Q:::::Q 1::::l 15 | Q:::::O Q:::::Q 1::::l 16 | Q:::::O Q:::::Q 1::::l 17 | Q:::::O QQQQ:::::Q 1::::l 18 | Q::::::O Q::::::::Q 1::::l 19 | Q:::::::QQ::::::::Q111::::::111 20 | QQ::::::::::::::Q 1::::::::::1 21 | QQ:::::::::::Q 1::::::::::1 22 | QQQQQQQQ::::QQ111111111111 23 | Q:::::Q 24 | QQQQQQ QUILIBRIUM.ONE 25 | 26 | 27 | ========================================================================== 28 | ✨ NODE "STORE" BACKUP VIA AWS ✨ 29 | ========================================================================== 30 | This script automates the backup of your node "store" data to AWS S3. 31 | You need an AWS account and a Public/Secret access key. 32 | 33 | For security create a user + keys specific to the bucket you want to use. 34 | 35 | Made with 🔥 by LaMat - https://quilibrium.one 36 | =========================================================================== 37 | 38 | Processing... ⏳ 39 | 40 | EOF 41 | 42 | sleep 7 # add sleep time 43 | 44 | # Function to check for newer script version and update 45 | check_for_updates() { 46 | SCRIPT_CHECKSUM=$(md5sum ~/scripts/qnode_store_backup_aws.sh | awk '{ print $1 }') 47 | LATEST_CHECKSUM=$(curl -s https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/tools/qnode_store_backup_aws.sh | md5sum | awk '{ print $1 }') 48 | 49 | if [ "$SCRIPT_CHECKSUM" != "$LATEST_CHECKSUM" ]; then 50 | echo "Updating the script to the latest version..." 51 | sleep 1 52 | curl -o ~/scripts/qnode_store_backup_idrive.sh https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/main/tools/qnode_store_backup_aws.sh || display_error "❌ Failed to download the newer version of the script." 53 | chmod +x ~/scripts/qnode_store_backup_aws.sh || display_error "❌ Failed to set execute permission for the updated script." 54 | echo "✅ Script updated successfully." 55 | sleep 1 56 | echo "Please run the script again." 57 | exit 0 58 | fi 59 | } 60 | 61 | # Check for updates and update if available 62 | check_for_updates 63 | 64 | 65 | # [USER INPUT] 66 | 67 | echo "⚙️ Updating package repositories..." 68 | sudo apt update 69 | sleep 1 70 | 71 | # [CHECK FOR AWS CLI] 72 | if ! command -v aws &> /dev/null; then 73 | echo "⚙️ Installing AWS CLI..." 74 | sudo apt update 75 | sudo apt install awscli -y 76 | echo "✅ AWS CLI installed." 77 | else 78 | echo "ℹ️ AWS CLI is already installed." 79 | fi 80 | 81 | echo "⚙️ Configuring AWS CLI..." 82 | aws configure 83 | sleep 1 84 | 85 | # [USER CONFIGURATION] 86 | 87 | echo "" 88 | echo "ℹ️ Please specify how frequently you want to run the backup (in hours):" 89 | read -p "Enter the backup frequency: " BACKUP_FREQUENCY 90 | echo "" 91 | 92 | # Prompt the user if they already have a bucket 93 | read -p "Do you already have an AWS S3 bucket for backups? (y/n): " HAS_BUCKET 94 | echo "" 95 | if [[ $HAS_BUCKET == "y" ]]; then 96 | echo "Tip: Use a bucket specific to Quilibrium." 97 | read -p "Enter the name of your existing AWS S3 bucket: " BUCKET_NAME 98 | echo "" 99 | else 100 | echo "Tip: Create a bucket specific to Quilibrium." 101 | read -p "Enter a name for your new AWS S3 bucket: " BUCKET_NAME 102 | echo "" 103 | # Create the bucket 104 | aws s3 mb s3://$BUCKET_NAME 105 | echo "✅ Bucket '$BUCKET_NAME' created successfully." 106 | fi 107 | 108 | echo "" 109 | echo "ℹ️ Please provide a unique name for the remote folder, eg. 'Q1' (no spaces or special characters, max 20 characters)." 110 | echo "This must be unique for each node. Your store files will be backed up inside this folder on AWS." 111 | while true; do 112 | read -p "Enter the folder name: " TARGET_FOLDER 113 | if [[ ! "$TARGET_FOLDER" =~ ^[a-zA-Z0-9_-]{1,20}$ ]]; then 114 | echo "❌ Error: Folder name can only contain letters, numbers, - and _, and must be 20 characters or less." 115 | else 116 | break 117 | fi 118 | done 119 | 120 | echo "" 121 | echo "Your remote backup location on AWS will be '$BUCKET_NAME/stores_backup/$TARGET_FOLDER/'" 122 | echo "" 123 | sleep 1 124 | 125 | # [CRON JOB] 126 | 127 | echo "⚙️ Creating cronjob to run backup every $BACKUP_FREQUENCY hours..." 128 | RANDOM_MINUTE=$((1 + $RANDOM % 59)) # Generate a random minute between 1 and 59 129 | CRON_EXPRESSION="$RANDOM_MINUTE */$BACKUP_FREQUENCY * * *" 130 | (crontab -l ; echo "$CRON_EXPRESSION aws s3 sync ~/ceremonyclient/node/.config/store s3://$BUCKET_NAME/stores_backup/$TARGET_FOLDER --delete") | crontab - 131 | sleep 1 132 | 133 | # [COMPLETION] 134 | 135 | echo "✅ Backup setup complete!" 136 | echo "" 137 | echo "You have configured the backup to run every $BACKUP_FREQUENCY hours at minute $((1 + RANDOM % 59)) to the bucket '$BUCKET_NAME'." 138 | sleep 1 139 | echo "✅ IMPORTANT NOTE" 140 | echo "Please note that is a 2 way backup. The store folder on AWS will always mirror the one in your server." 141 | echo "So... if you delete the store folder in your server, it will deleted the one on AWS too." 142 | echo "If you want to avoid this, just edit your cronjob (run crontab -e) and remove the --delete flag from the command." 143 | echo "If you do this, your AWS store folder will grow bigger then your actual one, and won't mirror it anymore." 144 | echo "" 145 | echo "✅ TEST YOUR BACKUP" 146 | echo "You can test this backup with a 'dry run' using the command below." 147 | echo "The 'dry run' doesn't back up anything, it just shows you what it would back up." 148 | echo "aws s3 sync ~/ceremonyclient/node/.config/store s3://$BUCKET_NAME//stores_backup/$TARGET_FOLDER --dryrun" 149 | -------------------------------------------------------------------------------- /tools/qnode_store_snapshot_storj.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ##################### 4 | # Logs - Configuration 5 | ##################### 6 | 7 | # Log configuration 8 | LOG_DIR="$HOME/scripts/logs" 9 | LOG_FILE="$LOG_DIR/qnode_store_snapshot.log" 10 | LOG_ENTRIES=1000 11 | 12 | # Create log directory if needed 13 | if [ ! -d "$LOG_DIR" ]; then 14 | echo "Log directory does not exist. Creating $LOG_DIR..." 15 | if ! mkdir -p "$LOG_DIR" 2>/dev/null; then 16 | echo "ERROR: Failed to create log directory $LOG_DIR" 17 | exit 1 18 | fi 19 | fi 20 | 21 | # Set up logging with timestamps 22 | exec 1> >(while read line; do echo "[$(date '+%Y-%m-%d %H:%M:%S')] $line"; done | tee -a "$LOG_FILE") 2>&1 23 | 24 | ##################### 25 | # Backup store folder 26 | ##################### 27 | 28 | echo "Starting Quilibrium node store backup process" 29 | 30 | # Stop the ceremony client service 31 | echo "Stopping ceremonyclient service..." 32 | if ! systemctl stop ceremonyclient; then 33 | echo "ERROR: Failed to stop ceremonyclient service" 34 | exit 1 35 | fi 36 | 37 | # Wait for the service to fully stop 38 | echo "Waiting for service to stop completely..." 39 | sleep 10 40 | 41 | # Sync the store directory to Storj 42 | echo "Starting rclone sync to Storj..." 43 | if ! rclone sync $HOME/ceremonyclient/node/.config/store storj:/quilibrium/snapshot/store --exclude "snapshot/**"; then 44 | echo "ERROR: Failed to sync store directory to Storj" 45 | # Attempt to restart service before exiting 46 | systemctl start ceremonyclient 47 | exit 1 48 | fi 49 | 50 | # Wait for sync to complete and system to settle 51 | echo "Waiting for sync to complete..." 52 | sleep 10 53 | 54 | # Restart the ceremony client service 55 | echo "Restarting ceremonyclient service..." 56 | if ! systemctl start ceremonyclient; then 57 | echo "ERROR: Failed to restart ceremonyclient service" 58 | exit 1 59 | fi 60 | 61 | echo "Sync completed and service restarted successfully" 62 | 63 | ##################### 64 | # Logs - Cleanup 65 | ##################### 66 | 67 | # Rotate logs 68 | echo "Rotating logs..." 69 | if ! tail -n $LOG_ENTRIES "$LOG_FILE" > "$LOG_FILE.tmp"; then 70 | echo "ERROR: Failed to rotate logs" 71 | exit 1 72 | fi 73 | 74 | if ! mv "$LOG_FILE.tmp" "$LOG_FILE"; then 75 | echo "ERROR: Failed to move rotated log file" 76 | exit 1 77 | fi 78 | 79 | echo "Script completed successfully" -------------------------------------------------------------------------------- /tools/qnode_system_cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Function to display the banner 4 | show_banner() { 5 | cat << "EOF" 6 | 7 | Q1Q1Q1\ Q1\ 8 | Q1 __Q1\ Q1Q1 | 9 | Q1 | Q1 |\_Q1 | 10 | Q1 | Q1 | Q1 | 11 | Q1 | Q1 | Q1 | 12 | Q1 Q1Q1 | Q1 | 13 | \Q1Q1Q1 / Q1Q1Q1\ 14 | \___Q1Q\ \______| QUILIBRIUM.ONE 15 | \___| 16 | 17 | ========================================================================== 18 | ✨ SYSTEM CLEANER ✨ 19 | ========================================================================== 20 | This script will clean up your system from temp files and old logs 21 | 22 | 23 | Made with 🔥 by LaMat - https://quilibrium.one 24 | =========================================================================== 25 | 26 | EOF 27 | } 28 | 29 | # Function to show status message 30 | show_status() { 31 | echo "Cleaning: $1..." 32 | } 33 | 34 | # Function to calculate freed space in MB 35 | calculate_freed_space() { 36 | local before=$1 37 | local after=$2 38 | echo "scale=2; ($before - $after) * 1024" | bc 39 | } 40 | 41 | # Backup function for important logs before cleaning 42 | backup_important_logs() { 43 | local backup_dir="/var/log/cleaned_logs_backup" 44 | local date_stamp=$(date +%Y%m%d_%H%M%S) 45 | 46 | show_status "Important system logs" 47 | 48 | # Create backup directory if it doesn't exist 49 | sudo mkdir -p "$backup_dir" 50 | 51 | # Backup authentication logs 52 | if [ -f "/var/log/auth.log" ]; then 53 | sudo cp /var/log/auth.log "$backup_dir/auth.log.$date_stamp" 54 | fi 55 | 56 | # Backup system logs 57 | if [ -f "/var/log/syslog" ]; then 58 | sudo cp /var/log/syslog "$backup_dir/syslog.$date_stamp" 59 | fi 60 | 61 | # Keep only last 5 backups 62 | cd "$backup_dir" && ls -t | tail -n +6 | xargs -r sudo rm -- 63 | } 64 | 65 | # Function for safe system cleanup 66 | clean_system() { 67 | # Backup important logs first 68 | backup_important_logs 69 | 70 | show_status "APT cache" 71 | sudo apt-get clean >/dev/null 2>&1 72 | sudo apt-get autoclean >/dev/null 2>&1 73 | sudo apt-get autoremove --purge -y >/dev/null 2>&1 74 | 75 | show_status "Old kernels" 76 | sudo dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | grep -v $(uname -r) | head -n -1 | xargs sudo apt-get -y purge >/dev/null 2>&1 77 | 78 | show_status "Package manager cache" 79 | sudo rm -rf /var/cache/apt/archives/* >/dev/null 2>&1 80 | sudo rm -rf /var/cache/apt/archives/partial/* >/dev/null 2>&1 81 | 82 | show_status "Temporary files" 83 | sudo rm -rf /tmp/* >/dev/null 2>&1 84 | sudo rm -rf /var/tmp/* >/dev/null 2>&1 85 | 86 | show_status "Old log files" 87 | sudo find /var/log -type f -name "*.log" -mtime +7 -exec rm -f {} \; >/dev/null 2>&1 88 | sudo find /var/log -type f -name "*.log.*" -mtime +7 -exec rm -f {} \; >/dev/null 2>&1 89 | 90 | show_status "Systemd journal" 91 | sudo journalctl --rotate >/dev/null 2>&1 92 | sudo journalctl --vacuum-time=7d >/dev/null 2>&1 93 | sudo rm -f /var/log/journal/*/*.journal~ >/dev/null 2>&1 94 | 95 | if [ -d "/var/log/audit" ]; then 96 | show_status "Audit logs" 97 | sudo find /var/log/audit -type f -mtime +7 -exec rm -f {} \; >/dev/null 2>&1 98 | fi 99 | 100 | show_status "Crash reports" 101 | sudo rm -rf /var/crash/* >/dev/null 2>&1 102 | 103 | show_status "Failed systemd units" 104 | sudo systemctl reset-failed >/dev/null 2>&1 105 | 106 | if command -v docker >/dev/null; then 107 | show_status "Docker system" 108 | docker system prune -f >/dev/null 2>&1 109 | fi 110 | 111 | show_status "Old sessions" 112 | sudo rm -rf /var/lib/systemd/sessions/* >/dev/null 2>&1 113 | 114 | show_status "Obsolete alternatives" 115 | sudo update-alternatives --remove-all ls >/dev/null 2>&1 116 | 117 | show_status "Performance logs" 118 | sudo rm -rf /var/log/sa/* >/dev/null 2>&1 119 | 120 | show_status "Login records" 121 | sudo truncate -s 0 /var/log/wtmp >/dev/null 2>&1 122 | sudo truncate -s 0 /var/log/btmp >/dev/null 2>&1 123 | 124 | if [ -d "/var/log/mail" ]; then 125 | show_status "Mail logs" 126 | sudo find /var/log/mail -type f -mtime +7 -exec rm -f {} \; >/dev/null 2>&1 127 | fi 128 | } 129 | 130 | # Main function 131 | main() { 132 | # Show banner 133 | show_banner 134 | 135 | echo "Starting cleanup..." 136 | echo 137 | 138 | # Get initial sizes 139 | initial_size=$(df -BG / | tail -1 | awk '{print $4}' | sed 's/G//') 140 | 141 | # Run cleanup 142 | clean_system 143 | 144 | # Get final sizes 145 | final_size=$(df -BG / | tail -1 | awk '{print $4}' | sed 's/G//') 146 | 147 | # Calculate freed space 148 | freed_space=$(calculate_freed_space $initial_size $final_size) 149 | 150 | # Show completion message 151 | echo 152 | echo "✅ Cleanup completed successfully!" 153 | echo "💾 Freed approximately ${freed_space}MB of space" 154 | } 155 | 156 | # Execute main function 157 | main -------------------------------------------------------------------------------- /tools/qnode_update_quick_check.sh: -------------------------------------------------------------------------------- 1 | # Configuration 2 | UPDATE_WAIT_TIME=1200 # 20 minutes in seconds 3 | UPDATE_SCRIPT_URL="https://raw.githubusercontent.com/lamat1111/QuilibriumScripts/master/qnode_service_update.sh" 4 | RELEASE_URL="https://releases.quilibrium.com/release" 5 | NODE_DIR="/root/ceremonyclient/node" 6 | 7 | # Function to normalize version for comparison 8 | normalize_version() { 9 | echo $1 | awk -F. '{printf "%03d%03d%03d%03d", $1+0, $2+0, $3+0, $4+0}' 10 | } 11 | 12 | # Extract remote version 13 | REMOTE_VERSION=$(curl -s "$RELEASE_URL" | grep -m1 "node-[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+-" | cut -d'-' -f2) 14 | 15 | # Get local version - excluding .dgst files and handling multiple versions 16 | LOCAL_VERSION=$(ls $NODE_DIR | grep "node-[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+-" | grep -v "\.dgst" | cut -d'-' -f2 | sort -rV | head -n1) 17 | 18 | echo "Remote version: $REMOTE_VERSION" 19 | echo "Local version: $LOCAL_VERSION" 20 | 21 | if [ $(normalize_version $REMOTE_VERSION) -gt $(normalize_version $LOCAL_VERSION) ]; then 22 | # Check if update is already in progress 23 | if [ -f /tmp/node_update_in_progress ]; then 24 | echo "Update already in progress, skipping" 25 | exit 0 26 | fi 27 | 28 | echo "New version available. Waiting $UPDATE_WAIT_TIME seconds before updating..." 29 | 30 | # Create lock file 31 | touch /tmp/node_update_in_progress 32 | 33 | # Show countdown 34 | for i in $(seq $UPDATE_WAIT_TIME -1 1); do 35 | printf "\rUpdate will start in: %02d:%02d" $(($i/60)) $(($i%60)) 36 | sleep 1 37 | done 38 | echo -e "\nStarting update..." 39 | 40 | # Execute update script 41 | mkdir -p ~/scripts && \ 42 | curl -sSL "$UPDATE_SCRIPT_URL" -o ~/scripts/qnode_service_update.sh && \ 43 | chmod +x ~/scripts/qnode_service_update.sh && \ 44 | ~/scripts/qnode_service_update.sh 45 | 46 | # Remove lock file after update 47 | rm /tmp/node_update_in_progress 48 | exit 0 49 | else 50 | echo "Current version is up to date" 51 | exit 0 52 | fi -------------------------------------------------------------------------------- /tools/qnode_visibility_check.sh: -------------------------------------------------------------------------------- 1 | 2 | cat << "EOF" 3 | 4 | QQQQQQQQQ 1111111 5 | QQ:::::::::QQ 1::::::1 6 | QQ:::::::::::::QQ 1:::::::1 7 | Q:::::::QQQ:::::::Q111:::::1 8 | Q::::::O Q::::::Q 1::::1 9 | Q:::::O Q:::::Q 1::::1 10 | Q:::::O Q:::::Q 1::::1 11 | Q:::::O Q:::::Q 1::::l 12 | Q:::::O Q:::::Q 1::::l 13 | Q:::::O Q:::::Q 1::::l 14 | Q:::::O QQQQ:::::Q 1::::l 15 | Q::::::O Q::::::::Q 1::::l 16 | Q:::::::QQ::::::::Q111::::::111 17 | QQ::::::::::::::Q 1::::::::::1 18 | QQ:::::::::::Q 1::::::::::1 19 | QQQQQQQQ::::QQ111111111111 20 | Q:::::Q 21 | QQQQQQ QUILIBRIUM.ONE 22 | 23 | 24 | ============================================================================ 25 | ✨ NODE VISIBILITY CHECK ✨ 26 | ============================================================================ 27 | This script will check if you node is visible to Bootstrap Peers. 28 | 29 | Follow the Quilibrium Node guide at https://docs.quilibrium.one 30 | 31 | Made with 🔥 by LaMat - https://quilibrium.one 32 | ============================================================================ 33 | 34 | Processing... ⏳ 35 | 36 | EOF 37 | 38 | sleep 5 # Add a 7-second delay 39 | 40 | # Export some variables ot solve the gRPCurl not found error 41 | export GOROOT=/usr/local/go 42 | export GOPATH=$HOME/go 43 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 44 | 45 | # Install gRPCurl if not installed 46 | if which grpcurl >/dev/null; then 47 | echo "✅ gRPCurl is installed." 48 | else 49 | echo "❌ gRPCurl is not installed." 50 | echo "📦 Installing gRPCurl..." 51 | sleep 1 # Add a 1-second delay 52 | # Try installing gRPCurl using go install 53 | if go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest; then 54 | echo "✅ gRPCurl installed successfully via go install." 55 | echo "" 56 | else 57 | echo "⚠️ Failed to install gRPCurl via go install. Trying apt-get..." 58 | # Try installing gRPCurl using apt-get 59 | if sudo apt-get install grpcurl -y; then 60 | echo "✅ gRPCurl installed successfully via apt-get." 61 | echo "" 62 | else 63 | echo "❌ Failed to install gRPCurl via apt-get! Please install it manually." 64 | exit 1 65 | fi 66 | fi 67 | fi 68 | 69 | 70 | # List of bootstrap peers 71 | bootstrap_peers=( 72 | "EiDpYbDwT2rZq70JNJposqAC+vVZ1t97pcHbK8kr5G4ZNA==" 73 | "EiCcVN/KauCidn0nNDbOAGMHRZ5psz/lthpbBeiTAUEfZQ==" 74 | "EiDhVHjQKgHfPDXJKWykeUflcXtOv6O2lvjbmUnRrbT2mw==" 75 | "EiDHhTNA0yf07ljH+gTn0YEk/edCF70gQqr7QsUr8RKbAA==" 76 | "EiAnwhEcyjsHiU6cDCjYJyk/1OVsh6ap7E3vDfJvefGigw==" 77 | "EiB75ZnHtAOxajH2hlk9wD1i9zVigrDKKqYcSMXBkKo4SA==" 78 | "EiDEYNo7GEfMhPBbUo+zFSGeDECB0RhG0GfAasdWp2TTTQ==" 79 | "EiCzMVQnCirB85ITj1x9JOEe4zjNnnFIlxuXj9m6kGq1SQ==" 80 | ) 81 | 82 | # Run command and capture output 83 | output=$(grpcurl -plaintext localhost:8337 quilibrium.node.node.pb.NodeService.GetNetworkInfo) 84 | 85 | # Check for bootstrap peers in the output 86 | visible=false 87 | for peer in "${bootstrap_peers[@]}"; do 88 | if [[ $output == *"$peer"* ]]; then 89 | visible=true 90 | echo "You see $peer as a bootstrap peer" 91 | else 92 | echo "Peer $peer not found" 93 | fi 94 | done 95 | 96 | if $visible ; then 97 | echo "" 98 | echo "" 99 | echo "✅ Your node is visible to bootstrap peers!" 100 | echo "" 101 | else 102 | echo "" 103 | echo "" 104 | echo "❌ Your node is not visible." 105 | echo "Check that your .config.yml has the right settings" 106 | echo "" 107 | echo "For more info and troubleshooting go here:" 108 | echo "https://docs.quilibrium.one/quilibrium-node-setup-guide/troubleshooting#node-not-visible-to-bootstrap-peers" 109 | echo "" 110 | echo "If all your settings are correct, restart your node, wait 15 minutes and try again." 111 | echo "" 112 | fi 113 | -------------------------------------------------------------------------------- /tools/qnode_visibility_check_autorestart.sh: -------------------------------------------------------------------------------- 1 | Certainly! Below is your script with the added functionality to restart the node using `service ceremonyclient restart` if it is not visible to the bootstrap peers. 2 | 3 | ```bash 4 | cat << "EOF" 5 | 6 | Q1Q1Q1\ Q1\ 7 | Q1 __Q1\ Q1Q1 | 8 | Q1 | Q1 |\_Q1 | 9 | Q1 | Q1 | Q1 | 10 | Q1 | Q1 | Q1 | 11 | Q1 Q1Q1 | Q1 | 12 | \Q1Q1Q1 / Q1Q1Q1\ 13 | \___Q1Q\ \______| QUILIBRIUM.ONE 14 | \___| 15 | 16 | ============================================================================ 17 | ✨ NODE VISIBILITY CHECK + AUTORESTART ✨ 18 | ============================================================================ 19 | This script will check if you node is visible to Bootstrap Peers. 20 | It will autorestart your node if it is not visible. 21 | 22 | Follow the Quilibrium Node guide at https://docs.quilibrium.one 23 | 24 | Made with 🔥 by LaMat - https://quilibrium.one 25 | ============================================================================ 26 | 27 | Processing... ⏳ 28 | 29 | EOF 30 | 31 | # Export some variables to solve the gRPCurl not found error 32 | export GOROOT=/usr/local/go 33 | export GOPATH=$HOME/go 34 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 35 | 36 | # List of bootstrap peers 37 | bootstrap_peers=( 38 | "EiDpYbDwT2rZq70JNJposqAC+vVZ1t97pcHbK8kr5G4ZNA==" 39 | "EiCcVN/KauCidn0nNDbOAGMHRZ5psz/lthpbBeiTAUEfZQ==" 40 | "EiDhVHjQKgHfPDXJKWykeUflcXtOv6O2lvjbmUnRrbT2mw==" 41 | "EiDHhTNA0yf07ljH+gTn0YEk/edCF70gQqr7QsUr8RKbAA==" 42 | "EiAnwhEcyjsHiU6cDCjYJyk/1OVsh6ap7E3vDfJvefGigw==" 43 | "EiB75ZnHtAOxajH2hlk9wD1i9zVigrDKKqYcSMXBkKo4SA==" 44 | "EiDEYNo7GEfMhPBbUo+zFSGeDECB0RhG0GfAasdWp2TTTQ==" 45 | "EiCzMVQnCirB85ITj1x9JOEe4zjNnnFIlxuXj9m6kGq1SQ==" 46 | ) 47 | 48 | # Run command and capture output 49 | output=$(grpcurl -plaintext localhost:8337 quilibrium.node.node.pb.NodeService.GetNetworkInfo) 50 | 51 | # Check for bootstrap peers in the output 52 | visible=false 53 | for peer in "${bootstrap_peers[@]}"; do 54 | if [[ $output == *"$peer"* ]]; then 55 | visible=true 56 | echo "You see $peer as a bootstrap peer" 57 | else 58 | echo "Peer $peer not found" 59 | fi 60 | done 61 | 62 | if $visible ; then 63 | echo "" 64 | echo "" 65 | echo "✅ Your node is visible to bootstrap peers!" 66 | echo "" 67 | else 68 | echo "" 69 | echo "" 70 | echo "❌ Your node is not visible. Restarting node..." 71 | sleep 3 72 | 73 | # Restart the node 74 | echo "🔄 Restarting the node..." 75 | if sudo service ceremonyclient restart; then 76 | echo "✅ Node restarted successfully." 77 | else 78 | echo "❌ Failed to restart the node. Please try restarting it manually." 79 | fi 80 | fi 81 | -------------------------------------------------------------------------------- /tools/qnode_visibility_check_installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << "EOF" 4 | 5 | Q1Q1Q1\ Q1\ 6 | Q1 __Q1\ Q1Q1 | 7 | Q1 | Q1 |\_Q1 | 8 | Q1 | Q1 | Q1 | 9 | Q1 | Q1 | Q1 | 10 | Q1 Q1Q1 | Q1 | 11 | \Q1Q1Q1 / Q1Q1Q1\ 12 | \___Q1Q\ \______| QUILIBRIUM.ONE 13 | \___| 14 | 15 | ============================================================================ 16 | ✨ QNODE VISIBILITY CHECK INSTALLER ✨ 17 | ============================================================================ 18 | This script will install the "Visibility Check" script and set up 19 | a cronjob to run it every hour at a random minute. 20 | 21 | The "Visibility Check" script will check the visibility of your node, 22 | and if it's not visible to Bootstrap Peers, it will restart it. 23 | 24 | Follow the Quilibrium Node guide at https://docs.quilibrium.one 25 | 26 | Made with 🔥 by LaMat - https://quilibrium.one 27 | ============================================================================ 28 | 29 | Processing... ⏳ 30 | 31 | EOF 32 | 33 | sleep 5 # Add a 7-second delay 34 | 35 | # Get the home directory of the current user 36 | HOME=$(eval echo ~$USER) 37 | 38 | # Step 1: Create $HOME/scripts directory if it doesn't exist 39 | if [ ! -d "$HOME/scripts" ]; then 40 | mkdir -p "$HOME/scripts" 41 | echo "✅ Created $HOME/scripts directory." 42 | fi 43 | 44 | # Step 2: Download the script from GitHub 45 | script_url="https://github.com/lamat1111/QuilibriumScripts/raw/main/tools/qnode_visibility_check_autorestart.sh" 46 | script_path="$HOME/scripts/qnode_visibility_check_autorestart.sh" 47 | 48 | curl -L $script_url -o $script_path 49 | if [ $? -eq 0 ]; then 50 | echo "✅ Downloaded qnode_visibility_check_autorestart.sh to $HOME/scripts." 51 | else 52 | echo "❌ Failed to download qnode_visibility_check_autorestart.sh." 53 | exit 1 54 | fi 55 | 56 | # Make the script executable 57 | chmod +x $script_path 58 | 59 | # Step 3: Set up a cron job to run the script every hour at a random minute 60 | cron_minute=$((RANDOM % 60)) 61 | cron_command="$cron_minute * * * * /bin/bash $script_path" 62 | 63 | # Add the cron job 64 | (crontab -l 2>/dev/null; echo "$cron_command") | crontab - 65 | 66 | echo "✅ Cron job added to run the script automatically" 67 | echo "" 68 | echo "The 'Visibility Check' script will now check the visibility of your node," 69 | echo "every hour at minute $cron_minute, and if it's not visible to Bootstrap Peers, it will restart it." 70 | --------------------------------------------------------------------------------