Skip to content

Commit 82e9e72

Browse files
authored
feat: Fix the initialization errors of GeoIP (#7345)
1 parent c35f55f commit 82e9e72

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

backend/app/service/upgrade.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ func (u *UpgradeService) handleRollback(originalDir string, errStep int) {
212212
global.LOG.Errorf("rollback 1panel failed, err: %v", err)
213213
}
214214
_, _ = cmd.Execf("cp -r %s /usr/local/bin", path.Join(originalDir, "lang"))
215-
_, _ = cmd.Execf("cp %s %s", path.Join(originalDir, "GeoIP.mmdb"), path.Join(global.CONF.System.BaseDir, "1panel/geo/"))
215+
geoPath := path.Join(global.CONF.System.BaseDir, "1panel/geo")
216+
_, _ = cmd.Execf("mkdir %s && cp %s %s/", geoPath, path.Join(originalDir, "GeoIP.mmdb"), geoPath)
216217

217218
if errStep == 2 {
218219
return

backend/init/lang/lang.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func initLang() {
7474
downloadGeoFromRemote(fileOp, geoPath)
7575
return
7676
}
77-
std, err := cmd.Execf("cp %s %s/", path.Join(tmpPath, "GeoIP.mmdb"), path.Dir(geoPath))
77+
std, err := cmd.Execf("mkdir %s && cp %s %s/", path.Dir(geoPath), path.Join(tmpPath, "GeoIP.mmdb"), path.Dir(geoPath))
7878
if err != nil {
7979
global.LOG.Errorf("load geo ip from package failed, std: %s, err: %v", std, err)
8080
return

cmd/server/cmd/restore.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ var restoreCmd = &cobra.Command{
5555
return err
5656
}
5757
_, _ = cmdUtils.Execf("cp -r %s /usr/local/bin", path.Join(tmpPath, "lang"))
58-
_, _ = cmdUtils.Execf("cp %s %s", path.Join(tmpPath, "GeoIP.mmdb"), path.Join(global.CONF.System.BaseDir, "1panel/geo/"))
58+
geoPath := path.Join(global.CONF.System.BaseDir, "1panel/geo")
59+
_, _ = cmdUtils.Execf("mkdir %s && cp %s %s/", geoPath, path.Join(tmpPath, "GeoIP.mmdb"), geoPath)
5960
fmt.Println(i18n.GetMsgByKeyForCmd("RestoreStep3"))
6061
if err := common.CopyFile(path.Join(tmpPath, "1panel.service"), "/etc/systemd/system"); err != nil {
6162
return err

0 commit comments

Comments
 (0)