Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/service/"
DESTINATION "scripts"
COMPONENT service)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/migration/"
DESTINATION "scripts"
COMPONENT assets)

# Sunshine assets
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/"
Expand All @@ -548,12 +551,16 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")

# Extra install commands
# Sets permissions on the installed folder so that we can write in it
# Restores permissions on the install directory
# Migrates config files from the root into the new config folder
# Sets permissions on the config folder so that we can write in it
# Install service
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
ExecWait '\\\"$SYSDIR\\\\cmd.exe\\\" /c \\\"start https://sunshinestream.readthedocs.io/\\\"'
ExecWait 'icacls \\\"$INSTDIR\\\" /grant:r Users:\\\(OI\\\)\\\(CI\\\)\\\(F\\\)'
ExecWait 'icacls \\\"$INSTDIR\\\" /reset'
ExecWait '\\\"$INSTDIR\\\\scripts\\\\migrate-config.bat\\\"'
ExecWait 'icacls \\\"$INSTDIR\\\\config\\\" /grant:r Users:\\\(OI\\\)\\\(CI\\\)\\\(F\\\)'
ExecWait '\\\"$INSTDIR\\\\scripts\\\\add-firewall-rule.bat\\\"'
ExecWait '\\\"$INSTDIR\\\\scripts\\\\install-service.bat\\\"'
MessageBox MB_YESNO|MB_ICONQUESTION 'Do you want to add/update ViGEmBus (virtual controller support)?' \
Expand Down
2 changes: 1 addition & 1 deletion docs/source/about/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ location by modifying the configuration file.
Docker /config/
Linux ~/.config/sunshine/
macOS ~/.config/sunshine/
Windows ./config/
Windows %ProgramFiles%\\Sunshine\\config
========= ===========

**Example**
Expand Down
4 changes: 3 additions & 1 deletion src/platform/windows/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ namespace platf {
using adapteraddrs_t = util::c_ptr<IP_ADAPTER_ADDRESSES>;

std::filesystem::path appdata() {
return L"."sv;
WCHAR sunshine_path[MAX_PATH];
GetModuleFileNameW(NULL, sunshine_path, _countof(sunshine_path));
return std::filesystem::path { sunshine_path }.remove_filename() / L"config"sv;
}

std::string from_sockaddr(const sockaddr *const socket_address) {
Expand Down
1 change: 0 additions & 1 deletion src_assets/linux/assets/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
},
{
"name": "Steam BigPicture",
"output": "steam.txt",
"detached": [
"setsid steam steam://open/bigpicture"
],
Expand Down
1 change: 0 additions & 1 deletion src_assets/macos/assets/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
{
"name": "Steam BigPicture",
"output": "steam.txt",
"detached": [
"open steam://open/bigpicture"
],
Expand Down
1 change: 0 additions & 1 deletion src_assets/windows/assets/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
{
"name": "Steam BigPicture",
"output": "steam.txt",
"detached": [
"steam steam://open/bigpicture"
],
Expand Down
46 changes: 46 additions & 0 deletions src_assets/windows/misc/migration/migrate-config.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@echo off

rem Get sunshine root directory
for %%I in ("%~dp0\..") do set "OLD_DIR=%%~fI"

rem Create the config directory if it didn't already exist
set "NEW_DIR=%OLD_DIR%\config"
if not exist "%NEW_DIR%\" mkdir "%NEW_DIR%"

rem Migrate all files that aren't already present in the config dir
if exist "%OLD_DIR%\apps.json" (
if not exist "%NEW_DIR%\apps.json" (
move "%OLD_DIR%\apps.json" "%NEW_DIR%\apps.json"
)
)
if exist "%OLD_DIR%\sunshine.conf" (
if not exist "%NEW_DIR%\sunshine.conf" (
move "%OLD_DIR%\sunshine.conf" "%NEW_DIR%\sunshine.conf"
)
)
if exist "%OLD_DIR%\sunshine_state.json" (
if not exist "%NEW_DIR%\sunshine_state.json" (
move "%OLD_DIR%\sunshine_state.json" "%NEW_DIR%\sunshine_state.json"
)
)

rem Migrate the credentials directory
if exist "%OLD_DIR%\credentials\" (
if not exist "%NEW_DIR%\credentials\" (
move "%OLD_DIR%\credentials" "%NEW_DIR%\"
)
)

rem Migrate the covers directory
if exist "%OLD_DIR%\covers\" (
if not exist "%NEW_DIR%\covers\" (
move "%OLD_DIR%\covers" "%NEW_DIR%\"

rem Fix apps.json image path values that point at the old covers directory
powershell -c "(Get-Content '%NEW_DIR%\apps.json').replace('.\/covers\/', '.\/config\/covers\/') | Set-Content '%NEW_DIR%\apps.json'"
)
)

rem Remove log files
del "%OLD_DIR%\*.txt"
del "%OLD_DIR%\*.log"