-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.go
More file actions
41 lines (34 loc) · 821 Bytes
/
utils.go
File metadata and controls
41 lines (34 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"os"
"os/exec"
)
// VerifyInstallation 检查 Clash 是否正确安装
func VerifyInstallation() error {
// 检查 clash 二进制文件
_, err := exec.LookPath("clash")
if err != nil {
return fmt.Errorf("Clash 二进制文件未找到: %v", err)
}
// 检查配置文件
if _, err := os.Stat("/srv/clash/config.yaml"); os.IsNotExist(err) {
return fmt.Errorf("Clash 配置文件未找到: %v", err)
}
// 检查 Country.mmdb 文件
mmdbPaths := []string{
"/root/.config/clash/Country.mmdb",
os.ExpandEnv("$HOME/.config/clash/Country.mmdb"),
}
mmdbFound := false
for _, path := range mmdbPaths {
if _, err := os.Stat(path); err == nil {
mmdbFound = true
break
}
}
if !mmdbFound {
return fmt.Errorf("Country.mmdb 文件未找到")
}
return nil
}