mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2025-08-12 06:26:39 +00:00
Compare commits
22 Commits
v0.1.3-bet
...
v0.1.4-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fe1110ab3 | ||
|
|
812c953976 | ||
|
|
f89505ab87 | ||
|
|
640eb8c02d | ||
|
|
fc3462ff9e | ||
|
|
071a6b124a | ||
|
|
45a8cf21f6 | ||
|
|
1315efa4d2 | ||
|
|
c2bd51faab | ||
|
|
f1ce2bbb77 | ||
|
|
a18bf1889b | ||
|
|
12c93de8c5 | ||
|
|
8280b62881 | ||
|
|
608847b1cb | ||
|
|
b4838ba402 | ||
|
|
fbd70a8eb1 | ||
|
|
fd1632fccb | ||
|
|
4a725d2c48 | ||
|
|
96bb323f72 | ||
|
|
961c29e499 | ||
|
|
870d1f3b5a | ||
|
|
24eedfa3fe |
@@ -7,6 +7,10 @@ DEBUG_MODE=${2}
|
||||
TARGET_DIR="dist"
|
||||
PLATFORMS="darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 linux/mips"
|
||||
|
||||
BUILD_VERSION="$(git describe --tags --always)"
|
||||
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
COMMIT_SHA1="$(git rev-parse --short HEAD)"
|
||||
|
||||
rm -rf ${TARGET_DIR}
|
||||
mkdir ${TARGET_DIR}
|
||||
|
||||
@@ -21,15 +25,15 @@ for pl in ${PLATFORMS}; do
|
||||
echo "build => ${TARGET}"
|
||||
if [ "${DEBUG_MODE}" == "debug" ]; then
|
||||
go build -trimpath -gcflags "all=-N -l" -o ${TARGET} \
|
||||
-ldflags "-X 'main.version=${BUILD_VERSION}' \
|
||||
-X 'main.buildDate=${BUILD_DATE}' \
|
||||
-X 'main.commitID=${COMMIT_SHA1}'\
|
||||
-ldflags "-X 'github.com/xgadget-lab/nexttrace/printer.version=${BUILD_VERSION}' \
|
||||
-X 'github.com/xgadget-lab/nexttrace/printer.buildDate=${BUILD_DATE}' \
|
||||
-X 'github.com/xgadget-lab/nexttrace/printer.commitID=${COMMIT_SHA1}'\
|
||||
-w -s"
|
||||
else
|
||||
go build -trimpath -o ${TARGET} \
|
||||
-ldflags "-X 'main.version=${BUILD_VERSION}' \
|
||||
-X 'main.buildDate=${BUILD_DATE}' \
|
||||
-X 'main.commitID=${COMMIT_SHA1}'\
|
||||
-ldflags "-X 'github.com/xgadget-lab/nexttrace/printer.version=${BUILD_VERSION}' \
|
||||
-X 'github.com/xgadget-lab/nexttrace/printer.buildDate=${BUILD_DATE}' \
|
||||
-X 'github.com/xgadget-lab/nexttrace/printer.commitID=${COMMIT_SHA1}'\
|
||||
-w -s"
|
||||
fi
|
||||
done
|
||||
|
||||
40
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
40
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
name: nexttrace 程序问题
|
||||
about: "提交一个 nexttrace 的程序问题报告。"
|
||||
copyright: [v2fly](https://github.com/v2fly)
|
||||
---
|
||||
|
||||
<!--
|
||||
除非特殊情况,请完整填写所有问题。不按模板发的 issue 将直接被关闭。
|
||||
如果你遇到的问题不是 nexttrace 的 bug,比如你不清楚如何配置,请在 https://github.com/xgadget-lab/nexttrace/discussions 进行讨论。
|
||||
-->
|
||||
|
||||
## 你正在使用哪个版本的 nexttrace?
|
||||
|
||||
<!-- 比如linux_amd64 macOS_arm64 -->
|
||||
|
||||
|
||||
## 你看到的异常现象是什么?
|
||||
|
||||
<!-- 请描述具体现象 -->
|
||||
|
||||
|
||||
## 你期待看到的正常表现是怎样的?
|
||||
|
||||
|
||||
|
||||
## 请附上你的命令
|
||||
|
||||
<!-- 提交 issue 前,请隐去您的隐私信息 -->
|
||||
|
||||
|
||||
## 请附上出错时软件输出的错误信息
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@@ -1,11 +1,10 @@
|
||||
on:
|
||||
push: # 每次带有 tag 的 push 候触发
|
||||
tags:
|
||||
- 'v*'
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
name: Build Release
|
||||
name: Test & Build Release
|
||||
jobs:
|
||||
test:
|
||||
Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -17,8 +16,9 @@ jobs:
|
||||
- name: Test
|
||||
run: go test -v -coverprofile='coverage.out' -covermode=count ./...
|
||||
|
||||
release:
|
||||
Build:
|
||||
needs: test
|
||||
if: contains('{{ github.ref }}', 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
@@ -1,17 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
name: Test
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: "1.18"
|
||||
|
||||
- name: Test
|
||||
run: go test -v -coverprofile='coverage.out' -covermode=count ./...
|
||||
48
README.md
48
README.md
@@ -6,14 +6,14 @@
|
||||
|
||||
# NextTrace
|
||||
|
||||
一款开源的可视化路由跟踪工具,使用Golang开发。
|
||||
一款开源的可视化路由跟踪工具,使用 Golang 开发。
|
||||
|
||||
## How To Use
|
||||
|
||||
### Install
|
||||
|
||||
```bash
|
||||
bash -c "$(curl -Ls https://raw.githubusercontent.com/xgadget-lab/nexttrace/main/nt_install.sh)"
|
||||
curl -Ls https://raw.githubusercontent.com/xgadget-lab/nexttrace/main/nt_install.sh -O && sudo bash nt_install.sh
|
||||
```
|
||||
|
||||
### Get Started
|
||||
@@ -32,6 +32,7 @@ nexttrace 2606:4700:4700::1111
|
||||
```
|
||||
|
||||
`NextTrace`也可以使用`TCP`和`UDP`协议发起`Traceroute`请求,不过目前只支持`IPv4`
|
||||
|
||||
```bash
|
||||
# TCP SYN Trace
|
||||
nexttrace -T www.bing.com
|
||||
@@ -45,7 +46,7 @@ nexttrace -U 1.0.0.1
|
||||
nexttrace -U -p 53 1.0.0.1
|
||||
```
|
||||
|
||||
`NextTrace`也同样支持一些进阶功能,如IP反向解析、并发数控制、模式切换等
|
||||
`NextTrace`也同样支持一些进阶功能,如 IP 反向解析、并发数控制、模式切换等
|
||||
|
||||
```bash
|
||||
# 无并发,每次只发送一个探测包
|
||||
@@ -58,15 +59,15 @@ nexttrace -rdns www.bbix.net
|
||||
nexttrace -r 1 -q 1 -report www.time.com.my
|
||||
```
|
||||
|
||||
### IP数据库
|
||||
### IP 数据库
|
||||
|
||||
目前使用的IP数据库默认为我们自己搭建的API服务,如果后期遇到滥用,我们可能会选择关闭。
|
||||
目前使用的 IP 数据库默认为我们自己搭建的 API 服务,如果后期遇到滥用,我们可能会选择关闭。
|
||||
|
||||
我们也会在后期开放服务端源代码,您也可以根据该项目的源码自行搭建属于您的API服务器。
|
||||
我们也会在后期开放服务端源代码,您也可以根据该项目的源码自行搭建属于您的 API 服务器。
|
||||
|
||||
NextTrace所有的的IP地理位置`API DEMO`可以参考[这里](https://github.com/xgadget-lab/nexttrace/blob/main/ipgeo/)
|
||||
NextTrace 所有的的 IP 地理位置`API DEMO`可以参考[这里](https://github.com/xgadget-lab/nexttrace/blob/main/ipgeo/)
|
||||
|
||||
### 全部用法详见Usage菜单
|
||||
### 全部用法详见 Usage 菜单
|
||||
|
||||
```shell
|
||||
Usage of nexttrace:
|
||||
@@ -93,12 +94,19 @@ Usage of nexttrace:
|
||||
Output trace results as table
|
||||
```
|
||||
|
||||
## FAQ 常见问题
|
||||
|
||||
如果你在安装或者使用的时候遇到了问题,我们建议你不要把新建一个 `issue` 作为首选项
|
||||
|
||||
或许可以在这里找到答案 -> [前往 Github Wiki](https://github.com/xgadget-lab/nexttrace/wiki/FAQ---%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E8%A7%A3%E7%AD%94)
|
||||
|
||||
<!-- 等待一个更好的项目截图
|
||||
## 项目截图
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
-->
|
||||
|
||||
<!--
|
||||
Leo注:描述可能不合适,建议再加以斟酌已经修改
|
||||
## History
|
||||
@@ -125,17 +133,25 @@ Leo注:描述可能不合适,建议再加以斟酌已经修改
|
||||
|
||||
#### China MainLand
|
||||
|
||||
* 项目组自行维护 ~ 御三家骨干网数据 ~ 5%
|
||||
- 项目组自行维护 ~ 御三家骨干网数据 ~ 5%
|
||||
|
||||
* 埃文科技 Paid Database ~ 95%
|
||||
- 埃文科技 Paid Database ~ 95%
|
||||
|
||||
**这里有朋友就要问了,为什么不全部使用埃文的付费库?**
|
||||
|
||||
埃文的库一直都不是最优选择,IPIP.NET 才是,但是因为他们不对私,所以我们只能选择价格更便宜的埃文库。
|
||||
|
||||
埃文家的数据库,在骨干网这块,准度可以说是非常糟糕,作为一款可视化的路由跟踪工具,骨干网的数据库准度非常重要。
|
||||
|
||||
所以我们选择了尝试自行去校准一部分骨干网数据,但是由于我们缺乏检测节点以及志愿者,所以这项工作可能会进展的尤其缓慢。
|
||||
|
||||
#### WorldWide
|
||||
|
||||
* 埃文科技 Paid Database ~ 15%
|
||||
- 埃文科技 Paid Database ~ 15%
|
||||
|
||||
* IpInfo Free ~ 15%
|
||||
- IpInfo Free ~ 15%
|
||||
|
||||
* IPInSight Free ~ 70%
|
||||
- IPInSight Free ~ 70%
|
||||
|
||||
### IPv6 Database
|
||||
|
||||
@@ -143,4 +159,4 @@ This product includes IP2Location LITE data available from <a href="https://lite
|
||||
|
||||
### Others
|
||||
|
||||
其他第三方API尽管集成在本项目内,但是具体的TOS以及AUP,请详见第三方API官网。如遇到IP数据错误,也请直接联系他们纠错。
|
||||
其他第三方 API 尽管集成在本项目内,但是具体的 TOS 以及 AUP,请详见第三方 API 官网。如遇到 IP 数据错误,也请直接联系他们纠错。
|
||||
|
||||
192
nt_install.sh
192
nt_install.sh
@@ -1,5 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
auto=False
|
||||
#是否忽略一切警告,按默认执行
|
||||
if [[ $1 == "--auto" ]]; then
|
||||
auto=True
|
||||
fi
|
||||
|
||||
usrPath="/usr/local/bin"
|
||||
|
||||
checkRootPermit() {
|
||||
@@ -49,15 +55,15 @@ getLocation() {
|
||||
}
|
||||
|
||||
installWgetPackage() {
|
||||
# macOS should install wget originally. Nothing to do
|
||||
echo "wget 正在安装中..."
|
||||
# try apt
|
||||
# 是时候直接使用 APT 来管理包了
|
||||
apt -h &>/dev/null
|
||||
apt-get -h &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# 先更新一下数据源,有些机器数据源比较老可能会404
|
||||
apt update -y &>/dev/null
|
||||
apt install wget -y &>/dev/null
|
||||
apt-get update -y &>/dev/null
|
||||
apt-get --no-install-recommends install wget -y &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try yum
|
||||
@@ -65,6 +71,7 @@ installWgetPackage() {
|
||||
if [ $? -eq 0 ]; then
|
||||
yum -y update &>/dev/null
|
||||
yum install wget -y &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try dnf
|
||||
@@ -72,6 +79,7 @@ installWgetPackage() {
|
||||
if [ $? -eq 0 ]; then
|
||||
dnf check-update &>/dev/null
|
||||
dnf install wget -y &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try pacman
|
||||
@@ -79,8 +87,25 @@ installWgetPackage() {
|
||||
if [ $? -eq 0 ]; then
|
||||
pacman -Sy &>/dev/null
|
||||
pacman -S wget &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
# try zypper
|
||||
zypper -h &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
zypper refresh &>/dev/null
|
||||
zypper install -y --no-recommends wget &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try brew
|
||||
brew -v &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
brew update &>/dev/null
|
||||
brew install wget &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 有的发行版自带的wget,只有 --help 参数
|
||||
wget --help &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -90,14 +115,14 @@ installWgetPackage() {
|
||||
}
|
||||
|
||||
installJqPackage() {
|
||||
# macOS should install wget originally. Nothing to do
|
||||
echo "jq 正在安装中..."
|
||||
# try apt
|
||||
apt-get -h &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# 先更新一下数据源,有些机器数据源比较老可能会404
|
||||
apt-get update -y &>/dev/null
|
||||
apt-get install jq -y &>/dev/null
|
||||
apt-get --no-install-recommends install jq -y &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try yum
|
||||
@@ -105,6 +130,7 @@ installJqPackage() {
|
||||
if [ $? -eq 0 ]; then
|
||||
yum -y update &>/dev/null
|
||||
yum install jq -y &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try dnf
|
||||
@@ -112,6 +138,15 @@ installJqPackage() {
|
||||
if [ $? -eq 0 ]; then
|
||||
dnf check-update &>/dev/null
|
||||
dnf install jq -y &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try zypper
|
||||
zypper -h &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
zypper refresh &>/dev/null
|
||||
zypper install -y --no-recommends jq &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try pacman
|
||||
@@ -119,6 +154,15 @@ installJqPackage() {
|
||||
if [ $? -eq 0 ]; then
|
||||
pacman -Sy &>/dev/null
|
||||
pacman -S jq &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try brew
|
||||
brew -v &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
brew update &>/dev/null
|
||||
brew install jq &>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
jq -h &>/dev/null
|
||||
@@ -131,6 +175,10 @@ installJqPackage() {
|
||||
checkWgetPackage() {
|
||||
wget -h &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
if [[ $auto == True ]]; then
|
||||
installWgetPackage
|
||||
return 0
|
||||
fi
|
||||
read -r -p "您还没有安装wget,是否安装? (y/n)" input
|
||||
|
||||
case $input in
|
||||
@@ -150,34 +198,14 @@ checkWgetPackage() {
|
||||
fi
|
||||
}
|
||||
|
||||
checkVersion() {
|
||||
echo "正在检查版本..."
|
||||
version=$(curl -sL https://api.github.com/repos/xgadget-lab/nexttrace/releases/latest | jq -r '.tag_name')
|
||||
if [[ $version == "" ]]; then
|
||||
echo "获取版本失败,请检查网络连接"
|
||||
exit 1
|
||||
fi
|
||||
echo 当前最新release版本:${version}
|
||||
read -r -p "是否安装/更新软件? (y/n)" input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
break
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "您选择了取消安装/更新,脚本即将退出"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkJqPackage() {
|
||||
jq -h &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "您还没有安装jq, 当您取消安装,我们会使用awk获取当前版本号。"
|
||||
read -r -p "但是如遇Github变更API,这可能会存在问题,是否安装? (y/n)" input
|
||||
if [[ $auto == True ]]; then
|
||||
installJqPackage
|
||||
return 0
|
||||
fi
|
||||
read -r -p "您还没有安装jq,是否安装? (y/n)" input
|
||||
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
@@ -185,8 +213,8 @@ checkJqPackage() {
|
||||
;;
|
||||
|
||||
[nN][oO] | [nN])
|
||||
echo "您选择了取消安装"
|
||||
return 0
|
||||
echo "您选择了取消安装,脚本即将退出"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
@@ -197,6 +225,39 @@ checkJqPackage() {
|
||||
return 1
|
||||
}
|
||||
|
||||
checkVersion() {
|
||||
checkJqPackage
|
||||
echo "正在检查版本..."
|
||||
version=$(curl -sL https://api.github.com/repos/xgadget-lab/nexttrace/releases/latest | jq -r '.tag_name')
|
||||
if [[ $version == "" ]]; then
|
||||
echo "获取版本失败,请检查网络连接"
|
||||
exit 1
|
||||
fi
|
||||
currentVersion=$(nexttrace -V | head -n 1 | awk '{print $2}')
|
||||
if [[ $currentVersion == $version ]]; then
|
||||
echo "当前版本已是最新版本"
|
||||
exit 0
|
||||
fi
|
||||
echo 当前最新release版本:${version}
|
||||
echo 您当前的版本:${currentVersion}
|
||||
if [[ $auto == True ]]; then
|
||||
return 0
|
||||
fi
|
||||
read -r -p "是否更新软件? (y/n)" input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
return 0
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "您选择了取消安装/更新,脚本即将退出"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
downloadBinrayFile() {
|
||||
echo "正在获取最新版的 NextTrace 发行版文件信息..."
|
||||
checkJqPackage
|
||||
@@ -211,20 +272,24 @@ downloadBinrayFile() {
|
||||
latestURL=$(curl -s https://api.github.com/repos/xgadget-lab/nexttrace/releases/latest | grep -i "browser_download_url.*${osDistribution}.*${archParam}" | awk -F '"' '{print $4}')
|
||||
fi
|
||||
if [ "$countryCode" == "CN" ]; then
|
||||
read -r -p "检测到国内网络环境,是否使用镜像下载以加速(y/n)" input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
if [[ $auto == True ]]; then
|
||||
latestURL="https://ghproxy.com/"$latestURL
|
||||
;;
|
||||
else
|
||||
read -r -p "检测到国内网络环境,是否使用镜像下载以加速(y/n)" input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
latestURL="https://ghproxy.com/"$latestURL
|
||||
;;
|
||||
|
||||
[nN][oO] | [nN])
|
||||
echo "您选择了不使用镜像,下载可能会变得异常缓慢,或者失败"
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "您选择了不使用镜像,下载可能会变得异常缓慢,或者失败"
|
||||
;;
|
||||
|
||||
*)
|
||||
latestURL="https://ghproxy.com/"$latestURL
|
||||
;;
|
||||
esac
|
||||
*)
|
||||
latestURL="https://ghproxy.com/"$latestURL
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "正在下载 NextTrace 二进制文件..."
|
||||
@@ -233,7 +298,7 @@ downloadBinrayFile() {
|
||||
echo "NextTrace 现在已经在您的系统中可用"
|
||||
changeMode
|
||||
mv ${downPath} ${usrPath}
|
||||
if [[ ${osDistribution} == "macOS" ]]; then
|
||||
if [[ ${osDistribution} == "darwin" ]]; then
|
||||
xattr -r -d com.apple.quarantine ${usrPath}/nexttrace
|
||||
fi
|
||||
else
|
||||
@@ -252,13 +317,43 @@ runBinrayFileHelp() {
|
||||
fi
|
||||
}
|
||||
|
||||
addCronTask() {
|
||||
if [[ $auto == True ]]; then
|
||||
return 0
|
||||
fi
|
||||
read -r -p "是否添加自动更新任务?(y/n)" input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
if [[ ${osDistribution} == "darwin" ]]; then
|
||||
crontab -l >crontab.bak
|
||||
sed -i '' '/nt_install.sh/d' crontab.bak
|
||||
elif [[ ${osDistribution} == "linux" ]]; then
|
||||
crontab -l >crontab.bak
|
||||
sed -i '/nt_install.sh/d' crontab.bak
|
||||
else
|
||||
echo "暂不支持您的系统,无法自动添加crontab任务"
|
||||
return 0
|
||||
fi
|
||||
echo "1 1 * * * $(dirname $(readlink -f "$0"))/nt_install.sh --auto >> /var/log/nt_install.log" >>crontab.bak
|
||||
crontab crontab.bak
|
||||
rm -f crontab.bak
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "您选择了不添加自动更新任务,您也可以通过命令 再次执行此脚本 手动更新"
|
||||
;;
|
||||
*)
|
||||
echo "您选择了不添加自动更新任务,您可以通过命令 再次执行此脚本 手动更新"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Check Procedure
|
||||
checkRootPermit
|
||||
checkSystemDistribution
|
||||
checkSystemArch
|
||||
checkWgetPackage
|
||||
# TODO: 检查版本并更新
|
||||
#checkVersion
|
||||
checkJqPackage
|
||||
checkVersion
|
||||
|
||||
# Download Procedure
|
||||
getLocation
|
||||
@@ -266,3 +361,4 @@ downloadBinrayFile
|
||||
|
||||
# Run Procedure
|
||||
runBinrayFileHelp
|
||||
addCronTask
|
||||
|
||||
@@ -5,8 +5,12 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
var version = "v0.0.0.alpha"
|
||||
var buildDate = ""
|
||||
var commitID = ""
|
||||
|
||||
func Version() {
|
||||
fmt.Print("NextTrace v0.1.2-Beta ") // TODO get version from git
|
||||
fmt.Println("NextTrace", version, buildDate, commitID)
|
||||
fmt.Println("XGadget-lab Leo (leo.moe) & Vincent (vincent.moe) & zhshch (xzhsh.ch)")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user