1 Star 0 Fork 0

坐公交也用券/glbm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
service.go 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
坐公交也用券 提交于 2023-02-24 18:04 . 控制日志打印
package glbm
import (
"fmt"
"strings"
"gitee.com/liumou_site/gf"
)
func (api *ApiService) Start() {
api.sudo.RunSudo("systemctl start ", api.Name)
api.Err = api.sudo.Err
}
func (api *ApiService) ReStart() {
api.sudo.RunSudo("systemctl restart", api.Name)
api.Err = api.sudo.Err
}
func (api *ApiService) Stop() {
api.sudo.RunSudo("systemctl stop", api.Name)
api.Err = api.sudo.Err
}
func (api *ApiService) ReLoad() *ApiService {
api.sudo.RunSudo("systemctl reload", api.Name)
api.Err = api.sudo.Err
return api
}
func (api *ApiService) Enable() *ApiService {
api.sudo.RunSudo("systemctl enable", api.Name)
api.Err = api.sudo.Err
return api
}
func (api *ApiService) Disable() *ApiService {
api.sudo.RunSudo("systemctl disable", api.Name)
api.Err = api.sudo.Err
return api
}
func (api *ApiService) ReLoadDaemon() *ApiService {
api.sudo.RunSudo("systemctl reload-daemon")
api.Err = api.sudo.Err
return api
}
func (api *ApiService) Exists() bool {
api.sudo.RunScriptSudo("systemctl -all| awk '{print $1}'")
r := gf.NewReadFile("demo")
r.Text = api.sudo.Strings
services := strings.Split(r.Text, "\n")
fmt.Println(services)
for _, s := range services {
if strings.Contains(s, api.Name) {
return true
}
}
return false
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/liumou_site/glbm.git
git@gitee.com:liumou_site/glbm.git
liumou_site
glbm
glbm
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385