Added Tailscale VPN installer and configuration

incremented to 24.1.5.0
This commit is contained in:
Blueprint Coding
2024-09-04 16:17:00 -06:00
parent 8bb38755db
commit 0afd6905de
3 changed files with 159 additions and 0 deletions

View File

@@ -3160,6 +3160,7 @@ echo 4. Install yq
echo 5. Install Visual Studio BuildTools
echo 6. Install CUDA Toolkit
echo 7. Install w64devkit
echo 8. Install Tailscale (VPN to access SillyTavern remotely)
echo %cyan_fg_strong% ______________________________________________________________%reset%
echo %cyan_fg_strong%^| Menu Options: ^|%reset%
echo 0. Back
@@ -3266,6 +3267,19 @@ if "%app_installer_core_util_choice%"=="1" (
pause
goto :app_installer_core_utilities
)
) else if "%app_installer_core_util_choice%"=="8" (
set "caller=app_installer_core_utilities"
if exist "%app_installer_core_utilities_dir%\install_tailscale.bat" (
call %app_installer_core_utilities_dir%\install_tailscale.bat
goto :app_installer_core_utilities
) else (
echo [%DATE% %TIME%] ERROR: install_tailscale.bat not found in: %app_installer_core_utilities_dir% >> %logs_stl_console_path%
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] install_tailscale.bat not found in: %app_installer_core_utilities_dir%%reset%
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Running Automatic Repair...
git pull
pause
goto :app_installer_core_utilities
)
) else if "%app_installer_core_util_choice%"=="0" (
goto :app_installer
) else (
@@ -4065,6 +4079,7 @@ echo 1. Edit SillyTavern config.yaml
echo %sslOption%
echo 3. Edit Extras
echo 4. Edit Environment Variables
echo 5. View Tailscale configuration
echo %cyan_fg_strong% ____________________________________________________________________________________________%reset%
echo %cyan_fg_strong%^| Menu Options: ^|%reset%
@@ -4115,6 +4130,19 @@ if "%editor_core_utilities_choice%"=="1" (
pause
goto :editor_core_utilities
)
) else if "%editor_core_utilities_choice%"=="5" (
set "caller=editor_core_utilities"
if exist "%app_installer_core_utilities_dir%\config_tailscale.bat" (
call %app_installer_core_utilities_dir%\config_tailscale.bat
goto :editor_core_utilities
) else (
echo [%DATE% %TIME%] ERROR: config_tailscale.bat not found in: %app_installer_core_utilities_dir% >> %logs_stl_console_path%
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] config_tailscale.bat not found in: %app_installer_core_utilities_dir%%reset%
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Running Automatic Repair...
git pull
pause
goto :editor_core_utilities
)
) else if "%editor_core_utilities_choice%"=="8" (
goto :delete_st_ssl
) else if "%editor_core_utilities_choice%"=="9" (

View File

@@ -0,0 +1,86 @@
@echo off
setlocal enabledelayedexpansion
title STL [TAILSCALE CONFIGURATION]
cls
echo / Home / Toolbox / App Installer / Core Utilities / Tailscale
echo -------------------------------------------------------------
rem Calculate the path to the logs folder based on the current script location
set log_dir=%~dp0..\..\..\..\logs
rem Normalize the path
for %%i in ("%log_dir%") do set log_dir=%%~fi
set log_file=%log_dir%\tailscale_status.txt
rem Clear the log file before writing new data
powershell -command "Clear-Content '%log_file%'"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Configuring Tailscale...
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Running Tailscale login...
tailscale up
if %errorlevel%==0 (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Tailscale configuration successful.
echo -------------------------------------------------------------
echo Select an option:
echo 1. Find Tailscale SillyTavern Remote URLs
echo 2. Home
choice /c 12 /m "Enter the number corresponding to your choice:"
if errorlevel 2 (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Returning to Home...
) else if errorlevel 1 (
echo.
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Fetching Tailscale status...
rem Use the dynamic path based on %~dp0 to write to the logs folder
powershell -command ^
"$json = tailscale status --json | ConvertFrom-Json; " ^
"$self = $json.Self; " ^
"$ip4 = $self.TailscaleIPs[0]; " ^
"$hostName = $self.HostName; " ^
"$dnsName = $self.DNSName; " ^
"$logPath = '%~dp0..\..\..\..\logs\tailscale_status.txt'; " ^
"Out-File -FilePath $logPath -InputObject $ip4 -Encoding ascii; " ^
"Out-File -FilePath $logPath -InputObject $hostName -Append -Encoding ascii; " ^
"Out-File -FilePath $logPath -InputObject $dnsName -Append -Encoding ascii"
rem Read the values directly using delayed expansion
set count=0
for /f "tokens=* delims=" %%i in (%log_file%) do (
set /a count+=1
if !count! equ 1 set ip4=%%i
if !count! equ 2 set hostName=%%i
if !count! equ 3 set dnsName=%%i
)
rem Remove trailing period from dnsName if it exists
if "!dnsName:~-1!"=="." set "dnsName=!dnsName:~0,-1!"
echo %blue_fg_strong%-------------------------------------------------------------%reset%
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% "Tailscale Remote SillyTavern URLs (if you changed your SillyTavern Port # change 8000 to that new port):"
echo %cyan_fg_strong%IP4:%reset% http://!ip4!:8000
echo %cyan_fg_strong%Machine Name:%reset% http://!hostName!:8000
echo %cyan_fg_strong%MagicDNS Name:%reset% http://!dnsName!:8000
echo %blue_fg_strong%-------------------------------------------------------------%reset%
rem Prompt the user to open the additional config instructions page
set /p userChoice="Do you want to open the additional configuration instructions page (Y/N)? "
if /i "!userChoice!"=="Y" (
rem Open the configuration URL
powershell -command ^
"$url = 'https://sillytavernai.com/tailscale-config/?HostName=!hostName!&DNSName=!dnsName!&IP4=!ip4!#STL'; " ^
"Start-Process $url"
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Skipping additional configuration instructions.
)
)
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[ERROR]%reset% %red_fg_strong%Tailscale configuration failed.%reset%
)
pause

View File

@@ -0,0 +1,45 @@
:install_tailscale
title STL [INSTALL-TAILSCALE]
set log_dir = %log_dir%
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Do you already have a Tailscale account set up? (Y/N)
set /p tailscale_account="Answer (Y/N): "
if /i "%tailscale_account%"=="Y" (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Checking if Tailscale is already installed and running...
rem Check if Tailscale is running by using the status command
tailscale status >nul 2>&1
if %errorlevel%==0 (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Tailscale is already installed and running. Proceeding to configuration...
call %app_installer_core_utilities_dir%\config_tailscale.bat
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Installing Tailscale...
winget install Tailscale.Tailscale
if %errorlevel%==0 (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%Tailscale installed successfully.%reset%
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Running Tailscale configuration...
call %app_installer_core_utilities_dir%\config_tailscale.bat
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[ERROR]%reset% Tailscale installation failed.%reset%
)
)
pause
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Opening Tailscale sign-up page...
start "" "https://login.tailscale.com/start"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Press any key after signing up to continue installation...
pause
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Installing Tailscale...
winget install Tailscale.Tailscale
if %errorlevel%==0 (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%Tailscale installed successfully.%reset%
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Running Tailscale configuration...
call config_tailscale.bat
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[ERROR]%reset% Tailscale installation failed.%reset%
)
)