Compare commits

...
26 Commits
Author SHA1 Message Date
naiba 194f3290bc ⬆️ Update dependencies 2024-03-30 11:15:26 +08:00
zhucaidan dc5c79711d Optimize translation (#343) 2024-03-30 11:12:00 +08:00
github-actions[bot] d88989fb85 update contributors[no ci] 2024-03-30 03:08:46 +00:00
UUBulb 0373d03fb2 fix installer bugs & improve (#341)
* fix installer bugs && improve

* Update install_en.sh
2024-03-30 11:08:29 +08:00
github-actions[bot] 140f9809a0 update contributors[no ci] 2024-03-30 03:01:11 +00:00
UUBulb f647a5f8e6 ddns: Add ability to update IPv4 or IPv6 only (#342)
* ddns: Add ability to resolve IPv4 or IPv6 only

* Fix bugs

* cdn cache
2024-03-30 11:00:55 +08:00
github-actions[bot] 506c87dbd8 update contributors[no ci] 2024-03-24 14:46:54 +00:00
naiba 8b5d513c6a Merge branch 'xykt-master' 2024-03-24 22:46:35 +08:00
naiba 6c718c4f38 Remove redundant code for MaxTCPPingValue initialization 2024-03-24 22:45:56 +08:00
xykt 5a2ab8a7ee Update network.html 2024-03-24 19:26:51 +08:00
xykt 0ea0c9ad8c Update network.html 2024-03-24 19:21:32 +08:00
xykt 7d4d8c46b8 Update network.html 2024-03-24 19:21:07 +08:00
xykt a4636ed774 Update network.html 2024-03-24 19:20:34 +08:00
xykt bb48e0912d Update network.html 2024-03-24 19:20:01 +08:00
xykt a575d1a6e0 Merge branch 'naiba:master' into master 2024-03-24 19:13:03 +08:00
github-actions[bot] 420d1ca8ff update contributors[no ci] 2024-03-24 08:13:23 +00:00
naiba 29554ec7ec 🐛 revert shit 2024-03-24 16:12:51 +08:00
xykt 9a8c0e7118 Update network.html 2024-03-24 09:24:23 +08:00
xykt 800af7ce4e Update network.html 2024-03-24 09:22:13 +08:00
xykt 78134a0e8b Update network.html 2024-03-24 09:20:53 +08:00
xykt bad910b686 Update network.html 2024-03-24 09:16:41 +08:00
xykt a7d1bd7487 Update network.html
美化了三网延迟界面:
1. 将Marker缩小降低曲线遮挡
2. 设置为曲线对应的颜色使其更加直观
3. 设置Marker透明度降低对画面的影响
4. 将延迟极小值的Marker倒置显示以快速区别极大值
5. 将超过MaxTCPPingValue的点删除
6. 显示丢包分布(细线),以及服务器断流区间(粗线)
2024-03-24 01:04:03 +08:00
xykt 20a10ac6b8 Merge branch 'naiba:master' into master 2024-03-23 13:25:37 +08:00
xykt 3a395e66c0 Merge branch 'naiba:master' into master 2024-03-04 16:07:13 +08:00
xykt 4e5cc0b642 Update config.go
修复了以下问题:
- 延迟默认最高300ms,超过后默认抹平
- 曲线上有很多ping值为0的无效散点,导致毛刺很多,干扰效果
- 图标的y轴比例失调,上方大片留白,大大降低了有效显示区域
- 默认只显示最近不到半小时左右的延迟表现,想看全天需要拖动,影响效果
- 曲线不显示极大极小值,不够直观
2024-02-19 01:17:42 +08:00
xykt fe2872bbb3 Update network.html
修复以下问题:
- 延迟默认最高300ms,超过后默认抹平
- 曲线上有很多ping值为0的无效散点,导致毛刺很多,干扰效果
- 图标的y轴比例失调,上方大片留白,大大降低了有效显示区域
- 默认只显示最近不到半小时左右的延迟表现,想看全天需要拖动,影响效果
- 曲线不显示极大极小值,不够直观
2024-02-19 01:14:26 +08:00
24 changed files with 710 additions and 1100 deletions
+3 -3
View File
@@ -42,15 +42,16 @@ You can change the dashboard language in the settings page (`/setting`) after th
<a href="https://github.com/AkkiaS7" title="Akkia"><img src="https://avatars.githubusercontent.com/u/68485070?v=4" width="50;" alt="Akkia"/></a> <a href="https://github.com/AkkiaS7" title="Akkia"><img src="https://avatars.githubusercontent.com/u/68485070?v=4" width="50;" alt="Akkia"/></a>
<a href="https://github.com/Erope" title="卖女孩的小火柴"><img src="https://avatars.githubusercontent.com/u/44471469?v=4" width="50;" alt="卖女孩的小火柴"/></a> <a href="https://github.com/Erope" title="卖女孩的小火柴"><img src="https://avatars.githubusercontent.com/u/44471469?v=4" width="50;" alt="卖女孩的小火柴"/></a>
<a href="https://github.com/dysf888" title="黑歌"><img src="https://avatars.githubusercontent.com/u/47450409?v=4" width="50;" alt="黑歌"/></a> <a href="https://github.com/dysf888" title="黑歌"><img src="https://avatars.githubusercontent.com/u/47450409?v=4" width="50;" alt="黑歌"/></a>
<a href="https://github.com/xykt" title="xykt"><img src="https://avatars.githubusercontent.com/u/152045469?v=4" width="50;" alt="xykt"/></a>
<a href="https://github.com/MikoyChinese" title="MikoyChinese"><img src="https://avatars.githubusercontent.com/u/22676744?v=4" width="50;" alt="MikoyChinese"/></a> <a href="https://github.com/MikoyChinese" title="MikoyChinese"><img src="https://avatars.githubusercontent.com/u/22676744?v=4" width="50;" alt="MikoyChinese"/></a>
<a href="https://github.com/JackieSung4ev" title="JackieSung4ev"><img src="https://avatars.githubusercontent.com/u/24974735?v=4" width="50;" alt="JackieSung4ev"/></a> <a href="https://github.com/JackieSung4ev" title="JackieSung4ev"><img src="https://avatars.githubusercontent.com/u/24974735?v=4" width="50;" alt="JackieSung4ev"/></a>
<a href="https://github.com/lemoeo" title="Lemoe"><img src="https://avatars.githubusercontent.com/u/18618627?v=4" width="50;" alt="Lemoe"/></a> <a href="https://github.com/lemoeo" title="Lemoe"><img src="https://avatars.githubusercontent.com/u/18618627?v=4" width="50;" alt="Lemoe"/></a>
<a href="https://github.com/cantoblanco" title="Kris"><img src="https://avatars.githubusercontent.com/u/116849421?v=4" width="50;" alt="Kris"/></a> <a href="https://github.com/cantoblanco" title="Kris"><img src="https://avatars.githubusercontent.com/u/116849421?v=4" width="50;" alt="Kris"/></a>
<a href="https://github.com/nap0o" title="nap0o"><img src="https://avatars.githubusercontent.com/u/144927971?v=4" width="50;" alt="nap0o"/></a> <a href="https://github.com/nap0o" title="nap0o"><img src="https://avatars.githubusercontent.com/u/144927971?v=4" width="50;" alt="nap0o"/></a>
<a href="https://github.com/uubulb" title="UUBulb"><img src="https://avatars.githubusercontent.com/u/35923940?v=4" width="50;" alt="UUBulb"/></a>
<a href="https://github.com/spiritLHLS" title="spiritlhl"><img src="https://avatars.githubusercontent.com/u/103393591?v=4" width="50;" alt="spiritlhl"/></a> <a href="https://github.com/spiritLHLS" title="spiritlhl"><img src="https://avatars.githubusercontent.com/u/103393591?v=4" width="50;" alt="spiritlhl"/></a>
<a href="https://github.com/liuyanxi975" title="刘颜溪"><img src="https://avatars.githubusercontent.com/u/24417037?v=4" width="50;" alt="刘颜溪"/></a> <a href="https://github.com/liuyanxi975" title="刘颜溪"><img src="https://avatars.githubusercontent.com/u/24417037?v=4" width="50;" alt="刘颜溪"/></a>
<a href="https://github.com/CosmosZ-code" title="CosmosZ-code"><img src="https://avatars.githubusercontent.com/u/81398224?v=4" width="50;" alt="CosmosZ-code"/></a> <a href="https://github.com/CosmosZ-code" title="CosmosZ-code"><img src="https://avatars.githubusercontent.com/u/81398224?v=4" width="50;" alt="CosmosZ-code"/></a>
<a href="https://github.com/uubulb" title="UUBulb"><img src="https://avatars.githubusercontent.com/u/35923940?v=4" width="50;" alt="UUBulb"/></a>
<a href="https://github.com/lvgj-stack" title="Ko no dio"><img src="https://avatars.githubusercontent.com/u/38449861?v=4" width="50;" alt="Ko no dio"/></a> <a href="https://github.com/lvgj-stack" title="Ko no dio"><img src="https://avatars.githubusercontent.com/u/38449861?v=4" width="50;" alt="Ko no dio"/></a>
<a href="https://github.com/hhhkkk520" title="Kris"><img src="https://avatars.githubusercontent.com/u/52115472?v=4" width="50;" alt="Kris"/></a> <a href="https://github.com/hhhkkk520" title="Kris"><img src="https://avatars.githubusercontent.com/u/52115472?v=4" width="50;" alt="Kris"/></a>
<a href="https://github.com/1ridic" title="1ridic"><img src="https://avatars.githubusercontent.com/u/88495501?v=4" width="50;" alt="1ridic"/></a> <a href="https://github.com/1ridic" title="1ridic"><img src="https://avatars.githubusercontent.com/u/88495501?v=4" width="50;" alt="1ridic"/></a>
@@ -59,13 +60,13 @@ You can change the dashboard language in the settings page (`/setting`) after th
<a href="https://github.com/iilemon" title="Sean"><img src="https://avatars.githubusercontent.com/u/33201711?v=4" width="50;" alt="Sean"/></a> <a href="https://github.com/iilemon" title="Sean"><img src="https://avatars.githubusercontent.com/u/33201711?v=4" width="50;" alt="Sean"/></a>
<a href="https://github.com/fscarmen" title="fscarmen"><img src="https://avatars.githubusercontent.com/u/62703343?v=4" width="50;" alt="fscarmen"/></a> <a href="https://github.com/fscarmen" title="fscarmen"><img src="https://avatars.githubusercontent.com/u/62703343?v=4" width="50;" alt="fscarmen"/></a>
<a href="https://github.com/ch8o" title="no-name-now"><img src="https://avatars.githubusercontent.com/u/9103372?v=4" width="50;" alt="no-name-now"/></a> <a href="https://github.com/ch8o" title="no-name-now"><img src="https://avatars.githubusercontent.com/u/9103372?v=4" width="50;" alt="no-name-now"/></a>
<a href="https://github.com/HsukqiLee" title="HsukqiLee"><img src="https://avatars.githubusercontent.com/u/79034142?v=4" width="50;" alt="HsukqiLee"/></a>
<a href="https://github.com/DarcJC" title="Darc Z."><img src="https://avatars.githubusercontent.com/u/53445798?v=4" width="50;" alt="Darc Z."/></a> <a href="https://github.com/DarcJC" title="Darc Z."><img src="https://avatars.githubusercontent.com/u/53445798?v=4" width="50;" alt="Darc Z."/></a>
<a href="https://github.com/Creling" title="Creling"><img src="https://avatars.githubusercontent.com/u/43109504?v=4" width="50;" alt="Creling"/></a> <a href="https://github.com/Creling" title="Creling"><img src="https://avatars.githubusercontent.com/u/43109504?v=4" width="50;" alt="Creling"/></a>
<a href="https://github.com/coreff" title="Core F"><img src="https://avatars.githubusercontent.com/u/38347122?v=4" width="50;" alt="Core F"/></a> <a href="https://github.com/coreff" title="Core F"><img src="https://avatars.githubusercontent.com/u/38347122?v=4" width="50;" alt="Core F"/></a>
<a href="https://github.com/colour93" title="玖叁"><img src="https://avatars.githubusercontent.com/u/64313711?v=4" width="50;" alt="玖叁"/></a> <a href="https://github.com/colour93" title="玖叁"><img src="https://avatars.githubusercontent.com/u/64313711?v=4" width="50;" alt="玖叁"/></a>
<a href="https://github.com/arkylin" title="凌"><img src="https://avatars.githubusercontent.com/u/35104502?v=4" width="50;" alt="凌"/></a> <a href="https://github.com/arkylin" title="凌"><img src="https://avatars.githubusercontent.com/u/35104502?v=4" width="50;" alt="凌"/></a>
<a href="https://github.com/ysicing" title="缘生"><img src="https://avatars.githubusercontent.com/u/8605565?v=4" width="50;" alt="缘生"/></a> <a href="https://github.com/ysicing" title="缘生"><img src="https://avatars.githubusercontent.com/u/8605565?v=4" width="50;" alt="缘生"/></a>
<a href="https://github.com/xykt" title="xykt"><img src="https://avatars.githubusercontent.com/u/152045469?v=4" width="50;" alt="xykt"/></a>
<a href="https://github.com/unclezs" title="unclezs"><img src="https://avatars.githubusercontent.com/u/42318775?v=4" width="50;" alt="unclezs"/></a> <a href="https://github.com/unclezs" title="unclezs"><img src="https://avatars.githubusercontent.com/u/42318775?v=4" width="50;" alt="unclezs"/></a>
<a href="https://github.com/yuanweize" title="I"><img src="https://avatars.githubusercontent.com/u/30067203?v=4" width="50;" alt="I"/></a> <a href="https://github.com/yuanweize" title="I"><img src="https://avatars.githubusercontent.com/u/30067203?v=4" width="50;" alt="I"/></a>
<a href="https://github.com/guoyongchang" title="guoyongchang"><img src="https://avatars.githubusercontent.com/u/10484506?v=4" width="50;" alt="guoyongchang"/></a> <a href="https://github.com/guoyongchang" title="guoyongchang"><img src="https://avatars.githubusercontent.com/u/10484506?v=4" width="50;" alt="guoyongchang"/></a>
@@ -76,7 +77,6 @@ You can change the dashboard language in the settings page (`/setting`) after th
<a href="https://github.com/MartijnLindeman" title="Martijn Lindeman"><img src="https://avatars.githubusercontent.com/u/78365708?v=4" width="50;" alt="Martijn Lindeman"/></a> <a href="https://github.com/MartijnLindeman" title="Martijn Lindeman"><img src="https://avatars.githubusercontent.com/u/78365708?v=4" width="50;" alt="Martijn Lindeman"/></a>
<a href="https://github.com/KorenKrita" title="KorenKrita"><img src="https://avatars.githubusercontent.com/u/22239339?v=4" width="50;" alt="KorenKrita"/></a> <a href="https://github.com/KorenKrita" title="KorenKrita"><img src="https://avatars.githubusercontent.com/u/22239339?v=4" width="50;" alt="KorenKrita"/></a>
<a href="https://github.com/techotaku" title="Ian Li"><img src="https://avatars.githubusercontent.com/u/1948179?v=4" width="50;" alt="Ian Li"/></a> <a href="https://github.com/techotaku" title="Ian Li"><img src="https://avatars.githubusercontent.com/u/1948179?v=4" width="50;" alt="Ian Li"/></a>
<a href="https://github.com/HsukqiLee" title="HsukqiLee"><img src="https://avatars.githubusercontent.com/u/79034142?v=4" width="50;" alt="HsukqiLee"/></a>
<a href="https://github.com/GreenTeodoro839" title="GreenTeodoro839"><img src="https://avatars.githubusercontent.com/u/77104800?v=4" width="50;" alt="GreenTeodoro839"/></a> <a href="https://github.com/GreenTeodoro839" title="GreenTeodoro839"><img src="https://avatars.githubusercontent.com/u/77104800?v=4" width="50;" alt="GreenTeodoro839"/></a>
<a href="https://github.com/Es-dese" title="Esdese"><img src="https://avatars.githubusercontent.com/u/71542548?v=4" width="50;" alt="Esdese"/></a> <a href="https://github.com/Es-dese" title="Esdese"><img src="https://avatars.githubusercontent.com/u/71542548?v=4" width="50;" alt="Esdese"/></a>
<a href="https://github.com/wwng2333" title="Crazy"><img src="https://avatars.githubusercontent.com/u/17147265?v=4" width="50;" alt="Crazy"/></a><!--GAMFC_DELIMITER_END--> <a href="https://github.com/wwng2333" title="Crazy"><img src="https://avatars.githubusercontent.com/u/17147265?v=4" width="50;" alt="Crazy"/></a><!--GAMFC_DELIMITER_END-->
+4
View File
@@ -301,6 +301,8 @@ type serverForm struct {
Note string Note string
HideForGuest string HideForGuest string
EnableDDNS string EnableDDNS string
EnableIPv4 string
EnableIpv6 string
DDNSDomain string DDNSDomain string
} }
@@ -318,6 +320,8 @@ func (ma *memberAPI) addOrEditServer(c *gin.Context) {
s.Note = sf.Note s.Note = sf.Note
s.HideForGuest = sf.HideForGuest == "on" s.HideForGuest = sf.HideForGuest == "on"
s.EnableDDNS = sf.EnableDDNS == "on" s.EnableDDNS = sf.EnableDDNS == "on"
s.EnableIPv4 = sf.EnableIPv4 == "on"
s.EnableIpv6 = sf.EnableIpv6 == "on"
s.DDNSDomain = sf.DDNSDomain s.DDNSDomain = sf.DDNSDomain
if s.ID == 0 { if s.ID == 0 {
s.Secret, err = utils.GenerateRandomString(18) s.Secret, err = utils.GenerateRandomString(18)
+3 -3
View File
@@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.3 toolchain go1.21.3
require ( require (
code.cloudfoundry.org/bytefmt v0.0.0-20240322144145-4816192cb114 code.cloudfoundry.org/bytefmt v0.0.0-20240329144308-0c372429d24b
code.gitea.io/sdk/gitea v0.17.1 code.gitea.io/sdk/gitea v0.17.1
github.com/BurntSushi/toml v1.3.2 github.com/BurntSushi/toml v1.3.2
github.com/gin-contrib/pprof v1.4.0 github.com/gin-contrib/pprof v1.4.0
@@ -22,7 +22,7 @@ require (
github.com/samber/lo v1.39.0 github.com/samber/lo v1.39.0
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2 github.com/spf13/viper v1.18.2
github.com/xanzy/go-gitlab v0.100.0 github.com/xanzy/go-gitlab v0.101.0
golang.org/x/crypto v0.21.0 golang.org/x/crypto v0.21.0
golang.org/x/oauth2 v0.18.0 golang.org/x/oauth2 v0.18.0
golang.org/x/sync v0.6.0 golang.org/x/sync v0.6.0
@@ -30,7 +30,7 @@ require (
google.golang.org/grpc v1.62.1 google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0 google.golang.org/protobuf v1.33.0
gorm.io/driver/sqlite v1.5.5 gorm.io/driver/sqlite v1.5.5
gorm.io/gorm v1.25.8 gorm.io/gorm v1.25.9
sigs.k8s.io/yaml v1.4.0 sigs.k8s.io/yaml v1.4.0
) )
+10 -10
View File
@@ -1,5 +1,5 @@
code.cloudfoundry.org/bytefmt v0.0.0-20240322144145-4816192cb114 h1:7KJsK0gPah7XfO46ARJA2TUXHZaJEnPI80mzxQLre68= code.cloudfoundry.org/bytefmt v0.0.0-20240329144308-0c372429d24b h1:cNaykmS90BLMH+ZNxQEJrbNyn1jRN0RMFvNZ6y6RVS4=
code.cloudfoundry.org/bytefmt v0.0.0-20240322144145-4816192cb114/go.mod h1:TNAH6xe5WOszc47+zM7NnpaJWBR8oYt12BUf4WLIZ98= code.cloudfoundry.org/bytefmt v0.0.0-20240329144308-0c372429d24b/go.mod h1:rUP3YSaxKT+3aSMMTiXqdxLz0C21nQAoPkQX/lHINjM=
code.gitea.io/sdk/gitea v0.17.1 h1:3jCPOG2ojbl8AcfaUCRYLT5MUcBMFwS0OSK2mA5Zok8= code.gitea.io/sdk/gitea v0.17.1 h1:3jCPOG2ojbl8AcfaUCRYLT5MUcBMFwS0OSK2mA5Zok8=
code.gitea.io/sdk/gitea v0.17.1/go.mod h1:aCnBqhHpoEWA180gMbaCtdX9Pl6BWBAuuP2miadoTNM= code.gitea.io/sdk/gitea v0.17.1/go.mod h1:aCnBqhHpoEWA180gMbaCtdX9Pl6BWBAuuP2miadoTNM=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
@@ -67,8 +67,8 @@ github.com/google/go-github/v47 v47.1.0/go.mod h1:VPZBXNbFSJGjyjFRUKo9vZGawTajnW
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20240320155624-b11c3daa6f07 h1:57oOH2Mu5Nw16KnZAVLdlUjmPH/TSYCKTJgG0OVfX0Y= github.com/google/pprof v0.0.0-20240327155427-868f304927ed h1:n8QtJTrwsv3P7dNxPaMeNkMcxvUpqocsHLr8iDLGlQI=
github.com/google/pprof v0.0.0-20240320155624-b11c3daa6f07/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/pprof v0.0.0-20240327155427-868f304927ed/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
@@ -125,8 +125,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/nicksnyder/go-i18n/v2 v2.4.0 h1:3IcvPOAvnCKwNm0TB0dLDTuawWEj+ax/RERNC+diLMM= github.com/nicksnyder/go-i18n/v2 v2.4.0 h1:3IcvPOAvnCKwNm0TB0dLDTuawWEj+ax/RERNC+diLMM=
github.com/nicksnyder/go-i18n/v2 v2.4.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4= github.com/nicksnyder/go-i18n/v2 v2.4.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4=
github.com/onsi/ginkgo/v2 v2.17.0 h1:kdnunFXpBjbzN56hcJHrXZ8M+LOkenKA7NnBzTNigTI= github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8=
github.com/onsi/ginkgo/v2 v2.17.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk=
github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg=
github.com/ory/graceful v0.1.3 h1:FaeXcHZh168WzS+bqruqWEw/HgXWLdNv2nJ+fbhxbhc= github.com/ory/graceful v0.1.3 h1:FaeXcHZh168WzS+bqruqWEw/HgXWLdNv2nJ+fbhxbhc=
@@ -186,8 +186,8 @@ github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/xanzy/go-gitlab v0.100.0 h1:jaOtYj5nWI19+9oVVmgy233pax2oYqucwetogYU46ks= github.com/xanzy/go-gitlab v0.101.0 h1:qRgvX8DNE19zRugB6rnnZMZ5ubhITSKPLNWEyc6UIPg=
github.com/xanzy/go-gitlab v0.100.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI= github.com/xanzy/go-gitlab v0.101.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
@@ -291,8 +291,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E= gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E=
gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE= gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE=
gorm.io/gorm v1.25.8 h1:WAGEZ/aEcznN4D03laj8DKnehe1e9gYQAjW8xyPRdeo= gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8=
gorm.io/gorm v1.25.8/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
+3 -1
View File
@@ -18,6 +18,8 @@ type Server struct {
DisplayIndex int // 展示排序,越大越靠前 DisplayIndex int // 展示排序,越大越靠前
HideForGuest bool // 对游客隐藏 HideForGuest bool // 对游客隐藏
EnableDDNS bool // 是否启用DDNS 未在配置文件中启用DDNS 或 DDNS检查时间为0时此项无效 EnableDDNS bool // 是否启用DDNS 未在配置文件中启用DDNS 或 DDNS检查时间为0时此项无效
EnableIPv4 bool // 是否启用DDNS IPv4
EnableIpv6 bool // 是否启用DDNS IPv6
DDNSDomain string // DDNS中的前缀 如基础域名为abc.oracle DDNSName为mjj 就会把mjj.abc.oracle解析服务器IP 为空则停用 DDNSDomain string // DDNS中的前缀 如基础域名为abc.oracle DDNSName为mjj 就会把mjj.abc.oracle解析服务器IP 为空则停用
Host *Host `gorm:"-"` Host *Host `gorm:"-"`
@@ -54,5 +56,5 @@ func (s Server) Marshal() template.JS {
note, _ := utils.Json.Marshal(s.Note) note, _ := utils.Json.Marshal(s.Note)
secret, _ := utils.Json.Marshal(s.Secret) secret, _ := utils.Json.Marshal(s.Secret)
ddnsDomain, _ := utils.Json.Marshal(s.DDNSDomain) ddnsDomain, _ := utils.Json.Marshal(s.DDNSDomain)
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s,"HideForGuest": %s,"EnableDDNS": %s,"DDNSDomain": %s}`, s.ID, name, secret, s.DisplayIndex, tag, note, boolToString(s.HideForGuest), boolToString(s.EnableDDNS), ddnsDomain)) // #nosec return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s,"HideForGuest": %s,"EnableDDNS": %s,"EnableIPv4": %s,"EnableIpv6": %s,"DDNSDomain": %s}`, s.ID, name, secret, s.DisplayIndex, tag, note, boolToString(s.HideForGuest), boolToString(s.EnableDDNS), boolToString(s.EnableIPv4), boolToString(s.EnableIpv6), ddnsDomain)) // #nosec
} }
+18 -12
View File
@@ -32,10 +32,10 @@ other = "Logout"
other = "Login" other = "Login"
[ConfirmLogout] [ConfirmLogout]
other = "Confirm Logout?" other = "Do you want to Logout?"
[AfterLoggingOutYouHaveToLoginAgain] [AfterLoggingOutYouHaveToLoginAgain]
other = "You need to login again after logout to continue" other = "You need to Login again to continue"
[Cancel] [Cancel]
other = "Cancel" other = "Cancel"
@@ -227,7 +227,7 @@ other = "Secret"
other = "Note" other = "Note"
[LinuxOneKeyInstall] [LinuxOneKeyInstall]
other = "Linux One-Key Install" other = "Linux One-Command Install"
[NoDomainAlert] [NoDomainAlert]
other = "Set CDN bypassed Domain/IP in setting before using this function" other = "Set CDN bypassed Domain/IP in setting before using this function"
@@ -257,7 +257,7 @@ other = "Execute by Trigger"
other = "Delete Scheduled Task" other = "Delete Scheduled Task"
[ConfirmToDeleteThisScheduledTask] [ConfirmToDeleteThisScheduledTask]
other = "Confirm Delete?" other = "Are you sure you want to Delete?"
[AccessDenied] [AccessDenied]
other = "Access Denied" other = "Access Denied"
@@ -293,7 +293,7 @@ other = "Delete Notification Method"
other = "Confirm to Delete This Notification Method?" other = "Confirm to Delete This Notification Method?"
[ForceUpdate] [ForceUpdate]
other = "Force Update" other = "Force to Update"
[SelectAll] [SelectAll]
other = "Select All" other = "Select All"
@@ -302,7 +302,7 @@ other = "Select All"
other = "Version" other = "Version"
[OneKeyInstall] [OneKeyInstall]
other = "One-Key Install" other = "One-Command Install"
[ClickToCopy] [ClickToCopy]
other = "Click To Copy" other = "Click To Copy"
@@ -398,7 +398,7 @@ other = "Virtualization"
other = "Swap" other = "Swap"
[NetTransfer] [NetTransfer]
other = "Transfer" other = "Usage"
[Load] [Load]
other = "Load" other = "Load"
@@ -419,7 +419,7 @@ other = "Last Active"
other = "Version" other = "Version"
[NetSpeed] [NetSpeed]
other = "Speed" other = "NIC"
[Uptime] [Uptime]
other = "Uptime" other = "Uptime"
@@ -473,7 +473,7 @@ other = "Next check"
other = "Current Usage" other = "Current Usage"
[VerifyPassword] [VerifyPassword]
other = "Verify Password" other = "Please enter your password"
[LightMode] [LightMode]
other = "Light Mode" other = "Light Mode"
@@ -482,7 +482,7 @@ other = "Light Mode"
other = "Dark Mode" other = "Dark Mode"
[FollowSystem] [FollowSystem]
other = "Follow System" other = "System Auto"
[GridLayout] [GridLayout]
other = "Grid Layout" other = "Grid Layout"
@@ -619,6 +619,12 @@ other = "Enable Show in Service"
[EnableDDNS] [EnableDDNS]
other = "Enable DDNS" other = "Enable DDNS"
[EnableIPv4]
other = "Enable DDNS IPv4"
[EnableIpv6]
other = "Enable DDNS IPv6"
[DDNSDomain] [DDNSDomain]
other = "DDNS Domain" other = "DDNS Domain"
@@ -629,7 +635,7 @@ other = "Feature"
other = "Template" other = "Template"
[Stat] [Stat]
other = "Stat" other = "Asset"
[DisableSwitchTemplateInFrontend] [DisableSwitchTemplateInFrontend]
other = "Disable Switch Template in Frontend" other = "Disable Switch Template in Frontend"
+6
View File
@@ -619,6 +619,12 @@ other = "Mostrar en servicio"
[EnableDDNS] [EnableDDNS]
other = "Habilitar DDNS" other = "Habilitar DDNS"
[EnableIPv4]
other = "Habilitar DDNS IPv4"
[EnableIpv6]
other = "Habilitar DDNS IPv6"
[DDNSDomain] [DDNSDomain]
other = "Dominio DDNS" other = "Dominio DDNS"
+6
View File
@@ -619,6 +619,12 @@ other = "在服务中显示"
[EnableDDNS] [EnableDDNS]
other = "启用DDNS" other = "启用DDNS"
[EnableIPv4]
other = "启用DDNS IPv4"
[EnableIpv6]
other = "启用DDNS IPv6"
[DDNSDomain] [DDNSDomain]
other = "DDNS域名" other = "DDNS域名"
+6
View File
@@ -619,6 +619,12 @@ other = "在服務中顯示"
[EnableDDNS] [EnableDDNS]
other = "啟用DDNS" other = "啟用DDNS"
[EnableIPv4]
other = "啟用DDNS IPv4"
[EnableIpv6]
other = "啟用DDNS IPv6"
[DDNSDomain] [DDNSDomain]
other = "DDNS網域" other = "DDNS網域"
+10
View File
@@ -327,6 +327,16 @@ function addOrEditServer(server, conf) {
} else { } else {
modal.find(".ui.enableddns.checkbox").checkbox("set unchecked"); modal.find(".ui.enableddns.checkbox").checkbox("set unchecked");
} }
if (server && server.EnableIPv4) {
modal.find(".ui.enableipv4.checkbox").checkbox("set checked");
} else {
modal.find(".ui.enableipv4.checkbox").checkbox("set unchecked");
}
if (server && server.EnableIpv6) {
modal.find(".ui.enableipv6.checkbox").checkbox("set checked");
} else {
modal.find(".ui.enableipv6.checkbox").checkbox("set unchecked");
}
showFormModal(".server.modal", "#serverForm", "/api/server"); showFormModal(".server.modal", "#serverForm", "/api/server");
} }
+1 -1
View File
@@ -10,7 +10,7 @@
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script> <script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
<script src="/static/main.js?v20240224"></script> <script src="/static/main.js?v20240330"></script>
<script> <script>
(function () { (function () {
updateLang({{.LANG }}); updateLang({{.LANG }});
+12
View File
@@ -32,6 +32,18 @@
<label>{{tr "EnableDDNS"}}</label> <label>{{tr "EnableDDNS"}}</label>
</div> </div>
</div> </div>
<div class="field">
<div class="ui enableipv4 checkbox">
<input name="EnableIPv4" type="checkbox" tabindex="0" />
<label>{{tr "EnableIPv4"}}</label>
</div>
</div>
<div class="field">
<div class="ui enableipv6 checkbox">
<input name="EnableIpv6" type="checkbox" tabindex="0" />
<label>{{tr "EnableIpv6"}}</label>
</div>
</div>
<div class="field"> <div class="field">
<label>{{tr "DDNSDomain"}}</label> <label>{{tr "DDNSDomain"}}</label>
<input type="text" name="DDNSDomain" placeholder="{{tr "DDNSDomain"}}"> <input type="text" name="DDNSDomain" placeholder="{{tr "DDNSDomain"}}">
+4
View File
@@ -30,6 +30,8 @@
<th>{{tr "VersionNumber"}}</th> <th>{{tr "VersionNumber"}}</th>
<th>{{tr "HideForGuest"}}</th> <th>{{tr "HideForGuest"}}</th>
<th>{{tr "EnableDDNS"}}</th> <th>{{tr "EnableDDNS"}}</th>
<th>{{tr "EnableIPv4"}}</th>
<th>{{tr "EnableIpv6"}}</th>
<th>{{tr "DDNSDomain"}}</th> <th>{{tr "DDNSDomain"}}</th>
<th>{{tr "Secret"}}</th> <th>{{tr "Secret"}}</th>
<th>{{tr "OneKeyInstall"}}</th> <th>{{tr "OneKeyInstall"}}</th>
@@ -48,6 +50,8 @@
<td>{{$server.Host.Version}}</td> <td>{{$server.Host.Version}}</td>
<td>{{$server.HideForGuest}}</td> <td>{{$server.HideForGuest}}</td>
<td>{{$server.EnableDDNS}}</td> <td>{{$server.EnableDDNS}}</td>
<td>{{$server.EnableIPv4}}</td>
<td>{{$server.EnableIpv6}}</td>
<td>{{$server.DDNSDomain}}</td> <td>{{$server.DDNSDomain}}</td>
<td> <td>
<button class="ui icon green mini button" data-clipboard-text="{{$server.Secret}}" data-tooltip="{{tr "ClickToCopy"}}"> <button class="ui icon green mini button" data-clipboard-text="{{$server.Secret}}" data-tooltip="{{tr "ClickToCopy"}}">
+1 -1
View File
@@ -13,7 +13,7 @@
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script> <script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
<script src="/static/main.js?v20240224"></script> <script src="/static/main.js?v20240330"></script>
<script src="/static/theme-default/js/mixin.js?v20240302"></script> <script src="/static/theme-default/js/mixin.js?v20240302"></script>
<script> <script>
(function () { (function () {
+153 -128
View File
@@ -20,101 +20,101 @@
</head> </head>
<body data-theme="light" data-gridlist="grid"> <body data-theme="light" data-gridlist="grid">
<header> <header>
<section class="nav-bar clearfix"> <section class="nav-bar clearfix">
<figure class="logo"> <figure class="logo">
<a href="/"> <a href="/">
<img src="/static/logo.svg?v20210804" alt='{{tr "NezhaMonitoring"}}' width="50" height="50"> <img src="/static/logo.svg?v20210804" alt='{{tr "NezhaMonitoring"}}' width="50" height="50">
</a> </a>
<a href="/">{{.Conf.Site.Brand}}</a> <a href="/">{{.Conf.Site.Brand}}</a>
</figure> </figure>
<div class="icon-container"> <div class="icon-container">
<div class="row cf"> <div class="row cf">
<div class="three col"> <div class="three col">
<div class="hamburger" id="hamburger-icon"><span class="line"></span><span <div class="hamburger" id="hamburger-icon"><span class="line"></span><span
class="line"></span><span class="line"></span></div> class="line"></span><span class="line"></span></div>
</div>
</div>
</div>
<nav class="nav-menu">
<ul>
<li><a href="/">{{tr "Home"}}</a></li>
<li><a href="/service">{{tr "Services"}}</a></li>
<li><a href="/network">{{tr "NetworkSpiter"}}</a></li>
{{if .Admin}}
<li><a href="/server">{{tr "AdminPanel"}}</a></li>
{{else}}
<li><a href="/login">{{tr "Login"}}</a></li>
{{end}}
</ul>
</nav>
</section>
</header>
<main>
<div id="network">
<div class="server-info-container" v-for='server in servers' :id="server.ID">
<div class="info-body" @click="redirectNetwork(server.ID)">
<ul class="server-info-body-container">
<li>
<h3>@#server.Name#@</h3>
</li>
<li><img :src="'/static/theme-daynight/img/flag/'+(server.Host&&server.Host.CountryCode?server.Host.CountryCode.toUpperCase():'CN')+'.png'"
:title="server.Host.CountryCode.toUpperCase()" /></li>
</ul>
</div> </div>
</div> </div>
</div> </div>
<nav class="nav-menu"> <div class="network-chart" style="height: 800px;overflow: hidden">
<ul> <div id="monitor-info-container" style="height: 520px;max-width: 1400px">
<li><a href="/">{{tr "Home"}}</a></li>
<li><a href="/service">{{tr "Services"}}</a></li>
<li><a href="/network">{{tr "NetworkSpiter"}}</a></li>
{{if .Admin}}
<li><a href="/server">{{tr "AdminPanel"}}</a></li>
{{else}}
<li><a href="/login">{{tr "Login"}}</a></li>
{{end}}
</ul>
</nav>
</section>
</header>
<main>
<div id="network">
<div class="server-info-container" v-for='server in servers' :id="server.ID" style="font-size: .6em">
<div class="info-body" @click="redirectNetwork(server.ID)">
<ul class="server-info-body-container">
<li>
<h3>@#server.Name#@</h3>
</li>
<li><img :src="'/static/theme-daynight/img/flag/'+(server.Host&&server.Host.CountryCode?server.Host.CountryCode.toUpperCase():'CN')+'.png'"
:title="server.Host.CountryCode.toUpperCase()" /></li>
</ul>
</div> </div>
</div> </div>
</div> <div class="sidebar-container">
<div class="network-chart" style="height: 800px;overflow: hidden"> <ul>
<div id="monitor-info-container" style="height: 520px;max-width: 1400px"> <li><i class="fas fa-sun" title='{{tr "LightMode"}}'></i><span>{{tr "LightMode"}}</span></li>
<li><i class="fas fa-moon" title='{{tr "DarkMode"}}'></i><span>{{tr "DarkMode"}}</span></li>
<li><i class="fas fa-th" title='{{tr "GridLayout"}}'></i><span>{{tr "GridLayout"}}</span></li>
<li><i class="fas fa-list-ul" title='{{tr "ListLayout"}}'></i><span>{{tr "ListLayout"}}</span></li>
</ul>
</div> </div>
</div> </main>
<div class="sidebar-container">
<ul>
<li><i class="fas fa-sun" title='{{tr "LightMode"}}'></i><span>{{tr "LightMode"}}</span></li>
<li><i class="fas fa-moon" title='{{tr "DarkMode"}}'></i><span>{{tr "DarkMode"}}</span></li>
<li><i class="fas fa-th" title='{{tr "GridLayout"}}'></i><span>{{tr "GridLayout"}}</span></li>
<li><i class="fas fa-list-ul" title='{{tr "ListLayout"}}'></i><span>{{tr "ListLayout"}}</span></li>
</ul>
</div>
</main>
<section class="dark-light-toggle"> <section class="dark-light-toggle">
<label class="switcher"> <label class="switcher">
<input type="checkbox" name="theme" id="dark-light" /> <input type="checkbox" name="theme" id="dark-light" />
<div> <div>
<i class="fas fa-adjust"></i> <i class="fas fa-adjust"></i>
</div> </div>
</label> </label>
</section> </section>
<!-- Back to top button --> <!-- Back to top button -->
<a id="back-to-top"></a> <a id="back-to-top"></a>
<footer> <footer>
<div class="footer-container"> <div class="footer-container">
<div><a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "NezhaMonitoring"}} · {{.Version}}</a> <div><a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "NezhaMonitoring"}} ·
<p>&copy; <span id="copyright-date"> {{.Version}}</a>
<p>&copy; <span id="copyright-date">
<script>document.getElementById('copyright-date').appendChild(document.createTextNode(new Date().getFullYear()))</script> <script>document.getElementById('copyright-date').appendChild(document.createTextNode(new Date().getFullYear()))</script>
</span> · <a href="https://blog.jackiesung.com" target="_blank">Theme designed by Jackie Sung</a> </span> · <a href="https://blog.jackiesung.com" target="_blank">Theme designed by Jackie Sung</a>
</p> </p>
</div>
</div> </div>
</div> </footer>
</footer>
<script src="/static/theme-daynight/js/main.js?v202102012266"></script> <script src="/static/theme-daynight/js/main.js?v202102012266"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/limonte-sweetalert2/11.4.4/sweetalert2.all.min.js"></script> <script
src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/limonte-sweetalert2/11.4.4/sweetalert2.all.min.js"></script>
<script> <script>
const monitorInfo = JSON.parse('{{.MonitorInfos}}'); const monitorInfo = JSON.parse('{{.MonitorInfos}}');
const initData = JSON.parse('{{.Servers}}').servers; const initData = JSON.parse('{{.Servers}}').servers;
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}}; let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
if (MaxTCPPingValue == null) {
MaxTCPPingValue = 1000;
}
// 基于准备好的dom,初始化echarts实例 // 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('monitor-info-container')); const myChart = echarts.init(document.getElementById('monitor-info-container'));
// 使用刚指定的配置项和数据显示图表。 // 使用刚指定的配置项和数据显示图表。
var statusCards = new Vue({ var statusCards = new Vue({
el: '#network', el: '#network',
@@ -128,11 +128,11 @@
position: function (pt) { position: function (pt) {
return [pt[0], '10%']; return [pt[0], '10%'];
}, },
formatter: function(params){ formatter: function (params) {
let result = params[0].axisValueLabel + "<br />"; let result = params[0].axisValueLabel + "<br />";
params.forEach(function(item){ params.forEach(function (item) {
result += item.marker + item.seriesName + ": " + item.value[1].toFixed(2) + " ms<br />"; result += item.marker + item.seriesName + ": " + item.value[1].toFixed(2) + " ms<br />";
}) })
return result; return result;
}, },
confine: true, confine: true,
@@ -179,9 +179,9 @@
mounted() { mounted() {
this.DarkMode(); this.DarkMode();
this.parseMonitorInfo(monitorInfo); this.parseMonitorInfo(monitorInfo);
window.addEventListener('resize', this.resizeHandle); window.addEventListener('resize', this.resizeHandle);
}, },
destroyed () { destroyed() {
window.removeEventListener('resize', this.resizeHandle) window.removeEventListener('resize', this.resizeHandle)
}, },
methods: { methods: {
@@ -195,81 +195,106 @@
}, },
redirectNetwork(id) { redirectNetwork(id) {
this.getMonitorHistory(id) this.getMonitorHistory(id)
.then(function(monitorInfo) { .then(function (monitorInfo) {
var vm = network.__vue__; var vm = network.__vue__;
vm.parseMonitorInfo(monitorInfo); vm.parseMonitorInfo(monitorInfo);
}) })
.catch(function(error){ .catch(function (error) {
window.location.href = "/404"; window.location.href = "/404";
}) })
}, },
getMonitorHistory(id) { getMonitorHistory(id) {
return $.ajax({ return $.ajax({
url: "/api/v1/monitor/"+id, url: "/api/v1/monitor/" + id,
method: "GET" method: "GET"
}); });
}, },
parseMonitorInfo(monitorInfo) { parseMonitorInfo(monitorInfo) {
let tSeries = []; let tSeries = [];
let tLegendData = []; let tLegendData = [];
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
for (let i = 0; i < monitorInfo.result.length; i++) { for (let i = 0; i < monitorInfo.result.length; i++) {
var lcolor = lcolors[i % lcolors.length];
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
let loss = 0; let loss = 0;
let data = []; let data = [];
let datal = [];
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
avgDelay = monitorInfo.result[i].avg_delay[j]; avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
if (avgDelay > 0.9 * MaxTCPPingValue) { if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
loss += 1 data.push([monitorInfo.result[i].created_at[j], avgDelay]);
}
else {
loss += 1;
datal.push({
xAxis: monitorInfo.result[i].created_at[j],
label: { show: false },
emphasis: { disabled: true },
lineStyle: {
type: "solid",
color: rgbaColorBar
}
});
} }
data.push([monitorInfo.result[i].created_at[j], avgDelay]);
} }
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; if (lossRate > 99) {
datal = [];
}
legendName = monitorInfo.result[i].monitor_name + " " + lossRate + "%";
tLegendData.push(legendName); tLegendData.push(legendName);
tSeries.push({ tSeries.push({
name: legendName, name: legendName,
type: 'line', type: 'line',
smooth: true, smooth: true,
symbol: 'none', symbol: 'none',
data: data data: data,
markLine: {
symbol: "none",
symbolSize: 0,
data: datal
},
markPoint: {
data: [
{ type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
{ type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
]
}
}); });
} }
this.option.title.text = monitorInfo.result[0].server_name; this.option.title.text = monitorInfo.result[0].server_name;
this.option.series = tSeries; this.option.series = tSeries;
this.option.legend.data = tLegendData; this.option.legend.data = tLegendData;
const hour = new Date(Date.now()).getHours()
if (hour > 17 || hour < 4) {
this.option.legend.textStyle.color = "#F1F1F2";
this.option.title.textStyle.color = "#ccc";
}
myChart.clear(); myChart.clear();
myChart.setOption(this.option); myChart.setOption(this.option);
}, },
resizeHandle () { resizeHandle() {
this.myChart.resize(); myChart.resize();
}, },
} }
}); });
</script> </script>
</body> </body>
<style> <style>
#network { #network {
display: grid; width: calc(100vw - 6em);
/*grid-template-columns: repeat(5, 1fr);*/ max-width: 1400px;
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); margin: 1em auto;
grid-gap: 1em; }
width: 100%;
width: calc(100vw - 6em); #monitor-info-container {
max-width: 1400px; margin: 0em auto;
margin: 1em auto; align-content: start;
align-content: start; background-color: #F1F1F2;
} }
#monitor-info-container{
margin: 0em auto; .server-info-container {
align-content: start; font-size: .6em;
background-color: #F1F1F2; width: fit-content;
} display: inline-block;
}
</style> </style>
</html> </html>
{{end}} {{end}}
+1 -1
View File
@@ -15,7 +15,7 @@
<div v-for="server in group.data" :id="server.ID" class="ui card"> <div v-for="server in group.data" :id="server.ID" class="ui card">
<div class="content" v-if="server.Host" style="margin-top: 10px; padding-bottom: 5px"> <div class="content" v-if="server.Host" style="margin-top: 10px; padding-bottom: 5px">
<div class="header"> <div class="header">
<i :class="'fi fi-' + server.Host.CountryCode"></i>&nbsp;<i v-if='server.Host.Platform == "darwin"' <i style="width: 22px;border-radius: 4px;" :class="'fi fi-' + server.Host.CountryCode"></i>&nbsp;<i v-if='server.Host.Platform == "darwin"'
class="apple icon"></i><i v-else-if='isWindowsPlatform(server.Host.Platform)' class="apple icon"></i><i v-else-if='isWindowsPlatform(server.Host.Platform)'
class="windows icon"></i><i v-else :class="'fl-' + getFontLogoClass(server.Host.Platform)"></i> class="windows icon"></i><i v-else :class="'fl-' + getFontLogoClass(server.Host.Platform)"></i>
@#server.Name + (server.live?'':'[{{tr "Offline"}}]')#@ @#server.Name + (server.live?'':'[{{tr "Offline"}}]')#@
+28 -9
View File
@@ -28,9 +28,6 @@
const monitorInfo = JSON.parse('{{.MonitorInfos}}'); const monitorInfo = JSON.parse('{{.MonitorInfos}}');
const initData = JSON.parse('{{.Servers}}').servers; const initData = JSON.parse('{{.Servers}}').servers;
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}}; let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
if (MaxTCPPingValue == null) {
MaxTCPPingValue = 1000;
}
new Vue({ new Vue({
el: '#app', el: '#app',
delimiters: ['@#', '#@'], delimiters: ['@#', '#@'],
@@ -185,19 +182,36 @@
parseMonitorInfo(monitorInfo) { parseMonitorInfo(monitorInfo) {
let tSeries = []; let tSeries = [];
let tLegendData = []; let tLegendData = [];
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
for (let i = 0; i < monitorInfo.result.length; i++) { for (let i = 0; i < monitorInfo.result.length; i++) {
var lcolor = lcolors[i % lcolors.length];
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
let loss = 0; let loss = 0;
let data = []; let data = [];
let datal = [];
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
if (avgDelay > 0.9 * MaxTCPPingValue) { if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
loss += 1
}
if (avgDelay > 0) {
data.push([monitorInfo.result[i].created_at[j], avgDelay]); data.push([monitorInfo.result[i].created_at[j], avgDelay]);
} }
else {
loss += 1;
datal.push({
xAxis: monitorInfo.result[i].created_at[j],
label: { show: false },
emphasis: { disabled: true },
lineStyle: {
type: "solid",
color: rgbaColorBar
}
});
}
} }
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
if (lossRate > 99) {
datal = [];
}
legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
tLegendData.push(legendName); tLegendData.push(legendName);
tSeries.push({ tSeries.push({
@@ -206,10 +220,15 @@
smooth: true, smooth: true,
symbol: 'none', symbol: 'none',
data: data, data: data,
markLine: {
symbol: "none",
symbolSize :0,
data: datal
},
markPoint: { markPoint: {
data: [ data: [
{ type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } }, { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
{ type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } } { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
] ]
} }
}); });
+29 -10
View File
@@ -55,9 +55,6 @@
const monitorInfo = JSON.parse('{{.MonitorInfos}}'); const monitorInfo = JSON.parse('{{.MonitorInfos}}');
const initData = JSON.parse('{{.Servers}}').servers; const initData = JSON.parse('{{.Servers}}').servers;
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}}; let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
if (MaxTCPPingValue == null) {
MaxTCPPingValue = 1000;
}
new Vue({ new Vue({
el: '#app', el: '#app',
delimiters: ['@#', '#@'], delimiters: ['@#', '#@'],
@@ -208,19 +205,36 @@
parseMonitorInfo(monitorInfo) { parseMonitorInfo(monitorInfo) {
let tSeries = []; let tSeries = [];
let tLegendData = []; let tLegendData = [];
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
for (let i = 0; i < monitorInfo.result.length; i++) { for (let i = 0; i < monitorInfo.result.length; i++) {
var lcolor = lcolors[i % lcolors.length];
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
let loss = 0; let loss = 0;
let data = []; let data = [];
let datal = [];
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
if (avgDelay > 0.9 * MaxTCPPingValue) { if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
loss += 1
}
if (avgDelay > 0) {
data.push([monitorInfo.result[i].created_at[j], avgDelay]); data.push([monitorInfo.result[i].created_at[j], avgDelay]);
} }
else {
loss += 1;
datal.push({
xAxis: monitorInfo.result[i].created_at[j],
label: { show: false },
emphasis: { disabled: true },
lineStyle: {
type: "solid",
color: rgbaColorBar
}
});
}
} }
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
if (lossRate > 99) {
datal = [];
}
legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
tLegendData.push(legendName); tLegendData.push(legendName);
tSeries.push({ tSeries.push({
@@ -229,10 +243,15 @@
smooth: true, smooth: true,
symbol: 'none', symbol: 'none',
data: data, data: data,
markLine: {
symbol: "none",
symbolSize :0,
data: datal
},
markPoint: { markPoint: {
data: [ data: [
{ type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } }, { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
{ type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } } { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
] ]
} }
}); });
+28 -9
View File
@@ -22,9 +22,6 @@
const monitorInfo = JSON.parse('{{.MonitorInfos}}'); const monitorInfo = JSON.parse('{{.MonitorInfos}}');
const initData = JSON.parse('{{.Servers}}').servers; const initData = JSON.parse('{{.Servers}}').servers;
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}}; let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
if (MaxTCPPingValue == null) {
MaxTCPPingValue = 1000;
}
new Vue({ new Vue({
el: '#app', el: '#app',
delimiters: ['@#', '#@'], delimiters: ['@#', '#@'],
@@ -171,19 +168,36 @@
parseMonitorInfo(monitorInfo) { parseMonitorInfo(monitorInfo) {
let tSeries = []; let tSeries = [];
let tLegendData = []; let tLegendData = [];
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
for (let i = 0; i < monitorInfo.result.length; i++) { for (let i = 0; i < monitorInfo.result.length; i++) {
var lcolor = lcolors[i % lcolors.length];
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
let loss = 0; let loss = 0;
let data = []; let data = [];
let datal = [];
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
if (avgDelay > 0.9 * MaxTCPPingValue) { if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
loss += 1
}
if (avgDelay > 0) {
data.push([monitorInfo.result[i].created_at[j], avgDelay]); data.push([monitorInfo.result[i].created_at[j], avgDelay]);
} }
else {
loss += 1;
datal.push({
xAxis: monitorInfo.result[i].created_at[j],
label: { show: false },
emphasis: { disabled: true },
lineStyle: {
type: "solid",
color: rgbaColorBar
}
});
}
} }
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
if (lossRate > 99) {
datal = [];
}
legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
tLegendData.push(legendName); tLegendData.push(legendName);
tSeries.push({ tSeries.push({
@@ -192,10 +206,15 @@
smooth: true, smooth: true,
symbol: 'none', symbol: 'none',
data: data, data: data,
markLine: {
symbol: "none",
symbolSize :0,
data: datal
},
markPoint: { markPoint: {
data: [ data: [
{ type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } }, { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
{ type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } } { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
] ]
} }
}); });
+208 -452
View File
@@ -14,7 +14,7 @@ NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent" NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent"
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service" NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard" NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
NZ_VERSION="v0.15.9" NZ_VERSION="v0.16.0"
red='\033[0;31m' red='\033[0;31m'
green='\033[0;32m' green='\033[0;32m'
@@ -100,22 +100,64 @@ pre_check() {
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard" Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
fi fi
fi fi
} }
confirm() { installation_check() {
if [[ $# > 1 ]]; then if docker compose version >/dev/null 2>&1; then
echo && read -e -p "$1 [默认$2]: " temp DOCKER_COMPOSE_COMMAND="docker compose"
if [[ x"${temp}" == x"" ]]; then if $DOCKER_COMPOSE_COMMAND ls | grep -qw "$NZ_DASHBOARD_PATH/docker-compose.yaml" >/dev/null 2>&1; then
temp=$2 NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
if [ -n "$NEZHA_IMAGES" ]; then
echo "存在带有 nezha-dashboard 仓库的 Docker 镜像:"
echo "$NEZHA_IMAGES"
IS_DOCKER_NEZHA=1
FRESH_INSTALL=0
return
else
echo "未找到带有 nezha-dashboard 仓库的 Docker 镜像。"
fi
fi
elif command -v docker-compose >/dev/null 2>&1; then
DOCKER_COMPOSE_COMMAND="docker-compose"
if $DOCKER_COMPOSE_COMMAND -f "$NZ_DASHBOARD_PATH/docker-compose.yaml" config >/dev/null 2>&1; then
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
if [ -n "$NEZHA_IMAGES" ]; then
echo "存在带有 nezha-dashboard 仓库的 Docker 镜像:"
echo "$NEZHA_IMAGES"
IS_DOCKER_NEZHA=1
FRESH_INSTALL=0
return
else
echo "未找到带有 nezha-dashboard 仓库的 Docker 镜像。"
fi
fi fi
else
read -e -p "$1 [y/n]: " temp
fi fi
if [[ x"${temp}" == x"y" || x"${temp}" == x"Y" ]]; then
return 0 if [[ -f $NZ_DASHBOARD_PATH/app ]]; then
else IS_DOCKER_NEZHA=0
return 1 FRESH_INSTALL=0
fi
}
select_version() {
if [[ -z $IS_DOCKER_NEZHA ]]; then
echo -e "${yellow}请自行选择您的安装方式(如果你是安装Agent,输入哪个都是一样的):\n1. Docker\n2. 独立安装${plain}"
while true; do
read -e -r -p "请输入选择 [1-2]" option
case "${option}" in
1)
IS_DOCKER_NEZHA=1
break
;;
2)
IS_DOCKER_NEZHA=0
break
;;
*)
echo "${red}请输入正确的数字 [1-2]${plain}"
;;
esac
done
fi fi
} }
@@ -186,7 +228,7 @@ install_dashboard() {
echo -e "> 安装面板" echo -e "> 安装面板"
# 哪吒监控文件夹 # 哪吒监控文件夹
if [ ! -d "${NZ_DASHBOARD_PATH}/docker-compose.yaml" ]; then if [[ ! $FRESH_INSTALL == 0 ]]; then
mkdir -p $NZ_DASHBOARD_PATH mkdir -p $NZ_DASHBOARD_PATH
else else
echo "您可能已经安装过面板端,重复安装会覆盖数据,请注意备份。" echo "您可能已经安装过面板端,重复安装会覆盖数据,请注意备份。"
@@ -208,17 +250,10 @@ install_dashboard() {
chmod 777 -R $NZ_DASHBOARD_PATH chmod 777 -R $NZ_DASHBOARD_PATH
command -v docker >/dev/null 2>&1 if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? != 0 ]]; then install_dashboard_docker
echo -e "正在安装 Docker" elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1 install_dashboard_standalone
if [[ $? != 0 ]]; then
echo -e "${red}下载脚本失败,请检查本机能否连接 ${Get_Docker_URL}${plain}"
return 0
fi
systemctl enable docker.service
systemctl start docker.service
echo -e "${green}Docker${plain} 安装成功"
fi fi
modify_dashboard_config 0 modify_dashboard_config 0
@@ -228,43 +263,34 @@ install_dashboard() {
fi fi
} }
install_dashboard_standalone() { install_dashboard_docker() {
install_base if [[ ! $FRESH_INSTALL == 0 ]]; then
command -v docker >/dev/null 2>&1
echo -e "> 安装面板" if [[ $? != 0 ]]; then
echo -e "正在安装 Docker"
# 哪吒监控文件夹 if [ "$os_alpine" != 1 ]; then
if [ ! -d "${NZ_DASHBOARD_PATH}/app" ]; then bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1
mkdir -p $NZ_DASHBOARD_PATH if [[ $? != 0 ]]; then
else echo -e "${red}下载脚本失败,请检查本机能否连接 ${Get_Docker_URL}${plain}"
echo "您可能已经安装过面板端,重复安装会覆盖数据,请注意备份。" return 0
read -e -r -p "是否退出安装? [Y/n] " input fi
case $input in systemctl enable docker.service
[yY][eE][sS] | [yY]) systemctl start docker.service
echo "退出安装" else
exit 0 apk add docker docker-compose >/dev/null 2>&1
;; rc-update add docker
[nN][oO] | [nN]) rc-service docker start
echo "继续安装" fi
;; echo -e "${green}Docker${plain} 安装成功"
*) installation_check
echo "退出安装" fi
exit 0
;;
esac
fi fi
}
install_dashboard_standalone() {
if [ ! -d "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" ] || [ ! -d "${NZ_DASHBOARD_PATH}/resource/static/custom" ]; then if [ ! -d "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" ] || [ ! -d "${NZ_DASHBOARD_PATH}/resource/static/custom" ]; then
mkdir -p "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" "${NZ_DASHBOARD_PATH}/resource/static/custom" >/dev/null 2>&1 mkdir -p "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" "${NZ_DASHBOARD_PATH}/resource/static/custom" >/dev/null 2>&1
fi fi
chmod 777 -R $NZ_DASHBOARD_PATH
modify_dashboard_config_standalone 0
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
selinux() { selinux() {
@@ -404,134 +430,85 @@ modify_agent_config() {
modify_dashboard_config() { modify_dashboard_config() {
echo -e "> 修改面板配置" echo -e "> 修改面板配置"
echo -e "正在下载 Docker 脚本" if [[ $IS_DOCKER_NEZHA == 1 ]]; then
wget -t 2 -T 10 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1 echo -e "正在下载 Docker 脚本"
if [[ $? != 0 ]]; then wget -t 2 -T 10 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1
echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0
fi
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0
fi
echo "关于 GitHub Oauth2 应用:在 https://github.com/settings/developers 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
echo "关于 Gitee Oauth2 应用:在 https://gitee.com/oauth/applications 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
read -ep "请输入 OAuth2 提供商(github/gitlab/jihulab/gitee,默认 github): " nz_oauth2_type &&
read -ep "请输入 Oauth2 应用的 Client ID: " nz_github_oauth_client_id &&
read -ep "请输入 Oauth2 应用的 Client Secret: " nz_github_oauth_client_secret &&
read -ep "请输入 GitHub/Gitee 登录名作为管理员,多个以逗号隔开: " nz_admin_logins &&
read -ep "请输入站点标题: " nz_site_title &&
read -ep "请输入站点访问端口: (默认 8008)" nz_site_port &&
read -ep "请输入用于 Agent 接入的 RPC 端口: (默认 5555)" nz_grpc_port
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
echo -e "${red}所有选项都不能为空${plain}"
before_show_menu
return 1
fi
if [[ -z "${nz_site_port}" ]]; then
nz_site_port=8008
fi
if [[ -z "${nz_grpc_port}" ]]; then
nz_grpc_port=5555
fi
if [[ -z "${nz_oauth2_type}" ]]; then
nz_oauth2_type=github
fi
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" /tmp/nezha-config.yaml
sed -i "s/nz_admin_logins/${nz_admin_logins}/" /tmp/nezha-config.yaml
sed -i "s/nz_grpc_port/${nz_grpc_port}/" /tmp/nezha-config.yaml
sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" /tmp/nezha-config.yaml
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
sed -i "s/nz_site_port/${nz_site_port}/" /tmp/nezha-docker-compose.yaml
sed -i "s/nz_grpc_port/${nz_grpc_port}/g" /tmp/nezha-docker-compose.yaml
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
mkdir -p $NZ_DASHBOARD_PATH/data
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
mv -f /tmp/nezha-docker-compose.yaml ${NZ_DASHBOARD_PATH}/docker-compose.yaml
echo -e "面板配置 ${green}修改成功,请稍等重启生效${plain}"
restart_and_update
if [[ $# == 0 ]]; then
before_show_menu
fi
}
modify_dashboard_config_standalone() {
echo -e "> 修改面板配置"
echo -e "正在下载配置模板"
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "${red}下载文件失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0
fi
echo "关于 GitHub Oauth2 应用:在 https://github.com/settings/developers 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
echo "关于 Gitee Oauth2 应用:在 https://gitee.com/oauth/applications 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
read -ep "请输入 OAuth2 提供商(github/gitlab/jihulab/gitee,默认 github): " nz_oauth2_type &&
read -ep "请输入 Oauth2 应用的 Client ID: " nz_github_oauth_client_id &&
read -ep "请输入 Oauth2 应用的 Client Secret: " nz_github_oauth_client_secret &&
read -ep "请输入 GitHub/Gitee 登录名作为管理员,多个以逗号隔开: " nz_admin_logins &&
read -ep "请输入站点标题: " nz_site_title &&
read -ep "请输入站点访问端口: (默认 8008)" nz_site_port &&
read -ep "请输入用于 Agent 接入的 RPC 端口: (默认 5555)" nz_grpc_port
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
echo -e "${red}所有选项都不能为空${plain}"
before_show_menu
return 1
fi
if [[ -z "${nz_site_port}" ]]; then
nz_site_port=8008
fi
if [[ -z "${nz_grpc_port}" ]]; then
nz_grpc_port=5555
fi
if [[ -z "${nz_oauth2_type}" ]]; then
nz_oauth2_type=github
fi
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" /tmp/nezha-config.yaml
sed -i "s/nz_admin_logins/${nz_admin_logins}/" /tmp/nezha-config.yaml
sed -i "s/nz_grpc_port/${nz_grpc_port}/" /tmp/nezha-config.yaml
sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" /tmp/nezha-config.yaml
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
mkdir -p $NZ_DASHBOARD_PATH/data
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
echo -e "正在下载服务文件"
if [ "$os_alpine" != 1 ]; then
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
else
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
chmod +x $NZ_DASHBOARD_SERVICERC
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}" echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0 return 0
fi fi
fi fi
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0
fi
echo "关于 GitHub Oauth2 应用:在 https://github.com/settings/developers 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
echo "关于 Gitee Oauth2 应用:在 https://gitee.com/oauth/applications 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
read -ep "请输入 OAuth2 提供商(github/gitlab/jihulab/gitee,默认 github): " nz_oauth2_type &&
read -ep "请输入 Oauth2 应用的 Client ID: " nz_github_oauth_client_id &&
read -ep "请输入 Oauth2 应用的 Client Secret: " nz_github_oauth_client_secret &&
read -ep "请输入 GitHub/Gitee 登录名作为管理员,多个以逗号隔开: " nz_admin_logins &&
read -ep "请输入站点标题: " nz_site_title &&
read -ep "请输入站点访问端口: (默认 8008)" nz_site_port &&
read -ep "请输入用于 Agent 接入的 RPC 端口: (默认 5555)" nz_grpc_port
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
echo -e "${red}所有选项都不能为空${plain}"
before_show_menu
return 1
fi
if [[ -z "${nz_site_port}" ]]; then
nz_site_port=8008
fi
if [[ -z "${nz_grpc_port}" ]]; then
nz_grpc_port=5555
fi
if [[ -z "${nz_oauth2_type}" ]]; then
nz_oauth2_type=github
fi
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" /tmp/nezha-config.yaml
sed -i "s/nz_admin_logins/${nz_admin_logins}/" /tmp/nezha-config.yaml
sed -i "s/nz_grpc_port/${nz_grpc_port}/" /tmp/nezha-config.yaml
sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" /tmp/nezha-config.yaml
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
sed -i "s/nz_site_port/${nz_site_port}/" /tmp/nezha-docker-compose.yaml
sed -i "s/nz_grpc_port/${nz_grpc_port}/g" /tmp/nezha-docker-compose.yaml
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
fi
mkdir -p $NZ_DASHBOARD_PATH/data
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
mv -f /tmp/nezha-docker-compose.yaml ${NZ_DASHBOARD_PATH}/docker-compose.yaml
fi
if [[ $IS_DOCKER_NEZHA == 0 ]]; then
echo -e "正在下载服务文件"
if [ "$os_alpine" != 1 ]; then
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
else
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
chmod +x $NZ_DASHBOARD_SERVICERC
if [[ $? != 0 ]]; then
echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0
fi
fi
fi
echo -e "面板配置 ${green}修改成功,请稍等重启生效${plain}" echo -e "面板配置 ${green}修改成功,请稍等重启生效${plain}"
restart_and_update_standalone restart_and_update
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
before_show_menu before_show_menu
@@ -543,15 +520,10 @@ restart_and_update() {
cd $NZ_DASHBOARD_PATH cd $NZ_DASHBOARD_PATH
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then restart_and_update_docker
docker compose pull elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
docker compose down restart_and_update_standalone
docker compose up -d
else
docker-compose pull
docker-compose down
docker-compose up -d
fi fi
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@@ -566,11 +538,13 @@ restart_and_update() {
fi fi
} }
restart_and_update_docker() {
$DOCKER_COMPOSE_COMMAND pull
$DOCKER_COMPOSE_COMMAND down
$DOCKER_COMPOSE_COMMAND up -d
}
restart_and_update_standalone() { restart_and_update_standalone() {
echo -e "> 重启并更新面板"
cd $NZ_DASHBOARD_PATH
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
systemctl stop nezha-dashboard systemctl stop nezha-dashboard
else else
@@ -587,27 +561,15 @@ restart_and_update_standalone() {
rc-update add nezha-dashboard rc-update add nezha-dashboard
rc-service nezha-dashboard restart rc-service nezha-dashboard restart
fi fi
if [[ $? == 0 ]]; then
echo -e "${green}哪吒监控 重启成功${plain}"
echo -e "默认管理面板地址:${yellow}域名:站点访问端口${plain}"
else
echo -e "${red}重启失败,可能是因为启动时间超过了两秒,请稍后查看日志信息${plain}"
fi
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
start_dashboard() { start_dashboard() {
echo -e "> 启动面板" echo -e "> 启动面板"
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then start_dashboard_docker
cd $NZ_DASHBOARD_PATH && docker compose up -d elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
else start_dashboard_standalone
cd $NZ_DASHBOARD_PATH && docker-compose up -d
fi fi
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@@ -621,34 +583,25 @@ start_dashboard() {
fi fi
} }
start_dashboard_standalone() { start_dashboard_docker() {
echo -e "> 启动面板" cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND up -d
}
start_dashboard_standalone() {
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
systemctl start nezha-dashboard systemctl start nezha-dashboard
else else
rc-service nezha-dashboard start rc-service nezha-dashboard start
fi fi
if [[ $? == 0 ]]; then
echo -e "${green}哪吒监控 启动成功${plain}"
else
echo -e "${red}启动失败,请稍后查看日志信息${plain}"
fi
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
stop_dashboard() { stop_dashboard() {
echo -e "> 停止面板" echo -e "> 停止面板"
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then stop_dashboard_docker
cd $NZ_DASHBOARD_PATH && docker compose down elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
else stop_dashboard_standalone
cd $NZ_DASHBOARD_PATH && docker-compose down
fi fi
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@@ -662,34 +615,25 @@ stop_dashboard() {
fi fi
} }
stop_dashboard_standalone() { stop_dashboard_docker() {
echo -e "> 停止面板" cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND down
}
stop_dashboard_standalone() {
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
systemctl stop nezha-dashboard systemctl stop nezha-dashboard
else else
rc-service nezha-dashboard stop rc-service nezha-dashboard stop
fi fi
if [[ $? == 0 ]]; then
echo -e "${green}哪吒监控 停止成功${plain}"
else
echo -e "${red}停止失败,请稍后查看日志信息${plain}"
fi
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
show_dashboard_log() { show_dashboard_log() {
echo -e "> 获取面板日志" echo -e "> 获取面板日志"
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then show_dashboard_log_docker
cd $NZ_DASHBOARD_PATH && docker compose logs -f elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
else show_dashboard_log_standalone
cd $NZ_DASHBOARD_PATH && docker-compose logs -f
fi fi
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@@ -697,33 +641,27 @@ show_dashboard_log() {
fi fi
} }
show_dashboard_log_standalone() { show_dashboard_log_docker() {
echo -e "> 获取面板日志" cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND logs -f
}
show_dashboard_log_standalone() {
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
journalctl -xf -u nezha-dashboard.service journalctl -xf -u nezha-dashboard.service
else else
echo "很抱歉,OpenRC 无此功能" tail -n 10 /var/log/nezha-dashboard.err
fi
if [[ $# == 0 ]]; then
before_show_menu
fi fi
} }
uninstall_dashboard() { uninstall_dashboard() {
echo -e "> 卸载管理面板" echo -e "> 卸载管理面板"
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then uninstall_dashboard_docker
cd $NZ_DASHBOARD_PATH && docker compose down elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
else uninstall_dashboard_standalone
cd $NZ_DASHBOARD_PATH && docker-compose down
fi fi
rm -rf $NZ_DASHBOARD_PATH
docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
clean_all clean_all
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@@ -731,9 +669,14 @@ uninstall_dashboard() {
fi fi
} }
uninstall_dashboard_standalone() { uninstall_dashboard_docker() {
echo -e "> 卸载管理面板" cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND down
rm -rf $NZ_DASHBOARD_PATH
docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
}
uninstall_dashboard_standalone() {
rm -rf $NZ_DASHBOARD_PATH rm -rf $NZ_DASHBOARD_PATH
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
@@ -747,12 +690,6 @@ uninstall_dashboard_standalone() {
else else
rm $NZ_DASHBOARD_SERVICERC rm $NZ_DASHBOARD_SERVICERC
fi fi
clean_all
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
show_agent_log() { show_agent_log() {
@@ -761,7 +698,7 @@ show_agent_log() {
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
journalctl -xf -u nezha-agent.service journalctl -xf -u nezha-agent.service
else else
echo "很抱歉,OpenRC 无此功能" tail -n 10 /var/log/nezha-agent.err
fi fi
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@@ -811,59 +748,6 @@ clean_all() {
fi fi
} }
select_version() {
DOCKER_COMPOSE_COMMAND=""
if docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE_COMMAND="docker compose"
if $DOCKER_COMPOSE_COMMAND ls | grep -qw "$NZ_DASHBOARD_PATH/docker-compose.yaml" >/dev/null 2>&1; then
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
if [ -n "$NEZHA_IMAGES" ]; then
echo "存在带有 nezha-dashboard 仓库的 Docker 镜像:"
echo "$NEZHA_IMAGES"
IS_DOCKER_NEZHA=1
return
else
echo "未找到带有 nezha-dashboard 仓库的 Docker 镜像。"
fi
fi
elif command -v docker-compose >/dev/null 2>&1; then
DOCKER_COMPOSE_COMMAND="docker-compose"
if $DOCKER_COMPOSE_COMMAND -f "$NZ_DASHBOARD_PATH/docker-compose.yaml" config >/dev/null 2>&1; then
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
if [ -n "$NEZHA_IMAGES" ]; then
echo "存在带有 nezha-dashboard 仓库的 Docker 镜像:"
echo "$NEZHA_IMAGES"
IS_DOCKER_NEZHA=1
return
else
echo "未找到带有 nezha-dashboard 仓库的 Docker 镜像。"
fi
fi
fi
if [[ -f $NZ_DASHBOARD_PATH/app ]]; then
IS_DOCKER_NEZHA=0
else
echo -e "${yellow}请自行选择您的安装方式(如果你是安装Agent,输入哪个都是一样的):\n1. Docker\n2. 独立安装${plain}"
while true; do
read -e -r -p "请输入数字 [1-2]" option
case "${option}" in
1)
IS_DOCKER_NEZHA=1
break
;;
2)
IS_DOCKER_NEZHA=0
break
;;
*)
echo "输入有误,请重新输入"
;;
esac
done
fi
}
show_usage() { show_usage() {
echo "哪吒监控 管理脚本使用方法: " echo "哪吒监控 管理脚本使用方法: "
echo "--------------------------------------------------------" echo "--------------------------------------------------------"
@@ -908,8 +792,7 @@ show_menu() {
${green}0.${plain} 退出脚本 ${green}0.${plain} 退出脚本
" "
echo && read -ep "请输入选择 [0-13]: " num echo && read -ep "请输入选择 [0-13]: " num
if [[ $IS_DOCKER_NEZHA == 1 ]]; then case "${num}" in
case "${num}" in
0) 0)
exit 0 exit 0
;; ;;
@@ -955,65 +838,14 @@ show_menu() {
*) *)
echo -e "${red}请输入正确的数字 [0-13]${plain}" echo -e "${red}请输入正确的数字 [0-13]${plain}"
;; ;;
esac esac
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
case "${num}" in
0)
exit 0
;;
1)
install_dashboard_standalone
;;
2)
modify_dashboard_config_standalone
;;
3)
start_dashboard_standalone
;;
4)
stop_dashboard_standalone
;;
5)
restart_and_update_standalone
;;
6)
show_dashboard_log_standalone
;;
7)
uninstall_dashboard_standalone
;;
8)
install_agent
;;
9)
modify_agent_config
;;
10)
show_agent_log
;;
11)
uninstall_agent
;;
12)
restart_agent
;;
13)
update_script
;;
*)
echo -e "${red}请输入正确的数字 [0-13]${plain}"
;;
esac
else
select_version
fi
} }
pre_check pre_check
installation_check
if [[ $# > 0 ]]; then if [[ $# > 0 ]]; then
if [[ $IS_DOCKER_NEZHA == 1 ]]; then case $1 in
case $1 in
"install_dashboard") "install_dashboard")
install_dashboard 0 install_dashboard 0
;; ;;
@@ -1059,84 +891,8 @@ if [[ $# > 0 ]]; then
update_script 0 update_script 0
;; ;;
*) show_usage ;; *) show_usage ;;
esac esac
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
case $1 in
"install_dashboard")
install_dashboard_standalone 0
;;
"modify_dashboard_config")
modify_dashboard_config_standalone 0
;;
"start_dashboard")
start_dashboard_standalone 0
;;
"stop_dashboard")
stop_dashboard_standalone 0
;;
"restart_and_update")
restart_and_update_standalone 0
;;
"show_dashboard_log")
show_dashboard_log_standalone 0
;;
"uninstall_dashboard")
uninstall_dashboard_standalone 0
;;
"install_agent")
shift
if [ $# -ge 3 ]; then
install_agent "$@"
else
install_agent 0
fi
;;
"modify_agent_config")
modify_agent_config 0
;;
"show_agent_log")
show_agent_log 0
;;
"uninstall_agent")
uninstall_agent 0
;;
"restart_agent")
restart_agent 0
;;
"update_script")
update_script 0
;;
*) show_usage ;;
esac
else
case $1 in
"install_agent")
shift
if [ $# -ge 3 ]; then
install_agent "$@"
else
install_agent 0
fi
;;
"modify_agent_config")
modify_agent_config 0
;;
"show_agent_log")
show_agent_log 0
;;
"uninstall_agent")
uninstall_agent 0
;;
"restart_agent")
restart_agent 0
;;
"update_script")
update_script 0
;;
*) show_usage ;;
esac
fi
else else
select_version select_version
show_menu show_menu
fi fi
+162 -405
View File
@@ -14,7 +14,7 @@ NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent" NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent"
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service" NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard" NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
NZ_VERSION="v0.15.9" NZ_VERSION="v0.16.0"
red='\033[0;31m' red='\033[0;31m'
green='\033[0;32m' green='\033[0;32m'
@@ -101,19 +101,60 @@ pre_check() {
fi fi
} }
confirm() { installation_check() {
if [[ $# > 1 ]]; then if docker compose version >/dev/null 2>&1; then
echo && read -e -p "$1 [默认$2]: " temp DOCKER_COMPOSE_COMMAND="docker compose"
if [[ x"${temp}" == x"" ]]; then if $DOCKER_COMPOSE_COMMAND ls | grep -qw "$NZ_DASHBOARD_PATH/docker-compose.yaml" >/dev/null 2>&1; then
temp=$2 NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
if [ -n "$NEZHA_IMAGES" ]; then
echo "Docker image with nezha-dashboard repository exists:"
echo "$NEZHA_IMAGES"
IS_DOCKER_NEZHA=1
return
else
echo "No Docker images with the nezha-dashboard repository were found."
fi
fi
elif command -v docker-compose >/dev/null 2>&1; then
DOCKER_COMPOSE_COMMAND="docker-compose"
if $DOCKER_COMPOSE_COMMAND -f "$NZ_DASHBOARD_PATH/docker-compose.yaml" config >/dev/null 2>&1; then
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
if [ -n "$NEZHA_IMAGES" ]; then
echo "Docker image with nezha-dashboard repository exists:"
echo "$NEZHA_IMAGES"
IS_DOCKER_NEZHA=1
return
else
echo "No Docker images with the nezha-dashboard repository were found."
fi
fi fi
else
read -e -p "$1 [y/n]: " temp
fi fi
if [[ x"${temp}" == x"y" || x"${temp}" == x"Y" ]]; then
return 0 if [[ -f $NZ_DASHBOARD_PATH/app ]]; then
else IS_DOCKER_NEZHA=0
return 1 FRESH_INSTALL=0
fi
}
select_version() {
if [[ -z $IS_DOCKER_NEZHA ]]; then
echo -e "${yellow}Select your installation method(Input anything is ok if you are installing agent):\n1. Docker\n2. Standalone${plain}"
while true; do
read -e -r -p "Please enter [1-2]: " option
case "${option}" in
1)
IS_DOCKER_NEZHA=1
break
;;
2)
IS_DOCKER_NEZHA=0
break
;;
*)
echo "${red}Please enter the correct number [1-2]${plain}"
;;
esac
done
fi fi
} }
@@ -184,7 +225,7 @@ install_dashboard() {
echo -e "> Install Panel" echo -e "> Install Panel"
# Nezha Monitoring Folder # Nezha Monitoring Folder
if [ ! -d "${NZ_DASHBOARD_PATH}/docker-compose.yaml" ]; then if [[ ! $FRESH_INSTALL == 0 ]]; then
mkdir -p $NZ_DASHBOARD_PATH mkdir -p $NZ_DASHBOARD_PATH
else else
echo "You may have already installed the dashboard, repeated installation will overwrite the data, please pay attention to backup." echo "You may have already installed the dashboard, repeated installation will overwrite the data, please pay attention to backup."
@@ -205,17 +246,10 @@ install_dashboard() {
fi fi
chmod 777 -R $NZ_DASHBOARD_PATH chmod 777 -R $NZ_DASHBOARD_PATH
command -v docker >/dev/null 2>&1 if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? != 0 ]]; then install_dashboard_docker
echo -e "Installing Docker" elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1 install_dashboard_standalone
if [[ $? != 0 ]]; then
echo -e "${red}Script failed to get, please check if the network can link ${Get_Docker_URL}${plain}"
return 0
fi
systemctl enable docker.service
systemctl start docker.service
echo -e "${green}Docker${plain} installed successfully"
fi fi
modify_dashboard_config 0 modify_dashboard_config 0
@@ -225,43 +259,34 @@ install_dashboard() {
fi fi
} }
install_dashboard_standalone() { install_dashboard_docker() {
install_base if [[ ! $FRESH_INSTALL == 0 ]]; then
command -v docker >/dev/null 2>&1
echo -e "> Install Panel" if [[ $? != 0 ]]; then
echo -e "Installing Docker"
# Nezha Monitoring Folder if [ "$os_alpine" != 1 ]; then
if [ ! -d "${NZ_DASHBOARD_PATH}/app" ]; then bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1
mkdir -p $NZ_DASHBOARD_PATH if [[ $? != 0 ]]; then
else echo -e "${red}Script failed to get, please check if the network can link ${Get_Docker_URL}${plain}"
echo "You may have already installed the dashboard, repeated installation will overwrite the data, please pay attention to backup." return 0
read -e -r -p "Exit the installation? [Y/n] " input fi
case $input in systemctl enable docker.service
[yY][eE][sS] | [yY]) systemctl start docker.service
echo "Exit the installation." else
exit 0 apk add docker docker-compose >/dev/null 2>&1
;; rc-update add docker
[nN][oO] | [nN]) rc-service docker start
echo "Continue." fi
;; echo -e "${green}Docker${plain} installed successfully"
*) installation_check
echo "Exit the installation." fi
exit 0
;;
esac
fi fi
}
install_dashboard_standalone() {
if [ ! -d "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" ] || [ ! -d "${NZ_DASHBOARD_PATH}/resource/static/custom" ]; then if [ ! -d "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" ] || [ ! -d "${NZ_DASHBOARD_PATH}/resource/static/custom" ]; then
mkdir -p "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" "${NZ_DASHBOARD_PATH}/resource/static/custom" >/dev/null 2>&1 mkdir -p "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" "${NZ_DASHBOARD_PATH}/resource/static/custom" >/dev/null 2>&1
fi fi
chmod 777 -R $NZ_DASHBOARD_PATH
modify_dashboard_config_standalone 0
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
selinux() { selinux() {
@@ -401,11 +426,13 @@ modify_agent_config() {
modify_dashboard_config() { modify_dashboard_config() {
echo -e "> Modify Panel Configuration" echo -e "> Modify Panel Configuration"
echo -e "Download Docker Script" if [[ $IS_DOCKER_NEZHA == 1 ]]; then
wget -t 2 -T 10 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1 echo -e "Download Docker Script"
if [[ $? != 0 ]]; then wget -t 2 -T 10 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1
echo -e "${red}Script failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}" if [[ $? != 0 ]]; then
return 0 echo -e "${red}Script failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
return 0
fi
fi fi
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1 wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
@@ -447,88 +474,37 @@ modify_dashboard_config() {
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
sed -i "s/nz_language/en-US/" /tmp/nezha-config.yaml sed -i "s/nz_language/en-US/" /tmp/nezha-config.yaml
sed -i "s/nz_site_port/${nz_site_port}/" /tmp/nezha-docker-compose.yaml if [[ $IS_DOCKER_NEZHA == 1 ]]; then
sed -i "s/nz_grpc_port/${nz_grpc_port}/g" /tmp/nezha-docker-compose.yaml sed -i "s/nz_site_port/${nz_site_port}/" /tmp/nezha-docker-compose.yaml
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml sed -i "s/nz_grpc_port/${nz_grpc_port}/g" /tmp/nezha-docker-compose.yaml
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
fi
mkdir -p $NZ_DASHBOARD_PATH/data mkdir -p $NZ_DASHBOARD_PATH/data
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
mv -f /tmp/nezha-docker-compose.yaml ${NZ_DASHBOARD_PATH}/docker-compose.yaml if [[ $IS_DOCKER_NEZHA == 1 ]]; then
mv -f /tmp/nezha-docker-compose.yaml ${NZ_DASHBOARD_PATH}/docker-compose.yaml
echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}"
restart_and_update
if [[ $# == 0 ]]; then
before_show_menu
fi
}
modify_dashboard_config_standalone() {
echo -e "> Modify Panel Configuration"
echo -e "Download configuration template"
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "${red}File failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
return 0
fi fi
echo "About the GitHub Oauth2 application: create it at https://github.com/settings/developers, no review required, and fill in the http(s)://domain_or_IP/oauth2/callback" && if [[ $IS_DOCKER_NEZHA == 0 ]]; then
echo "(Not recommended) About the Gitee Oauth2 application: create it at https://gitee.com/oauth/applications, no auditing required, and fill in the http(s)://domain_or_IP/oauth2/callback" && echo -e "Downloading service file"
read -ep "Please enter the OAuth2 provider (github/gitlab/jihulab/gitee, default github): " nz_oauth2_type && if [ "$os_alpine" != 1 ]; then
read -ep "Please enter the Client ID of the Oauth2 application: " nz_github_oauth_client_id && wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
read -ep "Please enter the Client Secret of the Oauth2 application: " nz_github_oauth_client_secret && else
read -ep "Please enter your GitHub/Gitee login name as the administrator, separated by commas: " nz_admin_logins && wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
read -ep "Please enter the site title: " nz_site_title && chmod +x $NZ_DASHBOARD_SERVICERC
read -ep "Please enter the site access port: (default 8008)" nz_site_port && if [[ $? != 0 ]]; then
read -ep "Please enter the RPC port to be used for Agent access: (default 5555)" nz_grpc_port echo -e "${red}File failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
return 0
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then fi
echo -e "${red}All options cannot be empty${plain}"
before_show_menu
return 1
fi
if [[ -z "${nz_site_port}" ]]; then
nz_site_port=8008
fi
if [[ -z "${nz_grpc_port}" ]]; then
nz_grpc_port=5555
fi
if [[ -z "${nz_oauth2_type}" ]]; then
nz_oauth2_type=github
fi
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" /tmp/nezha-config.yaml
sed -i "s/nz_admin_logins/${nz_admin_logins}/" /tmp/nezha-config.yaml
sed -i "s/nz_grpc_port/${nz_grpc_port}/" /tmp/nezha-config.yaml
sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" /tmp/nezha-config.yaml
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
mkdir -p $NZ_DASHBOARD_PATH/data
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
echo -e "Downloading service file"
if [ "$os_alpine" != 1 ]; then
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
else
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
chmod +x $NZ_DASHBOARD_SERVICERC
if [[ $? != 0 ]]; then
echo -e "${red}File failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
return 0
fi fi
fi fi
echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}" echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}"
restart_and_update_standalone restart_and_update
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
before_show_menu before_show_menu
@@ -540,15 +516,10 @@ restart_and_update() {
cd $NZ_DASHBOARD_PATH cd $NZ_DASHBOARD_PATH
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then restart_and_update_docker
docker compose pull elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
docker compose down restart_and_update_standalone
docker compose up -d
else
docker-compose pull
docker-compose down
docker-compose up -d
fi fi
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@@ -563,11 +534,13 @@ restart_and_update() {
fi fi
} }
restart_and_update_docker() {
$DOCKER_COMPOSE_COMMAND pull
$DOCKER_COMPOSE_COMMAND down
$DOCKER_COMPOSE_COMMAND up -d
}
restart_and_update_standalone() { restart_and_update_standalone() {
echo -e "> Restart and Update the Panel"
cd $NZ_DASHBOARD_PATH
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
systemctl stop nezha-dashboard systemctl stop nezha-dashboard
else else
@@ -584,27 +557,15 @@ restart_and_update_standalone() {
rc-update add nezha-dashboard rc-update add nezha-dashboard
rc-service nezha-dashboard restart rc-service nezha-dashboard restart
fi fi
if [[ $? == 0 ]]; then
echo -e "${green}Nezha Monitoring Restart Successful${plain}"
echo -e "Default panel address: ${yellow}domain:Site_access_port${plain}"
else
echo -e "${red}The restart failed, probably because the boot time exceeded two seconds, please check the log information later${plain}"
fi
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
start_dashboard() { start_dashboard() {
echo -e "> Start Panel" echo -e "> Start Panel"
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then start_dashboard_docker
cd $NZ_DASHBOARD_PATH && docker compose up -d elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
else start_dashboard_standalone
cd $NZ_DASHBOARD_PATH && docker-compose up -d
fi fi
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@@ -618,34 +579,25 @@ start_dashboard() {
fi fi
} }
start_dashboard_standalone() { start_dashboard_docker() {
echo -e "> Start Panel" cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND up -d
}
start_dashboard_standalone() {
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
systemctl start nezha-dashboard systemctl start nezha-dashboard
else else
rc-service nezha-dashboard start rc-service nezha-dashboard start
fi fi
if [[ $? == 0 ]]; then
echo -e "${green}Nezha Monitoring Start Successful${plain}"
else
echo -e "${red}Failed to start, please check the log message later${plain}"
fi
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
stop_dashboard() { stop_dashboard() {
echo -e "> Stop Panel" echo -e "> Stop Panel"
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then stop_dashboard_docker
cd $NZ_DASHBOARD_PATH && docker compose down elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
else stop_dashboard_standalone
cd $NZ_DASHBOARD_PATH && docker-compose down
fi fi
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@@ -659,34 +611,25 @@ stop_dashboard() {
fi fi
} }
stop_dashboard_standalone() { stop_dashboard_docker() {
echo -e "> Stop Panel" cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND down
}
stop_dashboard_standalone() {
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
systemctl stop nezha-dashboard systemctl stop nezha-dashboard
else else
rc-service nezha-dashboard stop rc-service nezha-dashboard stop
fi fi
if [[ $? == 0 ]]; then
echo -e "${green}Nezha Monitoring Stop Successful${plain}"
else
echo -e "${red}Failed to stop, please check the log message later${plain}"
fi
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
show_dashboard_log() { show_dashboard_log() {
echo -e "> View Panel Log" echo -e "> View Panel Log"
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then show_dashboard_log_docker
cd $NZ_DASHBOARD_PATH && docker compose logs -f elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
else show_dashboard_log_standalone
cd $NZ_DASHBOARD_PATH && docker-compose logs -f
fi fi
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@@ -694,33 +637,27 @@ show_dashboard_log() {
fi fi
} }
show_dashboard_log_standalone() { show_dashboard_log_docker() {
echo -e "> View Panel Log" cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND logs -f
}
show_dashboard_log_standalone() {
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
journalctl -xf -u nezha-dashboard.service journalctl -xf -u nezha-dashboard.service
else else
echo "Sorry, OpenRC do not have this feature yet." tail -n 10 /var/log/nezha-dashboard.err
fi
if [[ $# == 0 ]]; then
before_show_menu
fi fi
} }
uninstall_dashboard() { uninstall_dashboard() {
echo -e "> Uninstall Panel" echo -e "> Uninstall Panel"
docker compose version if [[ $IS_DOCKER_NEZHA == 1 ]]; then
if [[ $? == 0 ]]; then uninstall_dashboard_docker
cd $NZ_DASHBOARD_PATH && docker compose down elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
else uninstall_dashboard_standalone
cd $NZ_DASHBOARD_PATH && docker-compose down
fi fi
rm -rf $NZ_DASHBOARD_PATH
docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
clean_all clean_all
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@@ -728,9 +665,14 @@ uninstall_dashboard() {
fi fi
} }
uninstall_dashboard_standalone() { uninstall_dashboard_docker() {
echo -e "> Uninstall Panel" cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND down
rm -rf $NZ_DASHBOARD_PATH
docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
}
uninstall_dashboard_standalone() {
rm -rf $NZ_DASHBOARD_PATH rm -rf $NZ_DASHBOARD_PATH
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
@@ -744,12 +686,6 @@ uninstall_dashboard_standalone() {
else else
rm $NZ_DASHBOARD_SERVICERC rm $NZ_DASHBOARD_SERVICERC
fi fi
clean_all
if [[ $# == 0 ]]; then
before_show_menu
fi
} }
show_agent_log() { show_agent_log() {
@@ -758,7 +694,7 @@ show_agent_log() {
if [ "$os_alpine" != 1 ]; then if [ "$os_alpine" != 1 ]; then
journalctl -xf -u nezha-agent.service journalctl -xf -u nezha-agent.service
else else
echo "Sorry, OpenRC do not have this feature yet." tail -n 10 /var/log/nezha-agent.err
fi fi
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@@ -808,59 +744,6 @@ clean_all() {
fi fi
} }
select_version() {
DOCKER_COMPOSE_COMMAND=""
if docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE_COMMAND="docker compose"
if $DOCKER_COMPOSE_COMMAND ls | grep -qw "$NZ_DASHBOARD_PATH/docker-compose.yaml" >/dev/null 2>&1; then
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
if [ -n "$NEZHA_IMAGES" ]; then
echo "Docker image with nezha-dashboard repository exists:"
echo "$NEZHA_IMAGES"
IS_DOCKER_NEZHA=1
return
else
echo "No Docker images with the nezha-dashboard repository were found."
fi
fi
elif command -v docker-compose >/dev/null 2>&1; then
DOCKER_COMPOSE_COMMAND="docker-compose"
if $DOCKER_COMPOSE_COMMAND -f "$NZ_DASHBOARD_PATH/docker-compose.yaml" config >/dev/null 2>&1; then
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
if [ -n "$NEZHA_IMAGES" ]; then
echo "Docker image with nezha-dashboard repository exists:"
echo "$NEZHA_IMAGES"
IS_DOCKER_NEZHA=1
return
else
echo "No Docker images with the nezha-dashboard repository were found."
fi
fi
fi
if [[ -f $NZ_DASHBOARD_PATH/app ]]; then
IS_DOCKER_NEZHA=0
else
echo -e "${yellow}Select your installation method(Input anything is ok if you are installing agent):\n1. Docker\n2. Standalone${plain}"
while true; do
read -e -r -p "Input a number [1-2]: " option
case "${option}" in
1)
IS_DOCKER_NEZHA=1
break
;;
2)
IS_DOCKER_NEZHA=0
break
;;
*)
echo "Wrong input, try again"
;;
esac
done
fi
}
show_usage() { show_usage() {
echo "Nezha Monitor Management Script Usage: " echo "Nezha Monitor Management Script Usage: "
echo "--------------------------------------------------------" echo "--------------------------------------------------------"
@@ -905,8 +788,7 @@ show_menu() {
${green}0.${plain} Exit Script ${green}0.${plain} Exit Script
" "
echo && read -ep "Please enter [0-13]: " num echo && read -ep "Please enter [0-13]: " num
if [[ $IS_DOCKER_NEZHA == 1 ]]; then case "${num}" in
case "${num}" in
0) 0)
exit 0 exit 0
;; ;;
@@ -952,63 +834,14 @@ show_menu() {
*) *)
echo -e "${red}Please enter the correct number [0-13]${plain}" echo -e "${red}Please enter the correct number [0-13]${plain}"
;; ;;
esac esac
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
case "${num}" in
0)
exit 0
;;
1)
install_dashboard_standalone
;;
2)
modify_dashboard_config_standalone
;;
3)
start_dashboard_standalone
;;
4)
stop_dashboard_standalone
;;
5)
restart_and_update_standalone
;;
6)
show_dashboard_log_standalone
;;
7)
uninstall_dashboard_standalone
;;
8)
install_agent
;;
9)
modify_agent_config
;;
10)
show_agent_log
;;
11)
uninstall_agent
;;
12)
restart_agent
;;
13)
update_script
;;
*)
echo -e "${red}Please enter the correct number [0-13]${plain}"
;;
esac
fi
} }
pre_check pre_check
installation_check
if [[ $# > 0 ]]; then if [[ $# > 0 ]]; then
if [[ $IS_DOCKER_NEZHA == 1 ]]; then case $1 in
case $1 in
"install_dashboard") "install_dashboard")
install_dashboard 0 install_dashboard 0
;; ;;
@@ -1054,84 +887,8 @@ if [[ $# > 0 ]]; then
update_script 0 update_script 0
;; ;;
*) show_usage ;; *) show_usage ;;
esac esac
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
case $1 in
"install_dashboard")
install_dashboard_standalone 0
;;
"modify_dashboard_config")
modify_dashboard_config_standalone 0
;;
"start_dashboard")
start_dashboard_standalone 0
;;
"stop_dashboard")
stop_dashboard_standalone 0
;;
"restart_and_update")
restart_and_update_standalone 0
;;
"show_dashboard_log")
show_dashboard_log_standalone 0
;;
"uninstall_dashboard")
uninstall_dashboard_standalone 0
;;
"install_agent")
shift
if [ $# -ge 3 ]; then
install_agent "$@"
else
install_agent 0
fi
;;
"modify_agent_config")
modify_agent_config 0
;;
"show_agent_log")
show_agent_log 0
;;
"uninstall_agent")
uninstall_agent 0
;;
"restart_agent")
restart_agent 0
;;
"update_script")
update_script 0
;;
*) show_usage ;;
esac
else
case $1 in
"install_agent")
shift
if [ $# -ge 3 ]; then
install_agent "$@"
else
install_agent 0
fi
;;
"modify_agent_config")
modify_agent_config 0
;;
"show_agent_log")
show_agent_log 0
;;
"uninstall_agent")
uninstall_agent 0
;;
"restart_agent")
restart_agent 0
;;
"update_script")
update_script 0
;;
*) show_usage ;;
esac
fi
else else
select_version select_version
show_menu show_menu
fi fi
+5 -48
View File
@@ -1,62 +1,19 @@
#!/sbin/openrc-run #!/sbin/openrc-run
supervisor=supervise-daemon supervisor=supervise-daemon
name=nezha-agent name=nezha-agent
supervise_daemon_args="--stdout /var/log/${name}.log --stderr /var/log/${name}.err" output_log=/var/log/${name}.log
error_log=/var/log/${name}.err
SERVER="nz_grpc_host:nz_grpc_port" #Dashboard 地址 ip:port SERVER="nz_grpc_host:nz_grpc_port" #Dashboard 地址 ip:port
SECRET="nz_client_secret" #SECRET SECRET="nz_client_secret" #SECRET
NZ_BASE_PATH="/opt/nezha"
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
pidfile="/run/${RC_SVCNAME}.pid" pidfile="/run/${RC_SVCNAME}.pid"
command="/opt/nezha/agent/nezha-agent" command="/opt/nezha/agent/nezha-agent"
command_args="-s ${SERVER} -p ${SECRET}" command_args="-s ${SERVER} -p ${SECRET}"
command_background=true command_background=true
depend() { depend() {
need net need net
} }
checkconfig() {
GITHUB_URL="github.com"
if [ ! -f "${NZ_AGENT_PATH}/nezha-agent" ]; then
if [[ $(uname -m | grep 'x86_64') != "" ]]; then
os_arch="amd64"
elif [[ $(uname -m | grep 'i386\|i686') != "" ]]; then
os_arch="386"
elif [[ $(uname -m | grep 'aarch64\|armv8b\|armv8l') != "" ]]; then
os_arch="arm64"
elif [[ $(uname -m | grep 'arm') != "" ]]; then
os_arch="arm"
elif [[ $(uname -m | grep 's390x') != "" ]]; then
os_arch="s390x"
elif [[ $(uname -m | grep 'riscv64') != "" ]]; then
os_arch="riscv64"
fi
local version=$(curl -m 10 -sL "https://api.github.com/repos/nezhahq/agent/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
if [ ! -n "$version" ]; then
version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/nezhahq/agent/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/nezhahq\/agent@/v/g')
fi
if [ ! -n "$version" ]; then
version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/nezhahq/agent/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/nezhahq\/agent@/v/g')
fi
if [ ! -n "$version" ]; then
echo -e "获取版本号失败,请检查本机能否链接 https://api.github.com/repos/nezhahq/agent/releases/latest"
return 0
else
echo -e "当前最新版本为: ${version}"
fi
wget -t 2 -T 10 -O nezha-agent_linux_${os_arch}.zip https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_linux_${os_arch}.zip >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "Release 下载失败,请检查本机能否连接 ${GITHUB_URL}${plain}"
return 0
fi
mkdir -p $NZ_AGENT_PATH
chmod 755 -R $NZ_AGENT_PATH
unzip -qo nezha-agent_linux_${os_arch}.zip && mv nezha-agent $NZ_AGENT_PATH && rm -rf nezha-agent_linux_${os_arch}.zip README.md
fi
if [ ! -x "${NZ_AGENT_PATH}/nezha-agent" ]; then
chmod +x ${NZ_AGENT_PATH}/nezha-agent
fi
}
start_pre() { start_pre() {
if [ "${RC_CMD}" != "restart" ]; then checkpath -f -m 0644 -o root:root "/var/log/${name}.log"
checkconfig || return $?
fi
} }
Regular → Executable
+7 -5
View File
@@ -1,4 +1,8 @@
#!/sbin/openrc-run #!/sbin/openrc-run
supervisor=supervise-daemon
name=nezha-dashboard
output_log=/var/log/${name}.log
error_log=/var/log/${name}.err
pidfile="/run/${RC_SVCNAME}.pid" pidfile="/run/${RC_SVCNAME}.pid"
command="/opt/nezha/dashboard/app" command="/opt/nezha/dashboard/app"
command_args="" command_args=""
@@ -6,11 +10,9 @@ command_background=true
directory="/opt/nezha/dashboard" directory="/opt/nezha/dashboard"
depend() { depend() {
need net need net
} }
reload() { start_pre() {
ebegin "Reloading ${RC_SVCNAME}" checkpath -f -m 0644 -o root:root "/var/log/${name}.log"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
} }
+2 -2
View File
@@ -127,8 +127,8 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece
ipv4, ipv6, _ := utils.SplitIPAddr(host.IP) ipv4, ipv6, _ := utils.SplitIPAddr(host.IP)
maxRetries := int(singleton.Conf.DDNS.MaxRetries) maxRetries := int(singleton.Conf.DDNS.MaxRetries)
config := &ddns.DomainConfig{ config := &ddns.DomainConfig{
EnableIPv4: true, EnableIPv4: singleton.ServerList[clientID].EnableIPv4,
EnableIpv6: true, EnableIpv6: singleton.ServerList[clientID].EnableIpv6,
FullDomain: serverDomain, FullDomain: serverDomain,
Ipv4Addr: ipv4, Ipv4Addr: ipv4,
Ipv6Addr: ipv6, Ipv6Addr: ipv6,