Quilibrium/Quili.sh

405 lines
11 KiB
Bash
Raw Normal View History

2024-03-01 11:26:44 +00:00
#!/bin/bash
2024-03-20 08:18:35 +00:00
# 检查是否以root用户运行脚本
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要以root用户权限运行。"
echo "请尝试使用 'sudo -i' 命令切换到root用户然后再次运行此脚本。"
exit 1
fi
2024-03-03 05:20:12 +00:00
# 脚本保存路径
2024-03-04 04:02:02 +00:00
SCRIPT_PATH="$HOME/Quili.sh"
2024-03-01 11:26:44 +00:00
2024-03-03 05:20:12 +00:00
# 自动设置快捷键的功能
function check_and_set_alias() {
local alias_name="quili"
2024-03-17 04:15:53 +00:00
local profile_file="$HOME/.profile"
2024-03-03 05:20:12 +00:00
# 检查快捷键是否已经设置
2024-03-17 04:15:53 +00:00
if ! grep -q "$alias_name" "$profile_file"; then
echo "设置快捷键 '$alias_name' 到 $profile_file"
echo "alias $alias_name='bash $SCRIPT_PATH'" >> "$profile_file"
2024-03-03 05:20:12 +00:00
# 添加提醒用户激活快捷键的信息
2024-03-17 04:15:53 +00:00
echo "快捷键 '$alias_name' 已设置。请运行 'source $profile_file' 来激活快捷键,或重新登录。"
2024-03-03 05:20:12 +00:00
else
# 如果快捷键已经设置,提供一个提示信息
2024-03-17 04:15:53 +00:00
echo "快捷键 '$alias_name' 已经设置在 $profile_file"
echo "如果快捷键不起作用,请尝试运行 'source $profile_file' 或重新登录。"
2024-03-03 05:20:12 +00:00
fi
}
# 节点安装功能
function install_node() {
# 增加swap空间
sudo mkdir /swap
sudo fallocate -l 24G /swap/swapfile
sudo chmod 600 /swap/swapfile
sudo mkswap /swap/swapfile
sudo swapon /swap/swapfile
echo '/swap/swapfile swap swap defaults 0 0' >> /etc/fstab
# 向/etc/sysctl.conf文件追加内容
2024-03-01 11:26:44 +00:00
echo -e "\n# 自定义最大接收和发送缓冲区大小" >> /etc/sysctl.conf
echo "net.core.rmem_max=600000000" >> /etc/sysctl.conf
echo "net.core.wmem_max=600000000" >> /etc/sysctl.conf
2024-03-03 05:20:12 +00:00
echo "配置已添加到/etc/sysctl.conf"
2024-03-01 11:26:44 +00:00
# 重新加载sysctl配置以应用更改
sysctl -p
2024-03-03 05:20:12 +00:00
echo "sysctl配置已重新加载"
2024-03-01 11:26:44 +00:00
2024-03-03 05:20:12 +00:00
# 更新并升级Ubuntu软件包
2024-03-01 11:26:44 +00:00
sudo apt update && sudo apt -y upgrade
2024-03-03 05:20:12 +00:00
# 安装wget、screen和git等组件
2024-06-04 08:43:22 +00:00
sudo apt install git ufw bison screen binutils gcc make bsdmainutils cpulimit gawk -y
2024-03-01 11:26:44 +00:00
2024-05-27 08:09:52 +00:00
# 下载并安装gvm
2024-03-01 11:26:44 +00:00
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /root/.gvm/scripts/gvm
2024-05-27 08:09:52 +00:00
# 获取系统架构
ARCH=$(uname -m)
# 安装并使用go1.4作为bootstrap
2024-03-01 11:26:44 +00:00
gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
2024-05-27 08:09:52 +00:00
# 根据系统架构安装相应的Go版本
if [ "$ARCH" = "x86_64" ]; then
gvm install go1.17.13
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.20.2
gvm use go1.20.2
elif [ "$ARCH" = "aarch64" ]; then
gvm install go1.17.13 -B
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.20.2 -B
gvm use go1.20.2
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
2024-03-01 11:26:44 +00:00
2024-06-02 14:33:33 +00:00
2024-10-04 12:39:48 +00:00
git clone -b release-cdn https://git.dadunode.com/smeb_y/ceremonyclient.git
2024-06-02 14:33:33 +00:00
2024-03-03 05:20:12 +00:00
# 进入ceremonyclient/node目录
2024-06-05 03:51:08 +00:00
cd ceremonyclient/node
2024-06-06 14:53:06 +00:00
2024-03-01 11:26:44 +00:00
2024-03-03 05:20:12 +00:00
# 创建一个screen会话并运行命令
2024-10-04 12:03:17 +00:00
screen -dmS Quili bash -c './node-1.4.21.1-linux-amd64'
2024-03-03 05:20:12 +00:00
2024-06-03 01:07:20 +00:00
echo ====================================== 安装完成 请退出脚本使用screen 命令或者使用查看日志功能查询状态=========================================
2024-05-27 07:28:07 +00:00
2024-03-03 05:20:12 +00:00
}
2024-03-03 15:13:58 +00:00
# 节点安装功能
2024-05-28 01:55:45 +00:00
function install_node_mac() {
# 安装 Homebrew 包管理器(如果尚未安装)
if ! command -v brew &> /dev/null; then
echo "Homebrew 未安装。正在安装 Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2024-03-03 15:13:58 +00:00
fi
2024-05-28 01:55:45 +00:00
# 更新 Homebrew 并安装必要的软件包
brew update
brew install wget git screen bison gcc make
2024-03-03 15:13:58 +00:00
2024-05-28 01:55:45 +00:00
# 安装 gvm
2024-03-03 15:13:58 +00:00
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
2024-05-28 01:55:45 +00:00
source $HOME/.gvm/scripts/gvm
2024-03-03 15:13:58 +00:00
2024-05-28 01:55:45 +00:00
# 获取系统架构
ARCH=$(uname -m)
# 安装并使用 go1.4 作为 bootstrap
2024-03-03 15:13:58 +00:00
gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
2024-05-28 01:55:45 +00:00
# 根据系统架构安装相应的 Go 版本
if [ "$ARCH" = "x86_64" ]; then
gvm install go1.17.13
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
2024-03-03 15:13:58 +00:00
2024-05-28 01:55:45 +00:00
gvm install go1.20.2
gvm use go1.20.2
elif [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
gvm install go1.17.13 -B
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
2024-03-03 15:13:58 +00:00
2024-05-28 01:55:45 +00:00
gvm install go1.20.2 -B
gvm use go1.20.2
else
echo "无法支持的版本: $ARCH"
exit 1
fi
2024-03-03 15:13:58 +00:00
2024-05-28 01:55:45 +00:00
# 克隆仓库
2024-10-04 12:39:48 +00:00
git clone -b release-cdn https://git.dadunode.com/smeb_y/ceremonyclient.git
2024-03-03 15:13:58 +00:00
2024-05-28 01:55:45 +00:00
# 进入 ceremonyclient/node 目录
2024-06-05 03:51:08 +00:00
cd ceremonyclient/node
2024-03-03 15:13:58 +00:00
2024-05-28 01:55:45 +00:00
# 创建一个 screen 会话并运行命令
2024-10-04 12:03:17 +00:00
screen -dmS Quili bash -c './node-1.4.21.1-linux-arm64'
2024-03-03 15:13:58 +00:00
2024-05-29 05:16:06 +00:00
2024-06-03 01:07:20 +00:00
echo ====================================== 安装完成 请退出脚本使用screen 命令或者使用查看日志功能查询状态 =========================================
2024-03-03 15:13:58 +00:00
}
# 查看常规版本节点日志
2024-03-03 05:20:12 +00:00
function check_service_status() {
screen -r Quili
}
2024-05-16 02:56:37 +00:00
# 独立启动
function run_node() {
2024-05-30 01:58:29 +00:00
screen -dmS Quili bash -c "source /root/.gvm/scripts/gvm && gvm use go1.20.2 && cd ~/ceremonyclient/node && ./release_autorun.sh"
2024-05-16 02:59:21 +00:00
2024-06-03 01:07:20 +00:00
echo "=======================已启动quilibrium 挖矿 请退出脚本使用screen 命令或者使用查看日志功能查询状态========================================="
2024-05-16 02:56:37 +00:00
}
2024-03-03 05:20:12 +00:00
2024-05-17 14:38:48 +00:00
function add_snapshots() {
2024-06-03 09:03:30 +00:00
apt install unzip -y
rm -r $HOME/ceremonyclient/node/.config/store && wget -qO- https://snapshots.cherryservers.com/quilibrium/store.zip > /tmp/store.zip && unzip -j -o /tmp/store.zip -d $HOME/ceremonyclient/node/.config/store && rm /tmp/store.zip
2024-05-17 14:38:48 +00:00
2024-05-25 09:03:27 +00:00
screen -dmS Quili bash -c 'source /root/.gvm/scripts/gvm && gvm use go1.20.2 && cd ~/ceremonyclient/node && ./release_autorun.sh'
2024-05-17 14:38:48 +00:00
}
2024-03-03 05:20:12 +00:00
2024-05-24 11:07:23 +00:00
function backup_set() {
mkdir -p ~/backup
cat ~/ceremonyclient/node/.config/config.yml > ~/backup/config.txt
cat ~/ceremonyclient/node/.config/keys.yml > ~/backup/keys.txt
2024-05-25 15:45:16 +00:00
echo "=======================备份完成请执行cd ~/backup 查看备份文件========================================="
2024-05-24 11:07:23 +00:00
}
2024-05-27 07:28:07 +00:00
function check_balance() {
2024-06-09 03:27:05 +00:00
cd ~/ceremonyclient/node
2024-07-30 09:21:21 +00:00
version="1.4.21.1"
2024-06-09 03:27:05 +00:00
binary="node-$version"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [[ $(uname -m) == "aarch64"* ]]; then
binary="$binary-linux-arm64"
else
binary="$binary-linux-amd64"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
binary="$binary-darwin-arm64"
else
echo "unsupported OS for releases, please build from source"
exit 1
fi
2024-06-02 13:56:36 +00:00
2024-06-09 03:27:05 +00:00
./$binary --node-info
2024-05-27 07:28:07 +00:00
}
2024-05-24 11:07:23 +00:00
2024-06-04 01:00:26 +00:00
function unlock_performance() {
2024-06-04 01:59:41 +00:00
cd ~/ceremonyclient/node
2024-06-06 14:53:06 +00:00
echo "请选择要切换的版本:"
echo "1. 限制CPU50%性能版本"
echo "2. CPU性能拉满版本"
read -p "请输入选项(1或2): " version_choice
if [ "$version_choice" -eq 1 ]; then
2024-06-08 13:58:11 +00:00
git switch release-cdn
2024-06-06 14:53:06 +00:00
elif [ "$version_choice" -eq 2 ]; then
git switch release-non-datacenter
else
echo "无效的选项,退出脚本。"
exit 1
fi
2024-06-02 14:04:06 +00:00
# 赋予执行权限
chmod +x release_autorun.sh
2024-06-06 14:53:06 +00:00
# 创建一个screen会话并运行命令
2024-06-02 14:04:06 +00:00
screen -dmS Quili bash -c './release_autorun.sh'
2024-06-06 14:53:06 +00:00
2024-06-03 01:07:20 +00:00
echo "=======================已解锁CPU性能限制并启动quilibrium 挖矿请退出脚本使用screen 命令或者使用查看日志功能查询状态========================================="
2024-06-02 14:04:06 +00:00
}
2024-06-08 17:36:28 +00:00
# 升级节点版本
2024-06-08 16:31:30 +00:00
function update_node() {
cd ~/ceremonyclient/node
2024-06-08 17:11:53 +00:00
git remote set-url origin https://source.quilibrium.com/quilibrium/ceremonyclient.git
2024-06-08 16:31:30 +00:00
git pull
git switch release-cdn
echo "节点已升级。请运行脚本独立启动挖矿功能启动节点。"
}
2024-06-08 17:36:28 +00:00
function update_node_contabo() {
sudo sh -c 'echo "nameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf'
cd ~/ceremonyclient/node
git remote set-url origin https://source.quilibrium.com/quilibrium/ceremonyclient.git
git pull
git switch release-cdn
echo "节点已升级。请运行脚本独立启动挖矿功能启动节点。"
}
# 更新本脚本
2024-06-02 14:05:39 +00:00
function update_script() {
SCRIPT_URL="https://raw.githubusercontent.com/a3165458/Quilibrium/main/Quili.sh"
curl -o $SCRIPT_PATH $SCRIPT_URL
chmod +x $SCRIPT_PATH
echo "脚本已更新。请退出脚本后执行bash Quili.sh 重新运行此脚本。"
}
2024-06-08 17:39:16 +00:00
function install_node_contabo() {
# 增加swap空间
sudo mkdir /swap
sudo fallocate -l 24G /swap/swapfile
sudo chmod 600 /swap/swapfile
sudo mkswap /swap/swapfile
sudo swapon /swap/swapfile
echo '/swap/swapfile swap swap defaults 0 0' >> /etc/fstab
# 向/etc/sysctl.conf文件追加内容
echo -e "\n# 自定义最大接收和发送缓冲区大小" >> /etc/sysctl.conf
echo "net.core.rmem_max=600000000" >> /etc/sysctl.conf
echo "net.core.wmem_max=600000000" >> /etc/sysctl.conf
echo "配置已添加到/etc/sysctl.conf"
# 重新加载sysctl配置以应用更改
sysctl -p
echo "sysctl配置已重新加载"
sudo sh -c 'echo "nameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf'
# 更新并升级Ubuntu软件包
sudo apt update && sudo apt -y upgrade
# 安装wget、screen和git等组件
sudo apt install git ufw bison screen binutils gcc make bsdmainutils cpulimit gawk -y
# 下载并安装gvm
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /root/.gvm/scripts/gvm
# 获取系统架构
ARCH=$(uname -m)
# 安装并使用go1.4作为bootstrap
gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
# 根据系统架构安装相应的Go版本
if [ "$ARCH" = "x86_64" ]; then
gvm install go1.17.13
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.20.2
gvm use go1.20.2
elif [ "$ARCH" = "aarch64" ]; then
gvm install go1.17.13 -B
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.20.2 -B
gvm use go1.20.2
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
git clone https://source.quilibrium.com/quilibrium/ceremonyclient.git
# 进入ceremonyclient/node目录
cd ceremonyclient/node
git switch release-cdn
# 赋予执行权限
chmod +x release_autorun.sh
# 创建一个screen会话并运行命令
screen -dmS Quili bash -c './release_autorun.sh'
2024-06-08 17:47:38 +00:00
}
2024-06-09 03:27:05 +00:00
function setup_grpc() {
wget --no-cache -O - https://raw.githubusercontent.com/lamat1111/quilibriumscripts/master/tools/qnode_gRPC_calls_setup.sh | bash
echo "gRPC 安装后等待约30分钟生效"
}
2024-03-03 05:20:12 +00:00
# 主菜单
function main_menu() {
clear
echo "脚本以及教程由推特用户大赌哥 @y95277777 编写,免费开源,请勿相信收费"
echo "================================================================"
echo "节点社区 Telegram 群组:https://t.me/niuwuriji"
echo "节点社区 Telegram 频道:https://t.me/niuwuriji"
echo "请选择要执行的操作:"
2024-03-03 15:13:58 +00:00
echo "1. 安装常规节点"
2024-06-03 01:07:20 +00:00
echo "2. 查看节点日志"
echo "3. Mac 节点安装"
2024-06-02 14:05:39 +00:00
echo "8. 更新本脚本"
2024-06-03 09:03:30 +00:00
echo "9. 加载快照"
2024-06-08 16:31:30 +00:00
echo "10. 升级节点程序版本"
2024-06-08 17:39:16 +00:00
echo "11. 安装常规节点(针对contabo)"
echo "12. 升级节点程序版本(针对contabo)"
2024-06-09 03:27:05 +00:00
echo "13. 安装grpc"
2024-05-24 11:07:23 +00:00
echo "=======================单独使用功能============================="
2024-05-28 01:55:45 +00:00
echo "4. 独立启动挖矿(安装好常规节点后搭配使用)"
2024-05-24 11:07:23 +00:00
echo "=========================备份功能================================"
2024-05-28 01:55:45 +00:00
echo "5. 备份文件"
2024-05-27 07:28:07 +00:00
echo "=========================收米查询================================"
2024-06-09 03:27:05 +00:00
echo "6. 查询余额(需要先安装grpc)"
2024-06-02 14:05:39 +00:00
2024-06-09 05:05:34 +00:00
read -p "请输入选项1-13: " OPTION
2024-03-03 05:20:12 +00:00
case $OPTION in
1) install_node ;;
2024-03-03 15:13:58 +00:00
2) check_service_status ;;
2024-05-28 01:55:45 +00:00
3) install_node_mac ;;
4) run_node ;;
5) backup_set ;;
6) check_balance ;;
2024-06-02 14:05:39 +00:00
8) update_script ;;
2024-06-03 09:03:30 +00:00
9) add_snapshots ;;
2024-06-08 16:31:30 +00:00
10) update_node ;;
2024-06-08 17:39:16 +00:00
11) install_node_contabo ;;
12) update_node_contabo ;;
2024-06-09 03:27:05 +00:00
13) setup_grpc ;;
2024-03-03 05:20:12 +00:00
*) echo "无效选项。" ;;
esac
}
# 显示主菜单
main_menu