mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-20 06:07:57 +00:00
Merge pull request #271 from resin-io/239-fix-disable-logs-to-display
Fix disabling logs to display on newer OS with different service name
This commit is contained in:
commit
719df9adfe
@ -1,3 +1,4 @@
|
||||
* Fix disabling logs to display on newer OS with different service name [Pablo]
|
||||
* In cleanup, normalize all image tags for comparison [Pablo]
|
||||
* Use getRegistryAndName from docker-toolbelt 1.2.0 [Pablo]
|
||||
|
||||
|
@ -223,7 +223,8 @@ func VPNControl(writer http.ResponseWriter, request *http.Request) {
|
||||
//LogToDisplayControl is used to control tty-replacement service status with dbus
|
||||
func LogToDisplayControl(writer http.ResponseWriter, request *http.Request) {
|
||||
sendResponse, sendError := responseSenders(writer)
|
||||
serviceName := "tty-replacement.service"
|
||||
serviceName := "resin-info@tty1.service"
|
||||
serviceNameOld := "tty-replacement.service"
|
||||
var body LogToDisplayBody
|
||||
if err := parseJSONBody(&body, request); err != nil {
|
||||
log.Println(err)
|
||||
@ -236,6 +237,15 @@ func LogToDisplayControl(writer http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if loaded, err := systemd.Dbus.GetUnitProperty(serviceName, "LoadState"); err != nil {
|
||||
sendError(fmt.Errorf("Unable to get log to display load status: %v", err))
|
||||
return
|
||||
} else if loaded.Value.String() == `"not-found"` {
|
||||
// If the resin-info service is not found, we're on an older OS
|
||||
// which uses a different service name
|
||||
serviceName = serviceNameOld
|
||||
}
|
||||
|
||||
if activeState, err := systemd.Dbus.GetUnitProperty(serviceName, "ActiveState"); err != nil {
|
||||
sendError(fmt.Errorf("Unable to get log to display status: %v", err))
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user