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:
Pablo Carranza Vélez 2016-10-05 16:07:43 -03:00 committed by GitHub
commit 719df9adfe
2 changed files with 12 additions and 1 deletions

View File

@ -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]

View File

@ -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