Update Quili.sh

This commit is contained in:
smeb y 2024-05-28 09:55:45 +08:00 committed by GitHub
parent 1caa557c4b
commit 98126451d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

146
Quili.sh
View File

@ -114,102 +114,74 @@ echo ====================================== 安装完成 =======================
} }
# 节点安装功能 # 节点安装功能
function install_node_service() { function install_node_mac() {
# 安装 Homebrew 包管理器(如果尚未安装)
# 检查是否以root用户执行脚本 if ! command -v brew &> /dev/null; then
if [ "$(id -u)" != "0" ]; then echo "Homebrew 未安装。正在安装 Homebrew..."
echo "该脚本必须以root权限运行" 1>&2 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
exit 1
fi fi
# 增加swap空间 # 更新 Homebrew 并安装必要的软件包
sudo mkdir /swap brew update
sudo fallocate -l 24G /swap/swapfile brew install wget git screen bison gcc make
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文件追加内容 # 安装 gvm
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配置已重新加载"
# 更新并升级Ubuntu软件包
sudo apt update && sudo apt -y upgrade
# 安装wget、screen和git等组件
sudo apt install git ufw bison screen binutils gcc make bsdmainutils -y
# 安装GVM
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /root/.gvm/scripts/gvm source $HOME/.gvm/scripts/gvm
# 获取系统架构
ARCH=$(uname -m)
# 安装并使用 go1.4 作为 bootstrap
gvm install go1.4 -B gvm install go1.4 -B
gvm use go1.4 gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.17.13
gvm use go1.17.13 # 根据系统架构安装相应的 Go 版本
export GOROOT_BOOTSTRAP=$GOROOT if [ "$ARCH" = "x86_64" ]; then
gvm install go1.20.2 gvm install go1.17.13
gvm use go1.20.2 gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
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
gvm install go1.20.2 -B
gvm use go1.20.2
else
echo "无法支持的版本: $ARCH"
exit 1
fi
# 克隆仓库 # 克隆仓库
git clone https://github.com/quilibriumnetwork/ceremonyclient git clone https://github.com/quilibriumnetwork/ceremonyclient
# 进入ceremonyclient/node目录
# 构建 Qclient
cd ceremonyclient/client
GOEXPERIMENT=arenas go build -o qclient main.go
sudo cp $HOME/ceremonyclient/client/qclient /usr/local/bin
# 进入 ceremonyclient/node 目录
cd #HOME
cd ceremonyclient/node cd ceremonyclient/node
git switch release
# 构建服务 # 赋予执行权限
GOEXPERIMENT=arenas go install ./... chmod +x release_autorun.sh
# 写入服务 # 创建一个 screen 会话并运行命令
sudo tee /lib/systemd/system/ceremonyclient.service > /dev/null <<EOF screen -dmS Quili bash -c './release_autorun.sh'
[Unit]
Description=Ceremony Client GO App Service
[Service]
Type=simple
Restart=always
RestartSec=5S
WorkingDirectory=/root/ceremonyclient/node
Environment=GOEXPERIMENT=arenas
ExecStart=/root/.gvm/pkgsets/go1.20.2/global/bin/node ./...
[Install]
WantedBy=multi-user.target
EOF
# 重新加载 systemd 并启用并启动服务
sudo systemctl daemon-reload
sudo systemctl enable ceremonyclient
sudo systemctl start ceremonyclient
# 完成安装提示
echo ====================================== 安装完成 ========================================= echo ====================================== 安装完成 =========================================
} }
# 查看服务版本状态
function check_ceremonyclient_service_status() {
systemctl status ceremonyclient
}
# 服务版本节点日志查询
function view_logs() {
sudo journalctl -f -u ceremonyclient.service
}
# 查看常规版本节点日志 # 查看常规版本节点日志
function check_service_status() { function check_service_status() {
screen -r Quili screen -r Quili
@ -259,28 +231,22 @@ function main_menu() {
echo "请选择要执行的操作:" echo "请选择要执行的操作:"
echo "1. 安装常规节点" echo "1. 安装常规节点"
echo "2. 查看常规版本节点日志" echo "2. 查看常规版本节点日志"
echo "3. 安装服务版本节点(性能调度没有常规节点积极,可能奖励会更少)" echo "3. Mac 常规节点安装"
echo "4. 查看服务版本节点日志"
echo "5. 查看服务版本服务状态"
echo "6. 设置快捷键的功能"
echo "=======================单独使用功能=============================" echo "=======================单独使用功能============================="
echo "7. 独立启动挖矿(安装好常规节点后搭配使用)" echo "4. 独立启动挖矿(安装好常规节点后搭配使用)"
echo "=========================备份功能================================" echo "=========================备份功能================================"
echo "8. 备份文件" echo "5. 备份文件"
echo "=========================收米查询================================" echo "=========================收米查询================================"
echo "9. 查询余额" echo "6. 查询余额"
read -p "请输入选项1-8: " OPTION read -p "请输入选项1-6: " OPTION
case $OPTION in case $OPTION in
1) install_node ;; 1) install_node ;;
2) check_service_status ;; 2) check_service_status ;;
3) install_node_service ;; 3) install_node_mac ;;
4) view_logs ;; 4) run_node ;;
5) check_ceremonyclient_service_status ;; 5) backup_set ;;
6) check_and_set_alias ;; 6) check_balance ;;
7) run_node ;;
8) backup_set ;;
9) check_balance ;;
*) echo "无效选项。" ;; *) echo "无效选项。" ;;
esac esac
} }