mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 07:04:57 +01:00
Merge pull request #1408 from tgstation/aa/service-runner-change
Service installer will now ask to remove old ones
This commit is contained in:
@@ -118,6 +118,32 @@ namespace Tgstation.Server.Host.Service
|
||||
{
|
||||
if (Uninstall)
|
||||
return; // oh no, it's retarded...
|
||||
|
||||
// First check if the service already exists
|
||||
if (Environment.UserInteractive)
|
||||
foreach (ServiceController sc in ServiceController.GetServices())
|
||||
if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4")
|
||||
{
|
||||
DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo);
|
||||
if (result != DialogResult.Yes)
|
||||
return; // is this needed after exit?
|
||||
|
||||
// Stop it first to give it some cleanup time
|
||||
if (sc.Status == ServiceControllerStatus.Running)
|
||||
{
|
||||
sc.Stop();
|
||||
sc.WaitForStatus(ServiceControllerStatus.Stopped);
|
||||
}
|
||||
|
||||
// And remove it
|
||||
using (ServiceInstaller si = new ServiceInstaller())
|
||||
{
|
||||
si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null);
|
||||
si.ServiceName = sc.ServiceName;
|
||||
si.Uninstall(null);
|
||||
}
|
||||
}
|
||||
|
||||
using (var processInstaller = new ServiceProcessInstaller())
|
||||
using (var installer = new ServiceInstaller())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user