diff --git a/.gitea/workflows/template-cleanup.yaml b/.gitea/workflows/template-cleanup.yaml index d7b8782..787a93d 100644 --- a/.gitea/workflows/template-cleanup.yaml +++ b/.gitea/workflows/template-cleanup.yaml @@ -5,11 +5,11 @@ on: jobs: - # 当前仓库名不为 zabbix-agent-2-plugin-template 时触发 + # 当前仓库名不为 zabbix-agent2-plugin-template 时触发 template-cleanup: name: Template Cleanup runs-on: ubuntu-latest - #if: github.event.repository.name != 'zabbix-agent-2-plugin-template' + if: github.event.repository.name != 'zabbix-agent2-plugin-template' permissions: contents: write steps: @@ -24,18 +24,15 @@ jobs: export LC_CTYPE=C export LANG=C - # 变量 + # 准备变量 OWNER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]') REPO_NAME="${GITHUB_REPOSITORY##*/}" SAFE_OWNER=$(echo $OWNER | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]') SAFE_REPO_NAME=$(echo $REPO_NAME | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]') - GROUP="cn.sh.ittc.$SAFE_OWNER.$SAFE_REPO_NAME" - echo $REPO_NAME - echo $OWNER - echo $SAFE_REPO_NAME - echo $SAFE_OWNER - echo $GROUP + # 替换模板包名 + find src -type f -exec sed -i "s/zabbixagent2plugintemplate/$SAFE_REPO_NAME/g" {} + + find src -type f -exec sed -i "s/Zabbix Agent 2 Plugin Template/$REPO_NAME/g" {} + # # 记录文件修改 # - name: Commit files diff --git a/compose.yaml b/compose.yaml index caa5903..a68ca13 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,8 +6,8 @@ services: ZBX_SERVER_HOST: server ZBX_SERVER_PORT: 10051 volumes: - - ./log:/var/log/onvif-agent - - ./config.yaml:/etc/onvif-agent/config.yaml + - ./log:/var/log/zabbixagent2plugintemplate + - ./config.yaml:/etc/zabbixagent2plugintemplate/config.yaml ports: - "8080:8080" networks: diff --git a/config/config.go b/config/config.go index c4a831a..8042897 100644 --- a/config/config.go +++ b/config/config.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/spf13/viper" "log" - "onvif-agent/constant" "os" + "zabbixagent2plugintemplate/constant" ) type config struct { diff --git a/constant/app.go b/constant/app.go index c182bff..66361cc 100644 --- a/constant/app.go +++ b/constant/app.go @@ -1,6 +1,6 @@ package constant const ( - AppName = "onvif-agent" + AppName = "zabbixagent2plugintemplate" AppVersion = "1.0.0" ) diff --git a/go.mod b/go.mod index 2b7b14b..e1c5276 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module onvif-agent +module zabbixagent2plugintemplate go 1.23.0 diff --git a/integration/zabbixagent/gin_handler.go b/integration/zabbixagent/gin_handler.go index dc20beb..e59921b 100644 --- a/integration/zabbixagent/gin_handler.go +++ b/integration/zabbixagent/gin_handler.go @@ -3,9 +3,9 @@ package zabbixagent import ( "fmt" "github.com/gin-gonic/gin" - "onvif-agent/response" - handler "onvif-agent/router/handler/onvif" - service "onvif-agent/service/onvif" + "zabbixagent2plugintemplate/response" + handler "zabbixagent2plugintemplate/router/handler/onvif" + service "zabbixagent2plugintemplate/service/onvif" ) func DiscoverONVIFDevices(c *gin.Context) { diff --git a/integration/zabbixagent/handler.go b/integration/zabbixagent/handler.go index a239acb..a89d72f 100644 --- a/integration/zabbixagent/handler.go +++ b/integration/zabbixagent/handler.go @@ -6,9 +6,9 @@ import ( "golang.zabbix.com/sdk/errs" "io" "net/http" - "onvif-agent/config" - "onvif-agent/constant" "strings" + "zabbixagent2plugintemplate/config" + "zabbixagent2plugintemplate/constant" ) // HandlerFunc describes the signature all metric handler functions must have. diff --git a/main.go b/main.go index daa8db7..8425c57 100644 --- a/main.go +++ b/main.go @@ -5,14 +5,14 @@ import ( "github.com/gin-gonic/gin" "io" "log" - "onvif-agent/config" - "onvif-agent/constant" - "onvif-agent/integration/zabbixagent" - "onvif-agent/router" "os" "path/filepath" "runtime" "time" + "zabbixagent2plugintemplate/config" + "zabbixagent2plugintemplate/constant" + "zabbixagent2plugintemplate/integration/zabbixagent" + "zabbixagent2plugintemplate/router" ) func main() { diff --git a/router/handler/hello.go b/router/handler/hello.go index c1afd63..66c79ab 100644 --- a/router/handler/hello.go +++ b/router/handler/hello.go @@ -2,7 +2,7 @@ package handler import ( "github.com/gin-gonic/gin" - "onvif-agent/response" + "zabbixagent2plugintemplate/response" ) func Hello(c *gin.Context) { diff --git a/router/handler/onvif/notification.go b/router/handler/onvif/notification.go index e7b067f..1b4efcc 100644 --- a/router/handler/onvif/notification.go +++ b/router/handler/onvif/notification.go @@ -2,8 +2,8 @@ package onvif import ( "github.com/gin-gonic/gin" - "onvif-agent/response" - "onvif-agent/service/onvif" + "zabbixagent2plugintemplate/response" + "zabbixagent2plugintemplate/service/onvif" ) func GetNotifications(c *gin.Context) { diff --git a/router/handler/onvif/session.go b/router/handler/onvif/session.go index 273a5ff..8303fbf 100644 --- a/router/handler/onvif/session.go +++ b/router/handler/onvif/session.go @@ -3,8 +3,8 @@ package onvif import ( "github.com/gin-gonic/gin" "net/http" - "onvif-agent/response" - "onvif-agent/service/onvif" + "zabbixagent2plugintemplate/response" + "zabbixagent2plugintemplate/service/onvif" ) type CreateSessionRequest struct { diff --git a/router/handler/onvif/subscription.go b/router/handler/onvif/subscription.go index d4585d5..8d093ba 100644 --- a/router/handler/onvif/subscription.go +++ b/router/handler/onvif/subscription.go @@ -7,9 +7,9 @@ import ( "github.com/gin-gonic/gin" "log" "net/http" - "onvif-agent/config" - "onvif-agent/response" - "onvif-agent/service/onvif" + "zabbixagent2plugintemplate/config" + "zabbixagent2plugintemplate/response" + "zabbixagent2plugintemplate/service/onvif" ) func CreateSubscription(c *gin.Context) { diff --git a/router/router.go b/router/router.go index 59f757a..64acbe8 100644 --- a/router/router.go +++ b/router/router.go @@ -2,9 +2,9 @@ package router import ( "github.com/gin-gonic/gin" - "onvif-agent/integration/zabbixagent" - "onvif-agent/router/handler" - "onvif-agent/router/handler/onvif" + "zabbixagent2plugintemplate/integration/zabbixagent" + "zabbixagent2plugintemplate/router/handler" + "zabbixagent2plugintemplate/router/handler/onvif" ) func SetupRoutes(r *gin.Engine) {