private static LinuxServiceSettings CreateServiceSettings(HostSettings settings, string commandLine)
{
var currentAssembly = Assembly.GetEntryAssembly();
if (currentAssembly == null)
{
throw new InstallException(Resources.ServiceMustBeExecutableFile);
}
var serviceName = settings.Name;
if (!string.IsNullOrEmpty(settings.InstanceName))
{
serviceName += "@" + settings.InstanceName;
}
var result = new LinuxServiceSettings
{
ServiceName = serviceName,
DisplayName = settings.DisplayName,
Description = settings.Description,
ServiceExe = currentAssembly.Location,
ServiceArgs = commandLine
};
var installSettings = settings as InstallHostSettings;
if (installSettings != null)
{
result.Username = installSettings.Credentials?.Username;
result.Dependencies = installSettings.Dependencies;
}
return result;
}