mirror of https://github.com/1Panel-dev/1Panel
parent
fb5c3429e5
commit
42e522abe1
|
@ -172,17 +172,17 @@ func (u *SnapshotService) SnapshotCreate(req dto.SnapshotCreate) error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := u.handlePanelDatas(snap.ID, fileOp, "snapshot", global.CONF.BaseDir+"/1panel", backupPanelDir, localDir, dockerDataDir); err != nil {
|
if err := u.handlePanelDatas(snap.ID, fileOp, "snapshot", global.CONF.System.BaseDir+"/1panel", backupPanelDir, localDir, dockerDataDir); err != nil {
|
||||||
updateSnapshotStatus(snap.ID, constant.StatusFailed, err.Error())
|
updateSnapshotStatus(snap.ID, constant.StatusFailed, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, _ = cmd.Exec("systemctl restart docker")
|
_, _ = cmd.Exec("systemctl restart docker")
|
||||||
|
|
||||||
snapJson := SnapshotJson{
|
snapJson := SnapshotJson{
|
||||||
BaseDir: global.CONF.BaseDir,
|
BaseDir: global.CONF.System.BaseDir,
|
||||||
DockerDataDir: dockerDataDir,
|
DockerDataDir: dockerDataDir,
|
||||||
BackupDataDir: localDir,
|
BackupDataDir: localDir,
|
||||||
PanelDataDir: global.CONF.BaseDir + "/1panel",
|
PanelDataDir: global.CONF.System.BaseDir + "/1panel",
|
||||||
LiveRestoreEnabled: liveRestoreStatus,
|
LiveRestoreEnabled: liveRestoreStatus,
|
||||||
}
|
}
|
||||||
if err := u.saveJson(snapJson, rootDir); err != nil {
|
if err := u.saveJson(snapJson, rootDir); err != nil {
|
||||||
|
@ -287,8 +287,8 @@ func (u *SnapshotService) SnapshotRecover(req dto.SnapshotRecover) error {
|
||||||
u.OriginalPath = fmt.Sprintf("%s/original_%s", snapJson.BaseDir, snap.Name)
|
u.OriginalPath = fmt.Sprintf("%s/original_%s", snapJson.BaseDir, snap.Name)
|
||||||
_ = os.MkdirAll(u.OriginalPath, os.ModePerm)
|
_ = os.MkdirAll(u.OriginalPath, os.ModePerm)
|
||||||
|
|
||||||
snapJson.OldBaseDir = global.CONF.BaseDir
|
snapJson.OldBaseDir = global.CONF.System.BaseDir
|
||||||
snapJson.OldPanelDataDir = global.CONF.BaseDir + "/1panel"
|
snapJson.OldPanelDataDir = global.CONF.System.BaseDir + "/1panel"
|
||||||
snapJson.OldBackupDataDir = localDir
|
snapJson.OldBackupDataDir = localDir
|
||||||
recoverPanelDir := fmt.Sprintf("%s/%s/1panel", baseDir, snap.Name)
|
recoverPanelDir := fmt.Sprintf("%s/%s/1panel", baseDir, snap.Name)
|
||||||
liveRestore := false
|
liveRestore := false
|
||||||
|
|
|
@ -109,11 +109,18 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error {
|
||||||
global.LOG.Errorf("upgrade 1panel failed, err: %v", err)
|
global.LOG.Errorf("upgrade 1panel failed, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cpBinary(tmpDir+"/1pctl", "/usr/local/bin/1pctl"); err != nil {
|
if err := cpBinary(tmpDir+"/1pctl", "/usr/local/bin/1pctl"); err != nil {
|
||||||
u.handleRollback(fileOp, originalDir, 2)
|
u.handleRollback(fileOp, originalDir, 2)
|
||||||
global.LOG.Errorf("upgrade 1pctl failed, err: %v", err)
|
global.LOG.Errorf("upgrade 1pctl failed, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if _, err := cmd.Execf("sed -i -e 's#BASE_DIR=.*#BASE_DIR=%s#g' /usr/local/bin/1pctl", global.CONF.System.BaseDir); err != nil {
|
||||||
|
u.handleRollback(fileOp, originalDir, 2)
|
||||||
|
global.LOG.Errorf("upgrade basedir in 1pctl failed, err: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := cpBinary(tmpDir+"/1panel.service", "/etc/systemd/system/1panel.service"); err != nil {
|
if err := cpBinary(tmpDir+"/1panel.service", "/etc/systemd/system/1panel.service"); err != nil {
|
||||||
u.handleRollback(fileOp, originalDir, 3)
|
u.handleRollback(fileOp, originalDir, 3)
|
||||||
global.LOG.Errorf("upgrade 1panel.service failed, err: %v", err)
|
global.LOG.Errorf("upgrade 1panel.service failed, err: %v", err)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package configs
|
package configs
|
||||||
|
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
BaseDir string `mapstructure:"base_dir"`
|
|
||||||
System System `mapstructure:"system"`
|
System System `mapstructure:"system"`
|
||||||
LogConfig LogConfig `mapstructure:"log"`
|
LogConfig LogConfig `mapstructure:"log"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,9 +71,9 @@ func Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
global.CONF = serverConfig
|
global.CONF = serverConfig
|
||||||
global.CONF.BaseDir = baseDir
|
global.CONF.System.BaseDir = baseDir
|
||||||
global.CONF.System.IsDemo = v.GetBool("system.is_demo")
|
global.CONF.System.IsDemo = v.GetBool("system.is_demo")
|
||||||
global.CONF.System.DataDir = global.CONF.BaseDir + "/1panel"
|
global.CONF.System.DataDir = global.CONF.System.BaseDir + "/1panel"
|
||||||
global.CONF.System.Cache = global.CONF.System.DataDir + "/cache"
|
global.CONF.System.Cache = global.CONF.System.DataDir + "/cache"
|
||||||
global.CONF.System.Backup = global.CONF.System.DataDir + "/backup"
|
global.CONF.System.Backup = global.CONF.System.DataDir + "/backup"
|
||||||
global.CONF.System.DbPath = global.CONF.System.DataDir + "/db"
|
global.CONF.System.DbPath = global.CONF.System.DataDir + "/db"
|
||||||
|
|
Loading…
Reference in New Issue