1
0
mirror of https://github.com/IceWhaleTech/CasaOS.git synced 2025-07-12 23:50:14 +02:00
This commit is contained in:
Tiger Wang
2022-10-11 00:19:02 -04:00
parent 2eac040875
commit ff6cdb6fda
6 changed files with 170 additions and 122 deletions

View File

@ -35,8 +35,8 @@ func ExecResultStrArray(cmdStr string) []string {
fmt.Println(err)
return nil
}
//str, err := ioutil.ReadAll(stdout)
var networklist = []string{}
// str, err := ioutil.ReadAll(stdout)
networklist := []string{}
outputBuf := bufio.NewReader(stdout)
for {
output, _, err := outputBuf.ReadLine()
@ -54,6 +54,8 @@ func ExecResultStrArray(cmdStr string) []string {
func ExecResultStr(cmdStr string) string {
cmd := exec.Command("/bin/bash", "-c", cmdStr)
println(cmd.String())
stdout, err := cmd.StdoutPipe()
if err != nil {
fmt.Println(err)
@ -73,7 +75,7 @@ func ExecResultStr(cmdStr string) string {
return string(str)
}
//执行 lsblk 命令
// 执行 lsblk 命令
func ExecLSBLK() []byte {
output, err := exec.Command("lsblk", "-O", "-J", "-b").Output()
if err != nil {
@ -83,7 +85,7 @@ func ExecLSBLK() []byte {
return output
}
//执行 lsblk 命令
// 执行 lsblk 命令
func ExecLSBLKByPath(path string) []byte {
output, err := exec.Command("lsblk", path, "-O", "-J", "-b").Output()
if err != nil {
@ -93,7 +95,7 @@ func ExecLSBLKByPath(path string) []byte {
return output
}
//exec smart
// exec smart
func ExecSmartCTLByPath(path string) []byte {
timeout := 3
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second)
@ -107,6 +109,5 @@ func ExecSmartCTLByPath(path string) []byte {
}
func ExecEnabledSMART(path string) {
exec.Command("smartctl", "-s on", path).Output()
}