mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
feat: 修改配置文件,删除无用代码
This commit is contained in:
parent
493fb57dff
commit
cb281b2513
@ -8,8 +8,8 @@ type System struct {
|
|||||||
DataDir string `mapstructure:"data_dir"`
|
DataDir string `mapstructure:"data_dir"`
|
||||||
Cache string `mapstructure:"cache"`
|
Cache string `mapstructure:"cache"`
|
||||||
Backup string `mapstructure:"backup"`
|
Backup string `mapstructure:"backup"`
|
||||||
AppOss string `mapstructure:"app_oss"`
|
|
||||||
AppRepoOwner string `mapstructure:"app_repo_owner"`
|
AppRepoOwner string `mapstructure:"app_repo_owner"`
|
||||||
AppRepoName string `mapstructure:"app_repo_name"`
|
AppRepoName string `mapstructure:"app_repo_name"`
|
||||||
EncryptKey string `mapstructure:"encrypt_key"`
|
EncryptKey string `mapstructure:"encrypt_key"`
|
||||||
|
BaseDir string `mapstructure:"base_dir"`
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
baseDir := "/opt"
|
baseDir := "/opt"
|
||||||
|
mode := "local"
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
v := viper.NewWithOptions()
|
v := viper.NewWithOptions()
|
||||||
v.SetConfigType("yaml")
|
v.SetConfigType("yaml")
|
||||||
@ -28,6 +29,7 @@ func Init() {
|
|||||||
panic(fmt.Errorf("Fatal error config file: %s \n", err))
|
panic(fmt.Errorf("Fatal error config file: %s \n", err))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
mode = "release"
|
||||||
stdout, err := cmd.Exec("grep '^BASE_DIR=' /usr/bin/1pctl | cut -d'=' -f2")
|
stdout, err := cmd.Exec("grep '^BASE_DIR=' /usr/bin/1pctl | cut -d'=' -f2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -50,6 +52,9 @@ func Init() {
|
|||||||
if err := v.Unmarshal(&serverConfig); err != nil {
|
if err := v.Unmarshal(&serverConfig); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
if mode == "local" && serverConfig.System.BaseDir != "" {
|
||||||
|
baseDir = serverConfig.System.BaseDir
|
||||||
|
}
|
||||||
global.CONF = serverConfig
|
global.CONF = serverConfig
|
||||||
global.CONF.BaseDir = baseDir
|
global.CONF.BaseDir = baseDir
|
||||||
global.CONF.System.DataDir = global.CONF.BaseDir + "/1panel"
|
global.CONF.System.DataDir = global.CONF.BaseDir + "/1panel"
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitee.com/openeuler/go-gitee/gitee"
|
"gitee.com/openeuler/go-gitee/gitee"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@ -28,10 +29,14 @@ func CheckAndGetInfo(owner, repoName string) (*RepoInfo, error) {
|
|||||||
res, err := getLatestRepoInfo(repoType, owner, repoName)
|
res, err := getLatestRepoInfo(repoType, owner, repoName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return res, nil
|
return res, nil
|
||||||
|
} else {
|
||||||
|
global.LOG.Errorf("get %s last release version failed %s", repoType, err.Error())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
global.LOG.Errorf("get %s remote repo [%s] failed", repoType, url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return nil, errors.New("all remote repo get failed")
|
||||||
return nil, errors.New("remote repo get failed")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkValid(addr string) bool {
|
func checkValid(addr string) bool {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
system:
|
system:
|
||||||
db_file: 1Panel.db
|
db_file: 1Panel.db
|
||||||
app_oss: "https://1panel.oss-cn-hangzhou.aliyuncs.com"
|
app_repo_owner: 1Panel-dev
|
||||||
app_repo_owner: "1Panel-dev"
|
app_repo_name: appstore
|
||||||
app_repo_name: 'appstore'
|
base_dir: /opt
|
||||||
|
|
||||||
log:
|
log:
|
||||||
level: debug
|
level: debug
|
||||||
|
Loading…
x
Reference in New Issue
Block a user