Update Artela.sh
This commit is contained in:
parent
e0c2c3d63c
commit
115783a18f
162
Artela.sh
162
Artela.sh
@ -7,8 +7,33 @@ if [ "$(id -u)" != "0" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 脚本保存路径
|
# 检查并安装 Node.js 和 npm
|
||||||
SCRIPT_PATH="$HOME/Artela.sh"
|
function install_nodejs_and_npm() {
|
||||||
|
if command -v node > /dev/null 2>&1; then
|
||||||
|
echo "Node.js 已安装"
|
||||||
|
else
|
||||||
|
echo "Node.js 未安装,正在安装..."
|
||||||
|
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
|
||||||
|
sudo apt-get install -y nodejs
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v npm > /dev/null 2>&1; then
|
||||||
|
echo "npm 已安装"
|
||||||
|
else
|
||||||
|
echo "npm 未安装,正在安装..."
|
||||||
|
sudo apt-get install -y npm
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 检查并安装 PM2
|
||||||
|
function install_pm2() {
|
||||||
|
if command -v pm2 > /dev/null 2>&1; then
|
||||||
|
echo "PM2 已安装"
|
||||||
|
else
|
||||||
|
echo "PM2 未安装,正在安装..."
|
||||||
|
npm install pm2@latest -g
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# 自动设置快捷键的功能
|
# 自动设置快捷键的功能
|
||||||
function check_and_set_alias() {
|
function check_and_set_alias() {
|
||||||
@ -37,16 +62,11 @@ function check_and_set_alias() {
|
|||||||
|
|
||||||
# 节点安装功能
|
# 节点安装功能
|
||||||
function install_node() {
|
function install_node() {
|
||||||
|
install_nodejs_and_npm
|
||||||
# 检查命令是否存在
|
install_pm2
|
||||||
exists() {
|
|
||||||
command -v "$1" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# 检查curl是否安装,如果没有则安装
|
# 检查curl是否安装,如果没有则安装
|
||||||
if exists curl; then
|
if ! command -v curl > /dev/null; then
|
||||||
echo 'curl 已安装'
|
|
||||||
else
|
|
||||||
sudo apt update && sudo apt install curl -y
|
sudo apt update && sudo apt install curl -y
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -56,18 +76,16 @@ export NODE_MONIKER=$NODE_MONIKER
|
|||||||
|
|
||||||
# 更新和安装必要的软件
|
# 更新和安装必要的软件
|
||||||
sudo apt update && sudo apt upgrade -y
|
sudo apt update && sudo apt upgrade -y
|
||||||
sudo apt install -y curl iptables build-essential git wget jq make gcc nano tmux htop nvme-cli pkg-config libssl-dev libleveldb-dev tar clang bsdmainutils ncdu unzip libleveldb-dev lz4
|
sudo apt install -y curl iptables build-essential git wget jq make gcc nano tmux htop nvme-cli pkg-config libssl-dev libleveldb-dev tar clang bsdmainutils ncdu unzip libleveldb-dev lz4 snapd
|
||||||
|
|
||||||
# 安装Go
|
# 安装Go
|
||||||
sudo rm -rf /usr/local/go
|
sudo rm -rf /usr/local/go
|
||||||
curl -L https://go.dev/dl/go1.22.0.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
|
curl -L https://go.dev/dl/go1.22.0.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
|
||||||
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bash_profile
|
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bash_profile
|
||||||
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
|
source $HOME/.bash_profile
|
||||||
|
|
||||||
|
|
||||||
# 安装所有二进制文件
|
# 安装所有二进制文件
|
||||||
cd $HOME
|
cd $HOME
|
||||||
rm -rf artela
|
|
||||||
git clone https://github.com/artela-network/artela
|
git clone https://github.com/artela-network/artela
|
||||||
cd artela
|
cd artela
|
||||||
git checkout v0.4.7-rc6
|
git checkout v0.4.7-rc6
|
||||||
@ -86,107 +104,31 @@ SEEDS=""
|
|||||||
PEERS="b23bc610c374fd071c20ce4a2349bf91b8fbd7db@65.108.72.233:11656"
|
PEERS="b23bc610c374fd071c20ce4a2349bf91b8fbd7db@65.108.72.233:11656"
|
||||||
sed -i 's|^seeds *=.*|seeds = "'$SEEDS'"|; s|^persistent_peers *=.*|persistent_peers = "'$PEERS'"|' $HOME/.artelad/config/config.toml
|
sed -i 's|^seeds *=.*|seeds = "'$SEEDS'"|; s|^persistent_peers *=.*|persistent_peers = "'$PEERS'"|' $HOME/.artelad/config/config.toml
|
||||||
|
|
||||||
# 配置和快照
|
# 使用 PM2 启动节点进程
|
||||||
sed -i 's|^pruning *=.*|pruning = "custom"|g' $HOME/.artelad/config/app.toml
|
pm2 start artelad --name artela-node -- start
|
||||||
sed -i 's|^pruning-keep-recent *=.*|pruning-keep-recent = "100"|g' $HOME/.artelad/config/app.toml
|
pm2 save
|
||||||
sed -i 's|^pruning-interval *=.*|pruning-interval = "10"|g' $HOME/.artelad/config/app.toml
|
pm2 startup systemd
|
||||||
sed -i 's|^snapshot-interval *=.*|snapshot-interval = 0|g' $HOME/.artelad/config/app.toml
|
|
||||||
|
|
||||||
# 配置最小燃料价格和普罗米修斯
|
|
||||||
sed -i 's|^minimum-gas-prices *=.*|minimum-gas-prices = "0.025art"|g' $HOME/.artelad/config/app.toml
|
|
||||||
sed -i 's|^prometheus *=.*|prometheus = true|' $HOME/.artelad/config/config.toml
|
|
||||||
|
|
||||||
# 创建服务文件
|
|
||||||
sudo tee /etc/systemd/system/artelad.service > /dev/null << EOF
|
|
||||||
[Unit]
|
|
||||||
Description=artela node
|
|
||||||
After=network-online.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User=$USER
|
|
||||||
ExecStart=$(which artelad) start
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=10
|
|
||||||
LimitNOFILE=10000
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
||||||
# 重置Tendermint数据
|
|
||||||
artelad tendermint unsafe-reset-all --home $HOME/.artelad --keep-addr-book
|
|
||||||
|
|
||||||
# 安装lz4工具
|
|
||||||
sudo apt install snapd -y
|
|
||||||
sudo snap install lz4
|
|
||||||
|
|
||||||
# 下载并解压快照
|
|
||||||
SNAP_NAME=$(curl -s https://ss-t.artela.nodestake.org/ | egrep -o ">20.*\.tar.lz4" | tr -d ">")
|
|
||||||
curl -o - -L https://ss-t.artela.nodestake.org/${SNAP_NAME} | lz4 -c -d - | tar -x -C $HOME/.artelad
|
|
||||||
|
|
||||||
# 重新加载和启动服务
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable artelad
|
|
||||||
sudo systemctl restart artelad && sudo journalctl -u artelad -f
|
|
||||||
|
|
||||||
|
|
||||||
# 完成设置
|
|
||||||
echo '====================== 安装完成 ==========================='
|
echo '====================== 安装完成 ==========================='
|
||||||
echo '安装完成请重新连接VPS,以启用对应快捷键功能'
|
echo '安装完成请重新连接VPS,以启用对应快捷键功能'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 创建钱包
|
# 查看Avail服务状态
|
||||||
function add_wallet() {
|
|
||||||
artelad keys add wallet
|
|
||||||
}
|
|
||||||
|
|
||||||
# 导入钱包
|
|
||||||
function import_wallet() {
|
|
||||||
artelad keys add wallet --recover
|
|
||||||
}
|
|
||||||
|
|
||||||
# 查询余额
|
|
||||||
function check_balances() {
|
|
||||||
read -p "请输入钱包地址: " wallet_address
|
|
||||||
artelad query bank balances "$wallet_address"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 查看节点同步状态
|
|
||||||
function check_sync_status() {
|
|
||||||
artelad status 2>&1 | jq .SyncInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
# 查看babylon服务状态
|
|
||||||
function check_service_status() {
|
function check_service_status() {
|
||||||
systemctl status artelad
|
pm2 list
|
||||||
}
|
}
|
||||||
|
|
||||||
# 节点日志查询
|
# Avail 节点日志查询
|
||||||
function view_logs() {
|
function view_logs() {
|
||||||
sudo journalctl -f -u artelad.service
|
pm2 logs artela-node
|
||||||
}
|
}
|
||||||
|
|
||||||
# 卸载节点功能
|
# 卸载节点功能
|
||||||
function uninstall_node() {
|
function uninstall_node() {
|
||||||
echo "你确定要卸载Artela 节点程序吗?这将会删除所有相关的数据。[Y/N]"
|
pm2 delete artela-node
|
||||||
read -r -p "请确认: " response
|
|
||||||
|
|
||||||
case "$response" in
|
|
||||||
[yY][eE][sS]|[yY])
|
|
||||||
echo "开始卸载节点程序..."
|
|
||||||
sudo systemctl stop artelad && sudo systemctl disable artelad && sudo rm /etc/systemd/system/artelad.service && sudo systemctl daemon-reload && rm -rf $HOME/.artelad && rm -rf artela && sudo rm -rf $(which artelad)
|
|
||||||
|
|
||||||
echo "节点程序卸载完成。"
|
echo "节点程序卸载完成。"
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "取消卸载操作。"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# 主菜单
|
# 主菜单
|
||||||
function main_menu() {
|
function main_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
@ -198,25 +140,17 @@ function main_menu() {
|
|||||||
echo "退出脚本,请按键盘ctrl c退出即可"
|
echo "退出脚本,请按键盘ctrl c退出即可"
|
||||||
echo "请选择要执行的操作:"
|
echo "请选择要执行的操作:"
|
||||||
echo "1. 安装节点"
|
echo "1. 安装节点"
|
||||||
echo "2. 创建钱包"
|
echo "2. 查看服务状态"
|
||||||
echo "3. 导入钱包"
|
echo "3. 运行日志查询"
|
||||||
echo "4. 查看钱包地址余额"
|
echo "4. 卸载节点"
|
||||||
echo "5. 查看节点同步状态"
|
|
||||||
echo "6. 查看当前服务状态"
|
|
||||||
echo "7. 运行日志查询"
|
|
||||||
echo "8. 卸载节点"
|
|
||||||
echo "9. 设置快捷键"
|
echo "9. 设置快捷键"
|
||||||
read -p "请输入选项(0-9): " OPTION
|
read -p "请输入选项(1-4, 9): " OPTION
|
||||||
|
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
1) install_node ;;
|
1) install_node ;;
|
||||||
2) add_wallet ;;
|
2) check_service_status ;;
|
||||||
3) import_wallet ;;
|
3) view_logs ;;
|
||||||
4) check_balances ;;
|
4) uninstall_node ;;
|
||||||
5) check_sync_status ;;
|
|
||||||
6) check_service_status ;;
|
|
||||||
7) view_logs ;;
|
|
||||||
8) uninstall_node ;;
|
|
||||||
9) check_and_set_alias ;;
|
9) check_and_set_alias ;;
|
||||||
*) echo "无效选项。" ;;
|
*) echo "无效选项。" ;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user