feat(website): Automatically create an ACME account on Start (#8479)

This commit is contained in:
ChengPlay 2025-04-25 18:55:52 +08:00 committed by GitHub
parent d8f1c462f1
commit f485b1729c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,8 @@
package business
import (
"github.com/1Panel-dev/1Panel/agent/app/dto"
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
"github.com/1Panel-dev/1Panel/agent/app/service"
"github.com/1Panel-dev/1Panel/agent/constant"
"github.com/1Panel-dev/1Panel/agent/global"
@ -12,6 +14,7 @@ func Init() {
go syncRuntime()
go syncSSL()
go syncTask()
go initAcmeAccount()
}
func syncApp() {
@ -45,3 +48,22 @@ func syncTask() {
global.LOG.Errorf("sync task status error : %s", err.Error())
}
}
func initAcmeAccount() {
acmeAccountService := service.NewIWebsiteAcmeAccountService()
search := dto.PageInfo{
Page: 1,
PageSize: 10,
}
count, _, _ := acmeAccountService.Page(search)
if count == 0 {
createAcmeAccount := request.WebsiteAcmeAccountCreate{
Email: "acme@1paneldev.com",
Type: "letsencrypt",
KeyType: "2048",
}
if _, err := acmeAccountService.Create(createAcmeAccount); err != nil {
global.LOG.Errorf("create acme account error: %s", err.Error())
}
}
}