mirror of
https://github.com/acepanel/panel.git
synced 2026-02-06 16:21:03 +08:00
fix: 修复一些遗留问题
This commit is contained in:
@@ -79,7 +79,7 @@ func initWeb() (*app.Web, error) {
|
||||
websiteRepo := data.NewWebsiteRepo(locale, db, cacheRepo, databaseRepo, databaseServerRepo, databaseUserRepo, certRepo, certAccountRepo, settingRepo)
|
||||
environmentRepo := data.NewEnvironmentRepo(locale, config, cacheRepo, taskRepo)
|
||||
cronRepo := data.NewCronRepo(locale, db)
|
||||
backupRepo := data.NewBackupRepo(locale, db, settingRepo, websiteRepo)
|
||||
backupRepo := data.NewBackupRepo(locale, config, db, settingRepo, websiteRepo)
|
||||
homeService := service.NewHomeService(locale, config, taskRepo, websiteRepo, appRepo, environmentRepo, settingRepo, cronRepo, backupRepo)
|
||||
taskService := service.NewTaskService(taskRepo)
|
||||
websiteService := service.NewWebsiteService(websiteRepo, settingRepo)
|
||||
@@ -93,7 +93,7 @@ func initWeb() (*app.Web, error) {
|
||||
certAccountService := service.NewCertAccountService(certAccountRepo)
|
||||
appService := service.NewAppService(locale, appRepo, cacheRepo, settingRepo)
|
||||
environmentService := service.NewEnvironmentService(locale, environmentRepo, taskRepo)
|
||||
environmentPHPService := service.NewEnvironmentPHPService(locale, environmentRepo, taskRepo)
|
||||
environmentPHPService := service.NewEnvironmentPHPService(locale, config, environmentRepo, taskRepo)
|
||||
cronService := service.NewCronService(cronRepo)
|
||||
processService := service.NewProcessService()
|
||||
safeRepo := data.NewSafeRepo()
|
||||
|
||||
@@ -67,7 +67,7 @@ func initCli() (*app.Cli, error) {
|
||||
certRepo := data.NewCertRepo(locale, db, logger)
|
||||
certAccountRepo := data.NewCertAccountRepo(locale, db, userRepo, logger)
|
||||
websiteRepo := data.NewWebsiteRepo(locale, db, cacheRepo, databaseRepo, databaseServerRepo, databaseUserRepo, certRepo, certAccountRepo, settingRepo)
|
||||
backupRepo := data.NewBackupRepo(locale, db, settingRepo, websiteRepo)
|
||||
backupRepo := data.NewBackupRepo(locale, config, db, settingRepo, websiteRepo)
|
||||
cliService := service.NewCliService(locale, config, db, appRepo, cacheRepo, userRepo, settingRepo, backupRepo, websiteRepo, databaseServerRepo, certRepo, certAccountRepo)
|
||||
cli := route.NewCli(locale, cliService)
|
||||
command := bootstrap.NewCli(locale, cli)
|
||||
|
||||
7
go.sum
7
go.sum
@@ -118,8 +118,6 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
|
||||
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||
github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4=
|
||||
github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
@@ -269,7 +267,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/pquerna/otp v1.5.0 h1:NMMR+WrmaqXU4EzdGJEE1aUUI0AMRzsp96fFFWNPwxs=
|
||||
@@ -378,8 +375,6 @@ golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
|
||||
golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -452,8 +447,6 @@ golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
|
||||
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
|
||||
@@ -134,7 +134,7 @@ port = ` + ports + `
|
||||
maxretry = ` + jailMaxRetry + `
|
||||
findtime = ` + jailFindTime + `
|
||||
bantime = ` + jailBanTime + `
|
||||
logpath = ` + app.Root + `/wwwlogs/` + website.Name + `.log
|
||||
logpath = ` + app.Root + `/sites/` + website.Name + `/log/access.log
|
||||
# ` + jailWebsiteName + `-` + jailWebsiteMode + `-END
|
||||
`
|
||||
raw += rule
|
||||
|
||||
@@ -3,10 +3,11 @@ package biz
|
||||
import (
|
||||
"time"
|
||||
|
||||
mholtacme "github.com/mholt/acmez/v3/acme"
|
||||
|
||||
"github.com/acepanel/panel/internal/http/request"
|
||||
"github.com/acepanel/panel/pkg/acme"
|
||||
"github.com/acepanel/panel/pkg/types"
|
||||
mholtacme "github.com/mholt/acmez/v3/acme"
|
||||
)
|
||||
|
||||
type Cert struct {
|
||||
|
||||
@@ -30,7 +30,7 @@ func NewDB(conf *config.Config) (*gorm.DB, error) {
|
||||
options = append(options, sloggorm.WithTraceAll())
|
||||
}
|
||||
|
||||
return gorm.Open(gormlite.Open("file:"+filepath.Join(app.Root, "panel/storage/app.db?_txlock=immediate")), &gorm.Config{
|
||||
return gorm.Open(gormlite.Open("file:"+filepath.Join(app.Root, "panel/storage/panel.db?_txlock=immediate")), &gorm.Config{
|
||||
Logger: sloggorm.New(options...),
|
||||
SkipDefaultTransaction: true,
|
||||
DisableForeignKeyConstraintWhenMigrating: true,
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/acepanel/panel/internal/app"
|
||||
"github.com/acepanel/panel/internal/biz"
|
||||
"github.com/acepanel/panel/pkg/config"
|
||||
"github.com/acepanel/panel/pkg/db"
|
||||
"github.com/acepanel/panel/pkg/io"
|
||||
"github.com/acepanel/panel/pkg/shell"
|
||||
@@ -24,14 +25,16 @@ import (
|
||||
|
||||
type backupRepo struct {
|
||||
t *gotext.Locale
|
||||
conf *config.Config
|
||||
db *gorm.DB
|
||||
setting biz.SettingRepo
|
||||
website biz.WebsiteRepo
|
||||
}
|
||||
|
||||
func NewBackupRepo(t *gotext.Locale, db *gorm.DB, setting biz.SettingRepo, website biz.WebsiteRepo) biz.BackupRepo {
|
||||
func NewBackupRepo(t *gotext.Locale, conf *config.Config, db *gorm.DB, setting biz.SettingRepo, website biz.WebsiteRepo) biz.BackupRepo {
|
||||
return &backupRepo{
|
||||
t: t,
|
||||
conf: conf,
|
||||
db: db,
|
||||
setting: setting,
|
||||
website: website,
|
||||
@@ -350,10 +353,7 @@ func (r *backupRepo) createPanel(to string) error {
|
||||
if err = io.Cp(filepath.Join(app.Root, "panel"), temp); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = io.Cp("/usr/local/sbin/panel-cli", temp); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = io.Cp("/usr/local/etc/panel/config.yml", temp); err != nil {
|
||||
if err = io.Cp("/usr/local/sbin/acepanel", temp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -570,9 +570,9 @@ func (r *backupRepo) FixPanel() error {
|
||||
}
|
||||
|
||||
// 检查关键文件是否正常
|
||||
flag := !io.Exists("/usr/local/etc/panel/config.yml") ||
|
||||
!io.Exists(filepath.Join(app.Root, "panel", "web")) ||
|
||||
!io.Exists(filepath.Join(app.Root, "panel", "storage", "app.db")) ||
|
||||
flag := !io.Exists(filepath.Join(app.Root, "panel", "ace")) ||
|
||||
!io.Exists(filepath.Join(app.Root, "panel", "storage", "config.yml")) ||
|
||||
!io.Exists(filepath.Join(app.Root, "panel", "storage", "panel.db")) ||
|
||||
io.Exists("/tmp/panel-storage.zip")
|
||||
// 检查数据库连接
|
||||
if err := r.db.Exec("VACUUM").Error; err != nil {
|
||||
@@ -582,20 +582,20 @@ func (r *backupRepo) FixPanel() error {
|
||||
flag = true
|
||||
}
|
||||
if !flag {
|
||||
return errors.New(r.t.Get("Files are normal and do not need to be repaired, please run panel-cli update to update the panel"))
|
||||
return errors.New(r.t.Get("Files are normal and do not need to be repaired, please run acepanel update to update the panel"))
|
||||
}
|
||||
|
||||
// 再次确认是否需要修复
|
||||
if io.Exists("/tmp/panel-storage.zip") {
|
||||
// 文件齐全情况下只移除临时文件
|
||||
if io.Exists(filepath.Join(app.Root, "panel", "web")) &&
|
||||
io.Exists(filepath.Join(app.Root, "panel", "storage", "app.db")) &&
|
||||
io.Exists("/usr/local/etc/panel/config.yml") {
|
||||
if io.Exists(filepath.Join(app.Root, "panel", "ace")) &&
|
||||
io.Exists(filepath.Join(app.Root, "panel", "storage", "config.yml")) &&
|
||||
io.Exists(filepath.Join(app.Root, "panel", "storage", "panel.db")) {
|
||||
if err := io.Remove("/tmp/panel-storage.zip"); err != nil {
|
||||
return errors.New(r.t.Get("failed to clean temporary files: %v", err))
|
||||
}
|
||||
if app.IsCli {
|
||||
fmt.Println(r.t.Get("|-Cleaned up temporary files, please run panel-cli update to update the panel"))
|
||||
fmt.Println(r.t.Get("|-Cleaned up temporary files, please run acepanel update to update the panel"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -640,14 +640,9 @@ func (r *backupRepo) FixPanel() error {
|
||||
return errors.New(r.t.Get("Move panel file failed: %v", err))
|
||||
}
|
||||
}
|
||||
if io.Exists(filepath.Join("/tmp/panel-fix", "config.yml")) {
|
||||
if err = io.Mv(filepath.Join("/tmp/panel-fix", "config.yml"), "/usr/local/etc/panel/config.yml"); err != nil {
|
||||
return errors.New(r.t.Get("Move panel config failed: %v", err))
|
||||
}
|
||||
}
|
||||
if io.Exists(filepath.Join("/tmp/panel-fix", "panel-cli")) {
|
||||
if err = io.Mv(filepath.Join("/tmp/panel-fix", "panel-cli"), "/usr/local/sbin/panel-cli"); err != nil {
|
||||
return errors.New(r.t.Get("Move panel-cli file failed: %v", err))
|
||||
if io.Exists(filepath.Join("/tmp/panel-fix", "acepanel")) {
|
||||
if err = io.Mv(filepath.Join("/tmp/panel-fix", "acepanel"), "/usr/local/sbin/acepanel"); err != nil {
|
||||
return errors.New(r.t.Get("Move acepanel file failed: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,7 +661,7 @@ func (r *backupRepo) FixPanel() error {
|
||||
|
||||
// 下载服务文件
|
||||
if !io.Exists("/etc/systemd/system/panel.service") {
|
||||
if _, err = shell.Execf(`wget -O /etc/systemd/system/panel.service https://dl.cdn.haozi.net/panel/panel.service && sed -i "s|/www|%s|g" /etc/systemd/system/panel.service`, app.Root); err != nil {
|
||||
if _, err = shell.Execf(`wget -O /etc/systemd/system/panel.service https://%s/panel.service && sed -i "s|/opt/ace|%s|g" /etc/systemd/system/panel.service`, r.conf.App.DownloadEndpoint, app.Root); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -675,13 +670,16 @@ func (r *backupRepo) FixPanel() error {
|
||||
if app.IsCli {
|
||||
fmt.Println(r.t.Get("|-Set key file permissions..."))
|
||||
}
|
||||
if err = io.Chmod("/usr/local/etc/panel/config.yml", 0600); err != nil {
|
||||
if err = io.Chmod(filepath.Join(app.Root, "panel", "storage", "config.yml"), 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = io.Chmod(filepath.Join(app.Root, "panel", "storage", "panel.db"), 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = io.Chmod("/etc/systemd/system/panel.service", 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = io.Chmod("/usr/local/sbin/panel-cli", 0700); err != nil {
|
||||
if err = io.Chmod("/usr/local/sbin/acepanel", 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = io.Chmod(filepath.Join(app.Root, "panel"), 0700); err != nil {
|
||||
@@ -740,7 +738,7 @@ func (r *backupRepo) UpdatePanel(version, url, checksum string) error {
|
||||
}
|
||||
|
||||
if io.Exists("/tmp/panel-storage.zip") {
|
||||
return errors.New(r.t.Get("Temporary file detected in /tmp, this may be caused by the last update failure, please run panel-cli fix to repair and try again"))
|
||||
return errors.New(r.t.Get("Temporary file detected in /tmp, this may be caused by the last update failure, please run acepanel fix to repair and try again"))
|
||||
}
|
||||
|
||||
if app.IsCli {
|
||||
@@ -770,7 +768,7 @@ func (r *backupRepo) UpdatePanel(version, url, checksum string) error {
|
||||
if err := io.UnCompress(filepath.Join("/tmp", name), filepath.Join(app.Root, "panel")); err != nil {
|
||||
return errors.New(r.t.Get("|-Unzip new version failed: %v", err))
|
||||
}
|
||||
if !io.Exists(filepath.Join(app.Root, "panel", "web")) {
|
||||
if !io.Exists(filepath.Join(app.Root, "panel", "ace")) {
|
||||
return errors.New(r.t.Get("|-Unzip new version failed, missing file"))
|
||||
}
|
||||
if err := io.Remove(filepath.Join("/tmp", name)); err != nil {
|
||||
@@ -783,30 +781,33 @@ func (r *backupRepo) UpdatePanel(version, url, checksum string) error {
|
||||
if err := io.UnCompress("/tmp/panel-storage.zip", filepath.Join(app.Root, "panel", "storage")); err != nil {
|
||||
return errors.New(r.t.Get("|-Restore panel data failed: %v", err))
|
||||
}
|
||||
if !io.Exists(filepath.Join(app.Root, "panel/storage/app.db")) {
|
||||
if !io.Exists(filepath.Join(app.Root, "panel/storage/panel.db")) {
|
||||
return errors.New(r.t.Get("|-Restore panel data failed, missing file"))
|
||||
}
|
||||
|
||||
if app.IsCli {
|
||||
fmt.Println(r.t.Get("|-Run post-update script..."))
|
||||
}
|
||||
if _, err := shell.Execf("curl -sSLm 10 https://dl.cdn.haozi.net/panel/auto_update.sh | bash"); err != nil {
|
||||
if _, err := shell.Execf("curl -sSLm 10 https://%s/auto_update.sh | bash", r.conf.App.DownloadEndpoint); err != nil {
|
||||
return errors.New(r.t.Get("|-Run post-update script failed: %v", err))
|
||||
}
|
||||
if _, err := shell.Execf(`wget -O /etc/systemd/system/panel.service https://dl.cdn.haozi.net/panel/panel.service && sed -i "s|/www|%s|g" /etc/systemd/system/panel.service`, app.Root); err != nil {
|
||||
if _, err := shell.Execf(
|
||||
`wget -O /etc/systemd/system/panel.service https://%s/panel.service && sed -i "s|/www|%s|g" /etc/systemd/system/panel.service`,
|
||||
r.conf.App.DownloadEndpoint, app.Root,
|
||||
); err != nil {
|
||||
return errors.New(r.t.Get("|-Download panel service file failed: %v", err))
|
||||
}
|
||||
if _, err := shell.Execf("panel-cli setting write version %s", version); err != nil {
|
||||
if _, err := shell.Execf("acepanel setting write version %s", version); err != nil {
|
||||
return errors.New(r.t.Get("|-Write new panel version failed: %v", err))
|
||||
}
|
||||
if err := io.Mv(filepath.Join(app.Root, "panel/cli"), "/usr/local/sbin/panel-cli"); err != nil {
|
||||
return errors.New(r.t.Get("|-Move panel-cli tool failed: %v", err))
|
||||
if err := io.Mv(filepath.Join(app.Root, "panel/cli"), "/usr/local/sbin/acepanel"); err != nil {
|
||||
return errors.New(r.t.Get("|-Move acepanel tool failed: %v", err))
|
||||
}
|
||||
|
||||
if app.IsCli {
|
||||
fmt.Println(r.t.Get("|-Set key file permissions..."))
|
||||
}
|
||||
_ = io.Chmod("/usr/local/sbin/panel-cli", 0700)
|
||||
_ = io.Chmod("/usr/local/sbin/acepanel", 0700)
|
||||
_ = io.Chmod("/etc/systemd/system/panel.service", 0644)
|
||||
_ = io.Chmod(filepath.Join(app.Root, "panel"), 0700)
|
||||
|
||||
|
||||
@@ -613,7 +613,7 @@ func (r *websiteRepo) ClearLog(id uint) error {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := shell.Execf(`cat /dev/null > %s/wwwlogs/%s.log`, app.Root, website.Name)
|
||||
_, err := shell.Execf(`cat /dev/null > %s/sites/%s/log/access.log`, app.Root, website.Name)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/acepanel/panel/internal/http/request"
|
||||
"github.com/acepanel/panel/pkg/config"
|
||||
"github.com/acepanel/panel/pkg/tools"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/acepanel/panel/internal/app"
|
||||
"github.com/acepanel/panel/internal/biz"
|
||||
"github.com/acepanel/panel/internal/http/request"
|
||||
pkgcert "github.com/acepanel/panel/pkg/cert"
|
||||
"github.com/acepanel/panel/pkg/config"
|
||||
"github.com/acepanel/panel/pkg/tools"
|
||||
)
|
||||
|
||||
// CertRenew 证书续签
|
||||
|
||||
@@ -3,12 +3,12 @@ package job
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/acepanel/panel/pkg/config"
|
||||
"github.com/google/wire"
|
||||
"github.com/robfig/cron/v3"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/acepanel/panel/internal/biz"
|
||||
"github.com/acepanel/panel/pkg/config"
|
||||
)
|
||||
|
||||
var ProviderSet = wire.NewSet(NewJobs)
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/acepanel/panel/pkg/cert"
|
||||
"github.com/leonelquinteros/gotext"
|
||||
"github.com/libtnb/utils/collect"
|
||||
"github.com/libtnb/utils/hash"
|
||||
@@ -25,6 +24,7 @@ import (
|
||||
"github.com/acepanel/panel/internal/biz"
|
||||
"github.com/acepanel/panel/internal/http/request"
|
||||
"github.com/acepanel/panel/pkg/api"
|
||||
"github.com/acepanel/panel/pkg/cert"
|
||||
"github.com/acepanel/panel/pkg/config"
|
||||
"github.com/acepanel/panel/pkg/firewall"
|
||||
"github.com/acepanel/panel/pkg/io"
|
||||
@@ -687,7 +687,7 @@ func (s *CliService) CutoffWebsite(ctx context.Context, cmd *cli.Command) error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path := filepath.Join(app.Root, "wwwlogs")
|
||||
path := filepath.Join(app.Root, "sites", website.Name, "log")
|
||||
if cmd.String("path") != "" {
|
||||
path = cmd.String("path")
|
||||
}
|
||||
@@ -697,7 +697,7 @@ func (s *CliService) CutoffWebsite(ctx context.Context, cmd *cli.Command) error
|
||||
fmt.Println(s.hr)
|
||||
fmt.Println(s.t.Get("|-Rotation type: website"))
|
||||
fmt.Println(s.t.Get("|-Rotation target: %s", website.Name))
|
||||
if err = s.backupRepo.CutoffLog(path, filepath.Join(app.Root, "wwwlogs", website.Name+".log")); err != nil {
|
||||
if err = s.backupRepo.CutoffLog(path, filepath.Join(app.Root, "sites", website.Name, "log", "access.log")); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(s.hr)
|
||||
@@ -710,9 +710,9 @@ func (s *CliService) CutoffClear(ctx context.Context, cmd *cli.Command) error {
|
||||
if cmd.String("type") != "website" {
|
||||
return errors.New(s.t.Get("Currently only website log rotation is supported"))
|
||||
}
|
||||
path := filepath.Join(app.Root, "wwwlogs")
|
||||
if cmd.String("path") != "" {
|
||||
path = cmd.String("path")
|
||||
path := cmd.String("path")
|
||||
if cmd.String("path") == "" {
|
||||
return errors.New(s.t.Get("Please specify the log rotation path"))
|
||||
}
|
||||
|
||||
fmt.Println(s.hr)
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/acepanel/panel/internal/app"
|
||||
"github.com/acepanel/panel/internal/biz"
|
||||
"github.com/acepanel/panel/internal/http/request"
|
||||
"github.com/acepanel/panel/pkg/config"
|
||||
"github.com/acepanel/panel/pkg/io"
|
||||
"github.com/acepanel/panel/pkg/shell"
|
||||
"github.com/acepanel/panel/pkg/types"
|
||||
@@ -22,13 +23,15 @@ import (
|
||||
|
||||
type EnvironmentPHPService struct {
|
||||
t *gotext.Locale
|
||||
conf *config.Config
|
||||
environmentRepo biz.EnvironmentRepo
|
||||
taskRepo biz.TaskRepo
|
||||
}
|
||||
|
||||
func NewEnvironmentPHPService(t *gotext.Locale, environmentRepo biz.EnvironmentRepo, taskRepo biz.TaskRepo) *EnvironmentPHPService {
|
||||
func NewEnvironmentPHPService(t *gotext.Locale, conf *config.Config, environmentRepo biz.EnvironmentRepo, taskRepo biz.TaskRepo) *EnvironmentPHPService {
|
||||
return &EnvironmentPHPService{
|
||||
t: t,
|
||||
conf: conf,
|
||||
environmentRepo: environmentRepo,
|
||||
taskRepo: taskRepo,
|
||||
}
|
||||
@@ -310,10 +313,10 @@ func (s *EnvironmentPHPService) InstallModule(w http.ResponseWriter, r *http.Req
|
||||
return
|
||||
}
|
||||
|
||||
cmd := fmt.Sprintf(`curl -sSLm 10 --retry 3 'https://dl.cdn.haozi.net/panel/php_exts/%s.sh' | bash -s -- 'install' '%d' >> '/tmp/%s.log' 2>&1`, url.PathEscape(req.Slug), req.Version, req.Slug)
|
||||
cmd := fmt.Sprintf(`curl -sSLm 10 --retry 3 'https://%s/php_exts/%s.sh' | bash -s -- 'install' '%d' >> '/tmp/%s.log' 2>&1`, s.conf.App.DownloadEndpoint, url.PathEscape(req.Slug), req.Version, req.Slug)
|
||||
officials := []string{"fileinfo", "exif", "imap", "pgsql", "pdo_pgsql", "zip", "bz2", "readline", "snmp", "ldap", "enchant", "pspell", "calendar", "gmp", "sysvmsg", "sysvsem", "sysvshm", "xsl", "intl", "gettext"}
|
||||
if slices.Contains(officials, req.Slug) {
|
||||
cmd = fmt.Sprintf(`curl -sSLm 10 --retry 3 'https://dl.cdn.haozi.net/panel/php_exts/official.sh' | bash -s -- 'install' '%d' '%s' >> '/tmp/%s.log' 2>&1`, req.Version, req.Slug, req.Slug)
|
||||
cmd = fmt.Sprintf(`curl -sSLm 10 --retry 3 'https://%s/php_exts/official.sh' | bash -s -- 'install' '%d' '%s' >> '/tmp/%s.log' 2>&1`, s.conf.App.DownloadEndpoint, req.Version, req.Slug, req.Slug)
|
||||
}
|
||||
|
||||
task := new(biz.Task)
|
||||
@@ -345,10 +348,10 @@ func (s *EnvironmentPHPService) UninstallModule(w http.ResponseWriter, r *http.R
|
||||
return
|
||||
}
|
||||
|
||||
cmd := fmt.Sprintf(`curl -sSLm 10 --retry 3 'https://dl.cdn.haozi.net/panel/php_exts/%s.sh' | bash -s -- 'uninstall' '%d' >> '/tmp/%s.log' 2>&1`, url.PathEscape(req.Slug), req.Version, req.Slug)
|
||||
cmd := fmt.Sprintf(`curl -sSLm 10 --retry 3 'https://%s/php_exts/%s.sh' | bash -s -- 'uninstall' '%d' >> '/tmp/%s.log' 2>&1`, s.conf.App.DownloadEndpoint, url.PathEscape(req.Slug), req.Version, req.Slug)
|
||||
officials := []string{"fileinfo", "exif", "imap", "pgsql", "pdo_pgsql", "zip", "bz2", "readline", "snmp", "ldap", "enchant", "pspell", "calendar", "gmp", "sysvmsg", "sysvsem", "sysvshm", "xsl", "intl", "gettext"}
|
||||
if slices.Contains(officials, req.Slug) {
|
||||
cmd = fmt.Sprintf(`curl -sSLm 10 --retry 3 'https://dl.cdn.haozi.net/panel/php_exts/official.sh' | bash -s -- 'uninstall' '%d' '%s' >> '/tmp/%s.log' 2>&1`, req.Version, req.Slug, req.Slug)
|
||||
cmd = fmt.Sprintf(`curl -sSLm 10 --retry 3 'https://%s/php_exts/official.sh' | bash -s -- 'uninstall' '%d' '%s' >> '/tmp/%s.log' 2>&1`, s.conf.App.DownloadEndpoint, req.Version, req.Slug, req.Slug)
|
||||
}
|
||||
|
||||
task := new(biz.Task)
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/acepanel/panel/pkg/os"
|
||||
"github.com/leonelquinteros/gotext"
|
||||
"github.com/libtnb/chix"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"github.com/acepanel/panel/internal/http/request"
|
||||
"github.com/acepanel/panel/pkg/io"
|
||||
"github.com/acepanel/panel/pkg/os"
|
||||
"github.com/acepanel/panel/pkg/shell"
|
||||
"github.com/acepanel/panel/pkg/systemctl"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user