2024-03-22 07:15:15 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# 检查是否以root用户运行脚本
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Check if the script is run as root
|
2024-03-22 07:15:15 +00:00
|
|
|
|
if [ "$(id -u)" != "0" ]; then
|
2024-03-31 06:41:05 +00:00
|
|
|
|
echo "此脚本需要以root用户权限运行。/This script needs to be run with root user privileges."
|
|
|
|
|
echo "请尝试使用 'sudo -i' 命令切换到root用户,然后再次运行此脚本。/Please try to switch to root user with 'sudo -i' command, then run this script again."
|
2024-03-22 07:15:15 +00:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# 节点安装功能
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Node installation function
|
2024-03-22 07:15:15 +00:00
|
|
|
|
function install_node() {
|
|
|
|
|
|
|
|
|
|
# 更新系统包列表
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Update system package list
|
2024-03-22 07:23:45 +00:00
|
|
|
|
apt update
|
2024-03-22 07:15:15 +00:00
|
|
|
|
|
|
|
|
|
# 检查 Git 等是否已安装
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Check if Git and others are already installed
|
2024-03-22 13:05:29 +00:00
|
|
|
|
apt install git python3-venv bison screen binutils gcc make bsdmainutils python3-pip -y
|
2024-03-22 07:15:15 +00:00
|
|
|
|
|
2024-03-22 12:59:26 +00:00
|
|
|
|
# 安装numpy
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Install numpy
|
2024-03-22 12:59:26 +00:00
|
|
|
|
pip install numpy==1.24.4
|
|
|
|
|
|
|
|
|
|
|
2024-03-22 07:15:15 +00:00
|
|
|
|
# 安装GO
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Install GO
|
2024-03-22 07:23:45 +00:00
|
|
|
|
rm -rf /usr/local/go
|
2024-03-26 03:50:07 +00:00
|
|
|
|
cd /usr/local
|
2024-03-30 15:45:03 +00:00
|
|
|
|
wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz
|
|
|
|
|
tar -C /usr/local -xzf go1.22.1.linux-amd64.tar.gz
|
2024-03-26 03:50:07 +00:00
|
|
|
|
export PATH=$PATH:/usr/local/go/bin
|
2024-03-22 07:15:15 +00:00
|
|
|
|
source .bash_profile
|
2024-03-26 03:50:07 +00:00
|
|
|
|
go version
|
2024-03-22 07:15:15 +00:00
|
|
|
|
|
|
|
|
|
# 克隆官方仓库
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Clone the official repository
|
2024-03-22 07:15:15 +00:00
|
|
|
|
mkdir $HOME/nimble && cd $HOME/nimble
|
|
|
|
|
git clone https://github.com/nimble-technology/wallet-public.git
|
|
|
|
|
cd wallet-public
|
|
|
|
|
make install
|
|
|
|
|
|
|
|
|
|
# 创建钱包
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Create a wallet
|
2024-03-22 07:15:15 +00:00
|
|
|
|
nimble-networkd keys add ilovenimble
|
|
|
|
|
|
2024-03-22 11:29:12 +00:00
|
|
|
|
echo "=============================备份好钱包和助记词,下方需要使用==================================="
|
2024-03-31 06:41:05 +00:00
|
|
|
|
echo "=============================Make sure to backup your wallet and mnemonic phrase, it will be needed below==================================="
|
2024-03-22 07:15:15 +00:00
|
|
|
|
|
2024-03-31 06:41:05 +00:00
|
|
|
|
read -p "是否已经备份好助记词? Have you backed up the mnemonic phrase? (y/n) " backup_confirmed
|
|
|
|
|
|
|
|
|
|
# 如果用户没有确认备份,则退出脚本
|
|
|
|
|
# If the user did not confirm the backup, then exit the script
|
|
|
|
|
if [ "$backup_confirmed" != "y" ]; then
|
|
|
|
|
echo "请先备份好助记词,然后再继续执行脚本。/Please backup the mnemonic phrase first, then continue running the script."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2024-03-22 07:15:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 启动挖矿
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Start mining
|
|
|
|
|
read -p "请输入钱包地址: Please enter your wallet address: " wallet_addr
|
2024-03-22 11:54:20 +00:00
|
|
|
|
export wallet_addr
|
2024-03-22 07:15:15 +00:00
|
|
|
|
cd $HOME/nimble
|
|
|
|
|
git clone https://github.com/nimble-technology/nimble-miner-public.git
|
|
|
|
|
cd nimble-miner-public
|
|
|
|
|
make install
|
2024-03-22 09:40:24 +00:00
|
|
|
|
cd $HOME
|
2024-03-30 13:40:14 +00:00
|
|
|
|
cd $HOME/nimble/nimble-miner-public
|
|
|
|
|
source ./nimenv_localminers/bin/activate
|
|
|
|
|
screen -dmS nim bash -c 'make run addr=$wallet_addr'
|
2024-03-22 07:15:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 主菜单
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Main menu
|
2024-03-22 07:15:15 +00:00
|
|
|
|
function main_menu() {
|
|
|
|
|
clear
|
2024-03-31 06:41:05 +00:00
|
|
|
|
echo "请选择要执行的操作: /Please select an operation to execute:"
|
|
|
|
|
echo "1. 安装常规节点 /Install a regular node"
|
|
|
|
|
read -p "请输入选项(1): Please enter your choice (1): " OPTION
|
2024-03-22 07:15:15 +00:00
|
|
|
|
|
|
|
|
|
case $OPTION in
|
|
|
|
|
1) install_node ;;
|
2024-03-31 06:41:05 +00:00
|
|
|
|
*) echo "无效选项。/Invalid option." ;;
|
2024-03-22 07:15:15 +00:00
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 显示主菜单
|
2024-03-31 06:41:05 +00:00
|
|
|
|
# Show the main menu
|
2024-03-22 07:15:15 +00:00
|
|
|
|
main_menu
|