上传文件至 /
This commit is contained in:
parent
60c646cbd4
commit
ebceb9b713
257
quil.sh
Normal file
257
quil.sh
Normal file
@ -0,0 +1,257 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 检查是否以root用户运行脚本
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "此脚本需要以root用户权限运行。"
|
||||
echo "请尝试使用 'sudo -i' 命令切换到root用户,然后再次运行此脚本。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 脚本保存路径
|
||||
SCRIPT_PATH="$HOME/Quili.sh"
|
||||
|
||||
# 自动设置快捷键的功能
|
||||
function check_and_set_alias() {
|
||||
local alias_name="quili"
|
||||
local profile_file="$HOME/.profile"
|
||||
|
||||
# 检查快捷键是否已经设置
|
||||
if ! grep -q "$alias_name" "$profile_file"; then
|
||||
echo "设置快捷键 '$alias_name' 到 $profile_file"
|
||||
echo "alias $alias_name='bash $SCRIPT_PATH'" >> "$profile_file"
|
||||
# 添加提醒用户激活快捷键的信息
|
||||
echo "快捷键 '$alias_name' 已设置。请运行 'source $profile_file' 来激活快捷键,或重新登录。"
|
||||
else
|
||||
# 如果快捷键已经设置,提供一个提示信息
|
||||
echo "快捷键 '$alias_name' 已经设置在 $profile_file。"
|
||||
echo "如果快捷键不起作用,请尝试运行 'source $profile_file' 或重新登录。"
|
||||
fi
|
||||
}
|
||||
|
||||
# 节点安装功能
|
||||
function install_node() {
|
||||
# 检查是否在 macOS 上运行
|
||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
echo "此功能仅适用于 macOS。请使用适合您操作系统的安装方法。"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 如果尚未安装,则安装 Xcode 命令行工具
|
||||
if ! xcode-select -p &> /dev/null; then
|
||||
echo "正在安装 Xcode 命令行工具..."
|
||||
xcode-select --install
|
||||
# 等待安装完成
|
||||
while ! xcode-select -p &> /dev/null; do
|
||||
sleep 5
|
||||
done
|
||||
fi
|
||||
|
||||
# 如果尚未安装,则安装 Homebrew
|
||||
if ! command -v brew &> /dev/null; then
|
||||
echo "正在安装 Homebrew..."
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
# 为当前会话将 Homebrew 添加到 PATH
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
# 更新 Homebrew 并安装必要的包
|
||||
echo "正在更新 Homebrew 并安装必要的包..."
|
||||
brew update
|
||||
brew install wget git screen bison gcc make
|
||||
|
||||
# 安装 gvm (Go 版本管理器)
|
||||
echo "正在安装 gvm..."
|
||||
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
|
||||
source $HOME/.gvm/scripts/gvm
|
||||
|
||||
# 获取系统架构
|
||||
ARCH=$(uname -m)
|
||||
|
||||
# 安装并使用 Go 版本
|
||||
echo "正在安装 Go 版本..."
|
||||
gvm install go1.4 -B
|
||||
gvm use go1.4
|
||||
export GOROOT_BOOTSTRAP=$GOROOT
|
||||
|
||||
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" = "arm64" ]; 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"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 克隆仓库
|
||||
echo "正在克隆 Quilibrium 仓库..."
|
||||
git clone https://source.quilibrium.com/quilibrium/ceremonyclient.git
|
||||
|
||||
# 进入 node 目录并切换到正确的分支
|
||||
cd ceremonyclient/node
|
||||
git switch release-cdn
|
||||
|
||||
# 设置执行权限
|
||||
chmod +x release_autorun.sh
|
||||
|
||||
# 创建一个 screen 会话并运行命令
|
||||
echo "正在 screen 会话中启动节点..."
|
||||
screen -dmS Quili bash -c './release_autorun.sh'
|
||||
|
||||
echo "======================================"
|
||||
echo "安装完成。要查看节点状态:"
|
||||
echo "1. 退出此脚本"
|
||||
echo "2. 运行 'screen -r Quili' 来连接到 screen 会话"
|
||||
echo "3. 使用 Ctrl-A + Ctrl-D 来从 screen 会话中分离"
|
||||
echo "======================================"
|
||||
}
|
||||
|
||||
# 查看常规版本节点日志
|
||||
function check_service_status() {
|
||||
screen -r Quili
|
||||
}
|
||||
|
||||
# 独立启动
|
||||
function run_node() {
|
||||
screen -dmS Quili bash -c "source $HOME/.gvm/scripts/gvm && gvm use go1.20.2 && cd ~/ceremonyclient/node && ./release_autorun.sh"
|
||||
|
||||
echo "=======================已启动quilibrium 挖矿 请退出脚本使用screen 命令或者使用查看日志功能查询状态========================================="
|
||||
}
|
||||
|
||||
function add_snapshots() {
|
||||
brew install unzip
|
||||
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
|
||||
|
||||
screen -dmS Quili bash -c 'source $HOME/.gvm/scripts/gvm && gvm use go1.20.2 && cd ~/ceremonyclient/node && ./release_autorun.sh'
|
||||
}
|
||||
|
||||
function backup_set() {
|
||||
mkdir -p ~/backup
|
||||
cat ~/ceremonyclient/node/.config/config.yml > ~/backup/config.txt
|
||||
cat ~/ceremonyclient/node/.config/keys.yml > ~/backup/keys.txt
|
||||
|
||||
echo "=======================备份完成,请执行cd ~/backup 查看备份文件========================================="
|
||||
}
|
||||
|
||||
function check_balance() {
|
||||
cd ~/ceremonyclient/node
|
||||
version="1.4.21"
|
||||
binary="node-$version"
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
if [[ $(uname -m) == "arm64"* ]]; then
|
||||
binary="$binary-darwin-arm64"
|
||||
else
|
||||
binary="$binary-darwin-amd64"
|
||||
fi
|
||||
else
|
||||
echo "unsupported OS for releases, please build from source"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./$binary --node-info
|
||||
}
|
||||
|
||||
function unlock_performance() {
|
||||
cd ~/ceremonyclient/node
|
||||
|
||||
echo "请选择要切换的版本:"
|
||||
echo "1. 限制CPU50%性能版本"
|
||||
echo "2. CPU性能拉满版本"
|
||||
read -p "请输入选项(1或2): " version_choice
|
||||
|
||||
if [ "$version_choice" -eq 1 ]; then
|
||||
git switch release-cdn
|
||||
elif [ "$version_choice" -eq 2 ]; then
|
||||
git switch release-non-datacenter
|
||||
else
|
||||
echo "无效的选项,退出脚本。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 赋予执行权限
|
||||
chmod +x release_autorun.sh
|
||||
|
||||
# 创建一个screen会话并运行命令
|
||||
screen -dmS Quili bash -c './release_autorun.sh'
|
||||
|
||||
echo "=======================已解锁CPU性能限制并启动quilibrium 挖矿请退出脚本使用screen 命令或者使用查看日志功能查询状态========================================="
|
||||
}
|
||||
|
||||
# 升级节点版本
|
||||
function update_node() {
|
||||
cd ~/ceremonyclient/node
|
||||
git remote set-url origin https://source.quilibrium.com/quilibrium/ceremonyclient.git
|
||||
git pull
|
||||
git switch release-cdn
|
||||
echo "节点已升级。请运行脚本独立启动挖矿功能启动节点。"
|
||||
}
|
||||
|
||||
# 更新本脚本
|
||||
function update_script() {
|
||||
SCRIPT_PATH="./Quili.sh" # 定义脚本路径
|
||||
SCRIPT_URL="https://raw.githubusercontent.com/a3165458/Quilibrium/main/Quili.sh"
|
||||
|
||||
# 备份原始脚本
|
||||
cp $SCRIPT_PATH "${SCRIPT_PATH}.bak"
|
||||
|
||||
# 下载新脚本并检查是否成功
|
||||
if curl -o $SCRIPT_PATH $SCRIPT_URL; then
|
||||
chmod +x $SCRIPT_PATH
|
||||
echo "脚本已更新。请退出脚本后,执行bash Quli.sh 重新运行此脚本。"
|
||||
else
|
||||
echo "更新失败。正在恢复原始脚本。"
|
||||
mv "${SCRIPT_PATH}.bak" $SCRIPT_PATH
|
||||
fi
|
||||
}
|
||||
|
||||
# 安装gRPC
|
||||
function setup_grpc() {
|
||||
curl --no-cache -O - https://git.dadunode.com/aiai19811026/quill/src/branch/main/qnode_gRPC_calls_setup.sh | bash
|
||||
|
||||
echo "=======================gRPC安装完成========================================="
|
||||
}
|
||||
|
||||
# 自动设置快捷键
|
||||
check_and_set_alias
|
||||
|
||||
echo "=======================欢迎使用Quilibrium项目一键启动脚本======================="
|
||||
echo "1. 安装节点(支持断点续安装)"
|
||||
echo "2. 查看节点状态"
|
||||
echo "3. 独立启动挖矿"
|
||||
echo "4. 安装最新快照"
|
||||
echo "5. 备份配置文件"
|
||||
echo "6. 查看账户信息"
|
||||
echo "7. 解锁CPU性能限制"
|
||||
echo "8. 升级节点版本"
|
||||
echo "9. 升级脚本版本"
|
||||
echo "10. 安装gRPC"
|
||||
echo "11. 退出脚本"
|
||||
echo "======================================================================"
|
||||
|
||||
while true; do
|
||||
read -p "请输入选项(1-11): " choice
|
||||
|
||||
case $choice in
|
||||
1) install_node ;;
|
||||
2) check_service_status ;;
|
||||
3) run_node ;;
|
||||
4) add_snapshots ;;
|
||||
5) backup_set ;;
|
||||
6) check_balance ;;
|
||||
7) unlock_performance ;;
|
||||
8) update_node ;;
|
||||
9) update_script ;;
|
||||
10) setup_grpc ;;
|
||||
11) exit 0 ;;
|
||||
*) echo "无效的选项,请重新输入。" ;;
|
||||
esac
|
||||
done
|
Loading…
Reference in New Issue
Block a user