mirror of
https://github.com/Evidlo/remarkable_printer.git
synced 2024-10-20 03:27:37 -04:00
only restart xochitl if service enabled
This commit is contained in:
parent
8531bea5e3
commit
7e50dbb48f
15
main.go
15
main.go
|
@ -42,7 +42,7 @@ func main() {
|
||||||
|
|
||||||
// ----- Parse options -----
|
// ----- Parse options -----
|
||||||
|
|
||||||
debug := flag.Bool("debug", false, "enable debug output")
|
debug_flag := flag.Bool("debug", false, "enable debug output")
|
||||||
test := flag.Bool("test", false, "use /tmp as output dir")
|
test := flag.Bool("test", false, "use /tmp as output dir")
|
||||||
restart := flag.Bool("restart", false, "restart xochitl after saving PDF")
|
restart := flag.Bool("restart", false, "restart xochitl after saving PDF")
|
||||||
CONN_HOST := flag.String("host", CONN_HOST, "override bind address")
|
CONN_HOST := flag.String("host", CONN_HOST, "override bind address")
|
||||||
|
@ -50,8 +50,9 @@ func main() {
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *debug {
|
if *debug_flag {
|
||||||
LOG_LEVEL = "debug"
|
LOG_LEVEL = "debug"
|
||||||
|
debug("Debugging enabled")
|
||||||
}
|
}
|
||||||
if *test {
|
if *test {
|
||||||
XOCHITL_DIR = "/tmp/"
|
XOCHITL_DIR = "/tmp/"
|
||||||
|
@ -77,9 +78,13 @@ func main() {
|
||||||
|
|
||||||
// Restart xochitl
|
// Restart xochitl
|
||||||
if *restart {
|
if *restart {
|
||||||
stdout, err := exec.Command("systemctl", "restart", "xochitl").CombinedOutput()
|
stdout, exitcode := exec.Command("systemctl", "is-enabled", "xochitl").CombinedOutput()
|
||||||
if err != nil {
|
if exitcode != nil {
|
||||||
fmt.Println("xochitl restart failed with message:", string(stdout))
|
debug("Restarting xochitl")
|
||||||
|
stdout, err := exec.Command("systemctl", "restart", "xochitl").CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("xochitl restart failed with message:", string(stdout))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue