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() {
|
|
|
|
|
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
|
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 07:39:22 +00:00
|
|
|
|
echo "启动节点并后台运行,请使用查看日志,或者Titan面板功能..."
|
2024-03-14 07:41:15 +00:00
|
|
|
|
nohup ./titan-edge daemon start --init --url https://test-locator.titannet.io:5000/rpc/v0 > edge.log 2>&1 &
|
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 07:46:20 +00:00
|
|
|
|
cat edge.log
|
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
|