Titan-Network/Titan.sh

80 lines
2.5 KiB
Bash
Raw Normal View History

2024-03-14 06:59:40 +00:00
#!/bin/bash
# 脚本保存路径
2024-03-14 07:02:45 +00:00
SCRIPT_PATH="$HOME/Titan.sh"
2024-03-14 06:59:40 +00:00
# 函数定义
start_node() {
2024-03-14 08:57:06 +00:00
2024-03-14 06:59:40 +00:00
if [ "$1" = "first-time" ]; then
echo "首次启动节点..."
# 下载并解压 titan-node 到 /usr/local/bin
2024-03-14 09:04:37 +00:00
sudo apt update
sudo apt install screen -y
2024-03-14 06:59:40 +00:00
echo "正在下载并解压 titan-node..."
wget -c https://github.com/Titannet-dao/titan-node/releases/download/0.1.12/titan_v0.1.12_linux_amd64.tar.gz -O - | sudo tar -xz -C /usr/local/bin --strip-components=1
2024-03-14 07:31:08 +00:00
titan-edge daemon start --init --url https://test-locator.titannet.io:5000/rpc/v0
2024-03-14 06:59:40 +00:00
else
2024-03-14 09:05:00 +00:00
echo "启动节点监控并后台运行,请使用查看日志(screen -r titan)或者Titan面板功能..."
2024-03-14 08:57:06 +00:00
screen -dmS titan bash -c 'titan-edge daemon start --init --url https://test-locator.titannet.io:5000/rpc/v0'
2024-03-14 06:59:40 +00:00
fi
}
bind_node() {
2024-03-14 07:36:37 +00:00
echo "绑定节点...进入网页:https://test1.titannet.io/newoverview/activationcodemanagement 注册账户,并点击节点管理,点击获取身份码,在下方输入即可"
2024-03-14 06:59:40 +00:00
read -p "请输入身份码: " identity_code
echo "绑定节点,身份码为: $identity_code ..."
2024-03-14 07:31:08 +00:00
titan-edge bind --hash=$identity_code https://api-test1.container1.titannet.io/api/v2/device/binding
2024-03-14 06:59:40 +00:00
}
stop_node() {
echo "停止节点..."
titan-edge daemon stop
}
2024-03-14 07:31:08 +00:00
check_logs() {
echo "查看日志..."
2024-03-14 08:57:06 +00:00
screen -r titan
2024-03-14 07:31:08 +00:00
}
2024-03-14 06:59:40 +00:00
# 主菜单
function main_menu() {
clear
echo "脚本以及教程由推特用户大赌哥 @y95277777 编写,免费开源,请勿相信收费"
echo "================================================================"
echo "节点社区 Telegram 群组:https://t.me/niuwuriji"
echo "节点社区 Telegram 频道:https://t.me/niuwuriji"
echo "首次安装节点后等待生成文件大约1-2分钟敲击键盘ctrl c 停止节点,绑定身份码,再运行启动节点即可"
echo "请选择要执行的操作:"
echo "1) 安装节点"
echo "2) 启动节点"
echo "3) 绑定节点"
echo "4) 停止节点"
2024-03-14 07:31:08 +00:00
echo "5) 查看日志"
2024-03-14 06:59:40 +00:00
read -p "输入选择 (1-5): " choice
case $choice in
1)
start_node first-time
;;
2)
start_node
;;
3)
bind_node
;;
4)
stop_node
;;
2024-03-14 07:31:08 +00:00
5)
check_logs
;;
2024-03-14 06:59:40 +00:00
*)
echo "无效输入,请重新输入."
;;
esac
}
# 显示主菜单
main_menu