Start a tinc service if it already exists.

This commit is contained in:
Guus Sliepen 2009-11-01 15:57:28 +01:00
parent 6f6f426b35
commit d331f04e45

View file

@ -103,13 +103,18 @@ bool install_service(void) {
command, NULL, NULL, NULL, NULL, NULL); command, NULL, NULL, NULL, NULL, NULL);
if(!service) { if(!service) {
logger(LOG_ERR, "Could not create %s service: %s", identname, winerror(GetLastError())); DWORD lasterror = GetLastError();
return false; logger(LOG_ERR, "Could not create %s service: %s", identname, winerror(lasterror));
if(lasterror != ERROR_SERVICE_EXISTS)
return false;
} }
ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &description); if(service) {
ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &description);
logger(LOG_INFO, "%s service installed", identname); logger(LOG_INFO, "%s service installed", identname);
} else {
service = OpenService(manager, identname, SERVICE_ALL_ACCESS);
}
if(!StartService(service, 0, NULL)) if(!StartService(service, 0, NULL))
logger(LOG_WARNING, "Could not start %s service: %s", identname, winerror(GetLastError())); logger(LOG_WARNING, "Could not start %s service: %s", identname, winerror(GetLastError()));