mirror of
https://github.com/SillyTavern/SillyTavern-Launcher.git
synced 2026-04-27 01:39:03 +00:00
Merge pull request #57 from BlueprintCoding/main
Create and Use SSL for - Conflicts Resolved and Gitingore Fixed.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,4 +5,5 @@ text-completion/
|
||||
image-generation/
|
||||
voice-generation/
|
||||
xtts/
|
||||
bin/
|
||||
bin/
|
||||
!bin/create_ssl.bat
|
||||
107
Launcher.bat
107
Launcher.bat
@@ -370,11 +370,20 @@ REM ############################################################
|
||||
cd /d "%st_install_path%"
|
||||
title STL [HOME]
|
||||
cls
|
||||
|
||||
set "SSL_INFO_FILE=%~dp0\SillyTavern\certs\SillyTavernSSLInfo.txt"
|
||||
set "sslOptionSuffix="
|
||||
|
||||
REM Check if the SSL info file exists and set the suffix
|
||||
if exist "%SSL_INFO_FILE%" (
|
||||
set "sslOptionSuffix= (With SSL)"
|
||||
)
|
||||
|
||||
echo %blue_fg_strong%/ Home%reset%
|
||||
echo -------------------------------------------------------------
|
||||
echo What would you like to do?
|
||||
echo 1. Start SillyTavern
|
||||
echo 2. Start SillyTavern With Remote Link
|
||||
echo 1. Start SillyTavern%sslOptionSuffix%
|
||||
echo 2. Start SillyTavern With Remote Link%sslOptionSuffix%
|
||||
REM Check if the custom shortcut file exists and is not empty
|
||||
set "custom_name=Create Custom App Shortcut to Launch with SillyTavern" ; Initialize to default
|
||||
if exist "%~dp0bin\settings\custom-shortcut.txt" (
|
||||
@@ -458,6 +467,8 @@ if %errorlevel% neq 0 (
|
||||
goto :home
|
||||
)
|
||||
|
||||
|
||||
|
||||
setlocal
|
||||
set "command=%~1"
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Starting %command%
|
||||
@@ -472,10 +483,21 @@ for /f "tokens=2 delims=," %%a in ('tasklist /FI "IMAGENAME eq cmd.exe" /FO CSV
|
||||
endlocal
|
||||
|
||||
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched in a new window.
|
||||
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && node server.js && pause && popd"
|
||||
REM Check if SSL info file exists and set the command accordingly
|
||||
if exist "%SSL_INFO_FILE%" (
|
||||
for /f "skip=0 tokens=*" %%i in ('type "%SSL_INFO_FILE%"') do (
|
||||
goto :sslPathsFound
|
||||
)
|
||||
:sslPathsFound
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched with SSL in a new window.
|
||||
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && node server.js --ssl && pause && popd"
|
||||
) else (
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched in a new window.
|
||||
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && node server.js && pause && popd"
|
||||
)
|
||||
goto :home
|
||||
|
||||
|
||||
:start_st_rl
|
||||
REM Check if the folder exists
|
||||
if not exist "%st_install_path%" (
|
||||
@@ -493,11 +515,22 @@ if %errorlevel% neq 0 (
|
||||
pause
|
||||
goto :home
|
||||
)
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched in a new window.
|
||||
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && node server.js && pause && popd"
|
||||
start "" "%st_install_path%\Remote-Link.cmd"
|
||||
goto :home
|
||||
|
||||
REM Check if SSL info file exists and set the command accordingly
|
||||
if exist "%SSL_INFO_FILE%" (
|
||||
for /f "skip=0 tokens=*" %%i in ('type "%SSL_INFO_FILE%"') do (
|
||||
goto :sslPathsFoundRL
|
||||
)
|
||||
:sslPathsFoundRL
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched with SSL in a new window.
|
||||
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && node server.js --ssl && pause && popd"
|
||||
start "" "%~dp0SillyTavern\Remote-Link.cmd"
|
||||
) else (
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched in a new window.
|
||||
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && node server.js && pause && popd"
|
||||
start "" "%~dp0SillyTavern\Remote-Link.cmd"
|
||||
)
|
||||
goto :home
|
||||
|
||||
REM ############################################################
|
||||
REM ############## UPDATE MANAGER - FRONTEND ###################
|
||||
@@ -4681,12 +4714,27 @@ REM ############################################################
|
||||
:editor_core_utilities
|
||||
title STL [EDITOR CORE UTILITIES]
|
||||
cls
|
||||
set "SSL_INFO_FILE=%~dp0SillyTavern\certs\SillyTavernSSLInfo.txt"
|
||||
set "sslOption=2. Create and Use Self-Signed SSL Certificate with SillyTavern to encrypt your connection &echo %blue_fg_strong%Read More: https://sillytavernai.com/launcher-ssl (press 9 to open)%reset%"
|
||||
|
||||
REM Check if the SSL info file exists and read the expiration date
|
||||
if exist "%SSL_INFO_FILE%" (
|
||||
for /f "skip=2 tokens=*" %%i in ('type "%SSL_INFO_FILE%"') do (
|
||||
set "expDate=%%i"
|
||||
goto :infoFound
|
||||
)
|
||||
:infoFound
|
||||
set "sslOption=2. Regenerate SillyTavern SSL - %expDate% &echo %blue_fg_strong%SSL NOTE 1: You%reset% %red_fg_strong%WILL%reset% %blue_fg_strong%need to add the Self-Signed Cert as trusted in your browser on first launch. How to here: https://sillytavernai.com/launcher-ssl (press 9 to open)%reset% &echo %blue_fg_strong%SSL NOTE 2: To remove the SSL press 8%reset%"
|
||||
|
||||
)
|
||||
|
||||
echo %blue_fg_strong%/ Home / Toolbox / Editor / Core Utilities%reset%
|
||||
echo -------------------------------------------------------------
|
||||
echo What would you like to do?
|
||||
echo 1. Edit SillyTavern config.yaml
|
||||
echo 2. Edit Extras
|
||||
echo 3. Edit Environment Variables
|
||||
echo %sslOption%
|
||||
echo 3. Edit Extras
|
||||
echo 4. Edit Environment Variables
|
||||
echo 0. Back
|
||||
|
||||
set /p editor_core_util_choice=Choose Your Destiny:
|
||||
@@ -4695,11 +4743,19 @@ REM ######## EDITOR CORE UTILITIES - FRONTEND ##################
|
||||
if "%editor_core_util_choice%"=="1" (
|
||||
call :edit_st_config
|
||||
) else if "%editor_core_util_choice%"=="2" (
|
||||
call :edit_extras_modules
|
||||
call :create_st_ssl
|
||||
) else if "%editor_core_util_choice%"=="3" (
|
||||
call :edit_extras_modules
|
||||
) else if "%editor_core_util_choice%"=="4" (
|
||||
call :edit_env_var
|
||||
) else if "%editor_core_util_choice%"=="0" (
|
||||
goto :editor
|
||||
) else if "%editor_core_util_choice%"=="8" (
|
||||
goto :delete_st_ssl
|
||||
) else if "%editor_core_util_choice%"=="9" (
|
||||
echo Opening SillyTavernai.com SSL Info Page
|
||||
start "" "https://sillytavernai.com/launcher-ssl"
|
||||
goto :editor_core_utilities
|
||||
) else (
|
||||
echo [%DATE% %TIME%] %log_invalidinput% >> %log_path%
|
||||
echo %red_bg%[%time%]%reset% %echo_invalidinput%
|
||||
@@ -4711,6 +4767,35 @@ if "%editor_core_util_choice%"=="1" (
|
||||
start "" "%st_install_path%\config.yaml"
|
||||
goto :editor_core_utilities
|
||||
|
||||
:create_st_ssl
|
||||
call "%~dp0bin\create_ssl.bat" no-pause
|
||||
:: Check the error level returned by the main batch file
|
||||
if %errorlevel% equ 0 (
|
||||
echo %green_fg_strong%The SSL was created successfully.%reset%
|
||||
) else (
|
||||
echo %red_fg_strong%The SSL creation encountered an error. Please see \bin\SSL-Certs\ssl_error_log.txt for more info.%reset%
|
||||
)
|
||||
pause
|
||||
goto :editor_core_utilities
|
||||
|
||||
:delete_st_ssl
|
||||
REM Check if the SillyTavern\certs folder exists and delete it if it does
|
||||
set "CERTS_DIR=%~dp0SillyTavern\certs"
|
||||
|
||||
if exist "%CERTS_DIR%" (
|
||||
echo %blue_fg_strong%Deleting %CERTS_DIR% ...%reset%
|
||||
rmdir /s /q "%CERTS_DIR%"
|
||||
if errorlevel 0 (
|
||||
echo %green_fg_strong%The SillyTavern\certs folder has been successfully deleted.%reset%
|
||||
) else (
|
||||
echo %red_fg_strong%Failed to delete the SillyTavern\certs folder. Please check if the folder is in use and try again.%reset%
|
||||
)
|
||||
) else (
|
||||
echo %red_fg_strong%The SillyTavern\certs folder does not exist.%reset%
|
||||
)
|
||||
pause
|
||||
goto :editor_core_utilities
|
||||
|
||||
REM ##################################################################################################################################################
|
||||
REM ##################################################################################################################################################
|
||||
REM ##################################################################################################################################################
|
||||
|
||||
114
bin/create_ssl.bat
Normal file
114
bin/create_ssl.bat
Normal file
@@ -0,0 +1,114 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
:: Check if a specific argument is passed to detect if called by another batch file
|
||||
set "pauseRequired=false"
|
||||
set "silentMode=false"
|
||||
if "%~1"=="" (
|
||||
set "pauseRequired=true"
|
||||
) else (
|
||||
set "silentMode=true"
|
||||
)
|
||||
|
||||
:: Redirect output to NUL if in silent mode
|
||||
if "%silentMode%"=="true" (
|
||||
set "outputRedirection=>nul 2>&1"
|
||||
) else (
|
||||
set "outputRedirection="
|
||||
)
|
||||
|
||||
:: Set the SSL certificate directory and files
|
||||
set "SILLYTAVERN_DIR=%~dp0..\SillyTavern"
|
||||
set "CERT_DIR=%SILLYTAVERN_DIR%\certs"
|
||||
set "CERT_FILE=%CERT_DIR%\cert.pem"
|
||||
set "KEY_FILE=%CERT_DIR%\privkey.pem"
|
||||
set "CERT_INFO_FILE=%CERT_DIR%\SillyTavernSSLInfo.txt"
|
||||
set "ERROR_LOG=%CERT_DIR%\error_log.txt"
|
||||
|
||||
:: Check if the SillyTavern directory exists
|
||||
if not exist "%SILLYTAVERN_DIR%" (
|
||||
echo Please install SillyTavern first.
|
||||
if "%pauseRequired%"=="true" pause
|
||||
endlocal
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Create the SSL certificate directory if it doesn't exist
|
||||
if not exist "%CERT_DIR%" (
|
||||
mkdir "%CERT_DIR%"
|
||||
echo Created directory %CERT_DIR% %outputRedirection%
|
||||
) else (
|
||||
echo Directory %CERT_DIR% already exists. %outputRedirection%
|
||||
)
|
||||
|
||||
:: Check if the certificate already exists and delete it if it does
|
||||
if exist "%CERT_FILE%" (
|
||||
del "%CERT_FILE%"
|
||||
echo Existing certificate deleted. %outputRedirection%
|
||||
)
|
||||
|
||||
if exist "%KEY_FILE%" (
|
||||
del "%KEY_FILE%"
|
||||
echo Existing key deleted. %outputRedirection%
|
||||
)
|
||||
|
||||
:: Find the Git installation directory
|
||||
for /f "delims=" %%i in ('where git') do (
|
||||
set "gitPath=%%i"
|
||||
goto :foundGit
|
||||
)
|
||||
|
||||
:foundGit
|
||||
:: Extract the directory from the git.exe path
|
||||
for %%i in ("%gitPath%") do set "gitDir=%%~dpi"
|
||||
|
||||
:: Remove the bin\ or cmd\ part to get the main Git installation directory
|
||||
set "gitDir=%gitDir:bin\=%"
|
||||
set "gitDir=%gitDir:cmd\=%"
|
||||
|
||||
echo Git is installed at: %gitDir% %outputRedirection%
|
||||
|
||||
:: Find openssl.exe within the Git installation directory
|
||||
for /f "delims=" %%i in ('dir "%gitDir%" /s /b ^| findstr \\openssl.exe') do (
|
||||
set "opensslPath=%%i"
|
||||
goto :foundOpenSSL
|
||||
)
|
||||
|
||||
:foundOpenSSL
|
||||
echo OpenSSL is located at: %opensslPath% %outputRedirection%
|
||||
|
||||
:: Generate the self-signed certificate in PEM format
|
||||
echo Generating self-signed certificate... %outputRedirection%
|
||||
"%opensslPath%" req -x509 -newkey rsa:4096 -keyout "%KEY_FILE%" -out "%CERT_FILE%" -days 825 -nodes -subj "/CN=127.0.0.1" %outputRedirection%
|
||||
|
||||
if %errorlevel% neq 0 goto error
|
||||
echo Certificate generation complete. %outputRedirection%
|
||||
|
||||
:: Calculate the expiration date (today + 825 days) and format as mm/dd/yyyy
|
||||
for /f %%i in ('powershell -command "[datetime]::Now.AddDays(825).ToString('MM/dd/yyyy')"') do (
|
||||
set "expDate=%%i"
|
||||
)
|
||||
|
||||
:: Store the certificate and key path, and expiration date in the text file
|
||||
:: Correcting the paths to remove the "bin\.."
|
||||
set "correctCertPath=%SILLYTAVERN_DIR:\..\SillyTavern=\\SillyTavern%\certs\cert.pem"
|
||||
set "correctKeyPath=%SILLYTAVERN_DIR:\..\SillyTavern=\\SillyTavern%\certs\privkey.pem"
|
||||
|
||||
echo %correctCertPath% > "%CERT_INFO_FILE%"
|
||||
echo %correctKeyPath% >> "%CERT_INFO_FILE%"
|
||||
echo SSL Expiration Date (mm/dd/yyyy): %expDate% >> "%CERT_INFO_FILE%"
|
||||
echo Certificate and key paths and expiration date stored in %CERT_INFO_FILE%. %outputRedirection%
|
||||
|
||||
echo Done. %outputRedirection%
|
||||
if "%pauseRequired%"=="true" pause
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
:error
|
||||
echo An error occurred. Please check the console output for details. %outputRedirection%
|
||||
:: Log the error to the log file
|
||||
echo [%date% %time%] An error occurred during certificate generation. >> "%ERROR_LOG%"
|
||||
if "%pauseRequired%"=="true" pause
|
||||
endlocal
|
||||
exit /b 1
|
||||
goto :eof
|
||||
Reference in New Issue
Block a user