mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
parent
63c330054e
commit
8798babe07
@ -101,19 +101,19 @@ func Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadParams(param string) string {
|
func loadParams(param string) string {
|
||||||
stdout, err := cmd.Execf("grep '^%s=' /usr/bin/1pctl | cut -d'=' -f2", param)
|
stdout, err := cmd.Execf("grep '^%s=' /usr/local/bin/1pctl | cut -d'=' -f2", param)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
info := strings.ReplaceAll(stdout, "\n", "")
|
info := strings.ReplaceAll(stdout, "\n", "")
|
||||||
if len(info) == 0 || info == `""` {
|
if len(info) == 0 || info == `""` {
|
||||||
panic(fmt.Sprintf("error `%s` find in /usr/bin/1pctl", param))
|
panic(fmt.Sprintf("error `%s` find in /usr/local/bin/1pctl", param))
|
||||||
}
|
}
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadChangeInfo() string {
|
func loadChangeInfo() string {
|
||||||
stdout, err := cmd.Exec("grep '^CHANGE_USER_INFO=' /usr/bin/1pctl | cut -d'=' -f2")
|
stdout, err := cmd.Exec("grep '^CHANGE_USER_INFO=' /usr/local/bin/1pctl | cut -d'=' -f2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ var restoreCmd = &cobra.Command{
|
|||||||
fmt.Println("请使用 sudo 1pctl restore 或者切换到 root 用户")
|
fmt.Println("请使用 sudo 1pctl restore 或者切换到 root 用户")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
stdout, err := cmdUtils.Exec("grep '^BASE_DIR=' /usr/bin/1pctl | cut -d'=' -f2")
|
stdout, err := cmdUtils.Exec("grep '^BASE_DIR=' /usr/local/bin/1pctl | cut -d'=' -f2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("handle load `BASE_DIR` failed, err: %v", err)
|
return fmt.Errorf("handle load `BASE_DIR` failed, err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,13 @@ type setting struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadDBConn() (*gorm.DB, error) {
|
func loadDBConn() (*gorm.DB, error) {
|
||||||
stdout, err := cmdUtils.Exec("grep '^BASE_DIR=' /usr/bin/1pctl | cut -d'=' -f2")
|
stdout, err := cmdUtils.Exec("grep '^BASE_DIR=' /usr/local/bin/1pctl | cut -d'=' -f2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("handle load `BASE_DIR` failed, err: %v", err)
|
return nil, fmt.Errorf("handle load `BASE_DIR` failed, err: %v", err)
|
||||||
}
|
}
|
||||||
baseDir := strings.ReplaceAll(stdout, "\n", "")
|
baseDir := strings.ReplaceAll(stdout, "\n", "")
|
||||||
if len(baseDir) == 0 {
|
if len(baseDir) == 0 {
|
||||||
return nil, fmt.Errorf("error `BASE_DIR` find in /usr/bin/1pctl \n")
|
return nil, fmt.Errorf("error `BASE_DIR` find in /usr/local/bin/1pctl \n")
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(baseDir, "/") {
|
if strings.HasSuffix(baseDir, "/") {
|
||||||
baseDir = baseDir[:strings.LastIndex(baseDir, "/")]
|
baseDir = baseDir[:strings.LastIndex(baseDir, "/")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user