Titan-Network/Titan.sh
2024-03-14 15:46:20 +08:00

77 lines
2.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 脚本保存路径
SCRIPT_PATH="$HOME/Titan.sh"
# 函数定义
start_node() {
if [ "$1" = "first-time" ]; then
echo "首次启动节点..."
# 下载并解压 titan-node 到 /usr/local/bin
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
titan-edge daemon start --init --url https://test-locator.titannet.io:5000/rpc/v0
else
echo "启动节点并后台运行请使用查看日志或者Titan面板功能..."
nohup ./titan-edge daemon start --init --url https://test-locator.titannet.io:5000/rpc/v0 > edge.log 2>&1 &
fi
}
bind_node() {
echo "绑定节点...进入网页:https://test1.titannet.io/newoverview/activationcodemanagement 注册账户,并点击节点管理,点击获取身份码,在下方输入即可"
read -p "请输入身份码: " identity_code
echo "绑定节点,身份码为: $identity_code ..."
titan-edge bind --hash=$identity_code https://api-test1.container1.titannet.io/api/v2/device/binding
}
stop_node() {
echo "停止节点..."
titan-edge daemon stop
}
check_logs() {
echo "查看日志..."
cat edge.log
}
# 主菜单
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) 停止节点"
echo "5) 查看日志"
read -p "输入选择 (1-5): " choice
case $choice in
1)
start_node first-time
;;
2)
start_node
;;
3)
bind_node
;;
4)
stop_node
;;
5)
check_logs
;;
*)
echo "无效输入,请重新输入."
;;
esac
}
# 显示主菜单
main_menu