Migrate Windows config files into specific config directory (#716)

This commit is contained in:
Cameron Gutman
2023-01-07 12:34:06 -06:00
committed by GitHub
parent 9b6d0b7a06
commit c95f54f874
7 changed files with 59 additions and 7 deletions

View File

@@ -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"