Skip to content

Commit 2e954a5

Browse files
TomYogvnTomYogvn
andauthored
Made the installer prompt you to select the service startup type (#347)
* Made the service start immediately after boot Made the service start immediately after boot by changing its startup type from "delayed-auto" to "auto" to prevent systems being left unprotected for a short period of time after boot. Signed-off-by: TomYogvn <[email protected]> * Revert "Made the service start immediately after boot" This reverts commit b5e5e1d. Signed-off-by: TomYogvn <[email protected]> * Made the installer prompt you to select the service startup type Made the installer prompt you to select the service startup type and inform you that the default is "delayed-auto" for non-interactive installs which waits for the higher priority services to start leaving systems unprotected for a short period of time after boot while the recommended is "auto" however when using the latter you may encounter compatibility issues and if you choose to do so you should verify the service starts correctly after reboot. Signed-off-by: TomYogvn <[email protected]> --------- Signed-off-by: TomYogvn <[email protected]> Co-authored-by: TomYogvn <[email protected]>
1 parent 5ced365 commit 2e954a5

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

IPBanCore/Windows/Scripts/install_latest.ps1

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ param
2121
[Parameter(Mandatory=$False, Position = 1)]
2222
[Boolean] $silent = $False,
2323
[Parameter(Mandatory=$False, Position = 2)]
24-
[Boolean] $autostart = $True
24+
[Boolean] $autostart = $True,
25+
[Parameter(Mandatory=$False, Position = 3)]
26+
[ValidateSet("delayed-auto", "auto")]
27+
[String] $startupType = $null
2528
)
2629

2730
if ($PSVersionTable.PSVersion.Major -lt 5 -or ($PSVersionTable.PSVersion.Major -eq 5 -and $PSVersionTable.PSVersion.Minor -lt 1))
@@ -130,8 +133,38 @@ if (Test-Path -Path "$tempPath\nlog.config")
130133
& auditpol.exe /set /category:"{69979849-797A-11D9-BED3-505054503030}" /success:enable /failure:enable
131134
& auditpol.exe /set /category:"{69979850-797A-11D9-BED3-505054503030}" /success:enable /failure:enable
132135

136+
# prompt for startup type if not already specified
137+
if ($silent -eq $True)
138+
{
139+
if ([string]::IsNullOrEmpty($startupType))
140+
{
141+
$startupType = "delayed-auto"
142+
}
143+
}
144+
elseif ([string]::IsNullOrEmpty($startupType))
145+
{
146+
Write-Host "`n"
147+
Write-Host "Select the services startup type:"
148+
Write-Host '- The default is "delayed-auto" which waits for the higher priority services to start leaving the system briefly unprotected after boot while the recommended is "auto" however when using the latter you may encounter compatibility issues if you choose to do so please verify the service starts correctly after reboot.'
149+
Write-Host "1. delayed-auto"
150+
Write-Host "2. auto"
151+
152+
do
153+
{
154+
$choice = Read-Host "Enter selection"
155+
156+
switch ($choice)
157+
{
158+
"1" { $startupType = "delayed-auto"; Write-Host "You selected: $startupType`n" }
159+
"2" { $startupType = "auto"; Write-Host "You selected: $startupType`n" }
160+
default { Write-Host "Invalid selection, please enter 1-2!" }
161+
}
162+
}
163+
while ([string]::IsNullOrEmpty($startupType))
164+
}
165+
133166
# create service
134-
& sc.exe create IPBAN type= own start= delayed-auto binPath= $INSTALL_EXE DisplayName= $SERVICE_NAME
167+
& sc.exe create IPBAN type= own start= $startupType binPath= $INSTALL_EXE DisplayName= $SERVICE_NAME
135168
& sc.exe description IPBAN "Automatically builds firewall rules for abusive login attempts: https://github.com/DigitalRuby/IPBan"
136169
& sc.exe failure IPBAN reset= 9999 actions= "restart/60000/restart/60000/restart/60000"
137170
if ($autostart -eq $True)

0 commit comments

Comments
 (0)