Add an option to control whether Sunshine starts on boot

This commit is contained in:
Cameron Gutman 2023-05-23 21:00:41 -05:00
parent a87d8335bd
commit fe62b10324
3 changed files with 18 additions and 1 deletions

View File

@ -712,6 +712,11 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
DESTINATION "scripts"
COMPONENT assets)
# Configurable options for the service
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/autostart/"
DESTINATION "scripts"
COMPONENT autostart)
# scripts
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/firewall/"
DESTINATION "scripts"
@ -747,6 +752,7 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\add-firewall-rule.bat\\\"'
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-service.bat\\\"'
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-vigembus.bat\\\"'
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\autostart-service.bat\\\"'
NoController:
")
@ -804,6 +810,11 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
set(CPACK_COMPONENT_APPLICATION_REQUIRED true)
set(CPACK_COMPONENT_APPLICATION_DEPENDS assets)
# service auto-start script
set(CPACK_COMPONENT_AUTOSTART_DISPLAY_NAME "Launch on Startup")
set(CPACK_COMPONENT_AUTOSTART_DESCRIPTION "If enabled, launches Sunshine automatically on system startup.")
set(CPACK_COMPONENT_AUTOSTART_GROUP "Core")
# assets
set(CPACK_COMPONENT_ASSETS_DISPLAY_NAME "Required Assets")
set(CPACK_COMPONENT_ASSETS_DESCRIPTION "Shaders, default box art, and web UI.")

View File

@ -0,0 +1,4 @@
@echo off
rem Set the service to auto-start
sc config sunshinesvc start= auto

View File

@ -5,7 +5,9 @@ for %%I in ("%~dp0\..") do set "ROOT_DIR=%%~fI"
set SERVICE_NAME=sunshinesvc
set SERVICE_BIN="%ROOT_DIR%\tools\sunshinesvc.exe"
set SERVICE_START_TYPE=auto
rem Set service to demand start. It will be changed to auto later if the user selected that option.
set SERVICE_START_TYPE=demand
rem Check if sunshinesvc already exists
sc qc %SERVICE_NAME% > nul 2>&1