2023-05-23 22:26:14 -04:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2023-07-29 07:27:15 -04:00
|
|
|
|
|
|
|
"github.com/InazumaV/V2bX/common/exec"
|
2023-05-23 22:26:14 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
red = "\033[0;31m"
|
|
|
|
green = "\033[0;32m"
|
|
|
|
yellow = "\033[0;33m"
|
|
|
|
plain = "\033[0m"
|
|
|
|
)
|
|
|
|
|
|
|
|
func checkRunning() (bool, error) {
|
2023-06-01 20:45:22 -04:00
|
|
|
o, err := exec.RunCommandByShell("systemctl status V2bX | grep Active")
|
2023-05-23 22:26:14 -04:00
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
return strings.Contains(o, "running"), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func Err(msg ...any) string {
|
|
|
|
return red + fmt.Sprint(msg...) + plain
|
|
|
|
}
|
|
|
|
|
|
|
|
func Ok(msg ...any) string {
|
|
|
|
return green + fmt.Sprint(msg...) + plain
|
|
|
|
}
|
|
|
|
|
|
|
|
func Warn(msg ...any) string {
|
|
|
|
return yellow + fmt.Sprint(msg...) + plain
|
|
|
|
}
|