Launcher improvements

+ Uninstaller for sillytavern + extras
+ Changed conda env to extras (from sillytavernextras) to fit the docs
+ Improved backend menu functions (removes the elif mess)
+ Function to find a suitable terminal emulator when launching sillytavern or extras
+ Added tutorial on how to use it
This commit is contained in:
deffcolony
2023-11-18 20:36:32 +01:00
parent 8ae245ce01
commit 7534752cfa
4 changed files with 136 additions and 73 deletions

View File

@@ -160,7 +160,7 @@ if not defined choice set "choice=1"
REM Home - backend REM Home - backend
if "%choice%"=="1" ( if "%choice%"=="1" (
call :start call :start_st
) else if "%choice%"=="2" ( ) else if "%choice%"=="2" (
call :start_st_extras call :start_st_extras
) else if "%choice%"=="3" ( ) else if "%choice%"=="3" (
@@ -181,7 +181,7 @@ if "%choice%"=="1" (
) )
:start :start_st
REM Check if Node.js is installed REM Check if Node.js is installed
node --version > nul 2>&1 node --version > nul 2>&1
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (

View File

@@ -1,2 +1,26 @@
# SillyTavern-Launcher # SillyTavern-Launcher
Launcher scripts for SillyTavern and ST-Extras. Launcher scripts for SillyTavern and Extras.
## Usage
### Windows
1. Install [Git for Windows](https://gitforwindows.org/)
2. Open Windows Explorer (`Win+E`) and make or choose a folder where you wanna install the launcher to
3. Open a Command Prompt inside that folder by clicking in the 'Address Bar' at the top, typing `cmd`, and pressing Enter.
4. When you see a black box, insert the following command: `git clone https://github.com/SillyTavern/SillyTavern-Launcher.git`
5. double click on `installer.bat` and choose what you wanna install
6. After installation double click on `launcher.bat`
### Linux
1. Open your favorite terminal and install git
2. Download Sillytavern Launcher with: `git clone https://github.com/SillyTavern/SillyTavern-Launcher.git`
3. Navigate to the SillyTavern-Launcher with: `cd SillyTavern-Launcher`
4. Start the install launcher with: `chmod +x install.sh && ./install.sh` and choose what you wanna install
5. After installation start the launcher with: `chmod +x launcher.sh && ./launcher.sh`
### Mac
1. Open a terminal and install brew with: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
2. Then install git with: `brew install git`
3. Download Sillytavern Launcher with: `git clone https://github.com/SillyTavern/SillyTavern-Launcher.git`
4. Navigate to the SillyTavern-Launcher with: `cd SillyTavern-Launcher`
5. Start the install launcher with: `chmod +x install.sh && ./install.sh` and choose what you wanna install
6. After installation start the launcher with: `chmod +x launcher.sh && ./launcher.sh`

View File

@@ -223,11 +223,11 @@ install_st_extras() {
conda config --set auto_activate_base false conda config --set auto_activate_base false
conda init bash conda init bash
log_message "INFO" "Creating Conda environment sillytavernextras..." log_message "INFO" "Creating Conda environment extras..."
conda create -n sillytavernextras -y conda create -n extras -y
log_message "INFO" "Activating Conda environment sillytavernextras..." log_message "INFO" "Activating Conda environment extras..."
conda activate sillytavernextras conda activate extras
log_message "INFO" "Installing Python and Git in the Conda environment..." log_message "INFO" "Installing Python and Git in the Conda environment..."
conda install python=3.11 git -y conda install python=3.11 git -y
@@ -297,11 +297,11 @@ install_extras() {
conda config --set auto_activate_base false conda config --set auto_activate_base false
conda init bash conda init bash
log_message "INFO" "Creating Conda environment sillytavernextras..." log_message "INFO" "Creating Conda environment extras..."
conda create -n sillytavernextras -y conda create -n extras -y
log_message "INFO" "Activating Conda environment sillytavernextras..." log_message "INFO" "Activating Conda environment extras..."
conda activate sillytavernextras conda activate extras
log_message "INFO" "Installing Python and Git in the Conda environment..." log_message "INFO" "Installing Python and Git in the Conda environment..."
conda install python=3.11 git -y conda install python=3.11 git -y

View File

@@ -164,35 +164,29 @@ home() {
echo -e "Update Status: $update_status" echo -e "Update Status: $update_status"
echo "================================" echo "================================"
read -p "Choose Your Destiny (default is 1): " choice read -p "Choose Your Destiny: " home_choice
# Default to choice 1 if no input is provided # Default to choice 1 if no input is provided
if [ -z "$choice" ]; then if [ -z "$home_choice" ]; then
choice=1 home_choice=1
fi fi
# home - Backend # Home menu - Backend
if [ "$choice" = "1" ]; then case $home_choice in
start_sillytavern 1) start_st ;;
elif [ "$choice" = "2" ]; then 2) start_st_extras ;;
start_sillytavern_with_extras 3) update ;;
elif [ "$choice" = "3" ]; then 4) backup_menu ;;
update 5) switch_branch_menu ;;
elif [ "$choice" = "4" ]; then 6) toolbox ;;
backup_menu 7) exit ;;
elif [ "$choice" = "5" ]; then *) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}"
switch_branch_menu read -p "Press Enter to continue..."
elif [ "$choice" = "6" ]; then home ;;
toolbox esac
elif [ "$choice" = "7" ]; then
exit
else
echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}"
read -p "Press Enter to continue..."
home
fi
} }
# Function to check if Node.js is installed # Function to check if Node.js is installed
check_nodejs() { check_nodejs() {
node --version > /dev/null 2>&1 node --version > /dev/null 2>&1
@@ -206,27 +200,50 @@ check_nodejs() {
} }
# Function to find a suitable terminal emulator
find_terminal() {
for terminal in "$TERMINAL" x-terminal-emulator mate-terminal gnome-terminal terminator xfce4-terminal urxvt rxvt termit Eterm aterm uxterm xterm roxterm termite lxterminal terminology st qterminal lilyterm tilix terminix konsole kitty guake tilda alacritty hyper wezterm; do
if command -v "$terminal" > /dev/null 2>&1; then
echo "$terminal"
return 0
fi
done
# Return a default terminal if none is found
echo "x-terminal-emulator"
return 1
}
# Function to start SillyTavern # Function to start SillyTavern
start_sillytavern() { start_st() {
check_nodejs check_nodejs
log_message "INFO" "SillyTavern launched in a new window." log_message "INFO" "SillyTavern launched in a new window."
# Find a suitable terminal
# Start a terminal emulator for "start.sh" (adjust the command as needed) local detected_terminal
x-terminal-emulator -e "cd $(dirname "$0")./SillyTavern && ./start.sh" & detected_terminal=$(find_terminal)
log_message "INFO" "Found terminal: $detected_terminal"
# Enable read p command for troubleshooting
# read -p "Press Enter to continue..."
# Start SillyTavern in the detected terminal
exec "$detected_terminal" -e "cd $(dirname "$0")./SillyTavern && ./start.sh" &
home home
} }
# Function to start SillyTavern with Extras # Function to start SillyTavern with Extras
start_sillytavern_with_extras() { start_st_extras() {
check_nodejs check_nodejs
# Start a terminal emulator for "start.sh" (adjust the command as needed)
log_message "INFO" "SillyTavern launched in a new window." log_message "INFO" "SillyTavern launched in a new window."
log_message "INFO" "Extras launched in a new window." log_message "INFO" "Extras launched in a new window."
x-terminal-emulator -e "cd $(dirname "$0")./SillyTavern && ./start.sh" & # Find a suitable terminal
x-terminal-emulator -e "cd $(dirname "$0")./SillyTavern-extras && ./start.sh" & local detected_terminal
detected_terminal=$(find_terminal)
log_message "INFO" "Found terminal: $detected_terminal"
# Enable read p command for troubleshooting
# read -p "Press Enter to continue..."
# Start SillyTavern + extras in the detected terminal
exec "$detected_terminal" -e "cd $(dirname "$0")./SillyTavern && ./start.sh" &
exec "$detected_terminal" -e "cd $(dirname "$0")./SillyTavern-extras && ./start.sh" &
home home
} }
@@ -347,21 +364,17 @@ backup_menu() {
read -p "Choose Your Destiny: " backup_choice read -p "Choose Your Destiny: " backup_choice
# Backup menu - Backend # Backup menu - Backend
if [ "$backup_choice" = "1" ]; then case $backup_choice in
create_backup 1) create_backup ;;
elif [ "$backup_choice" = "2" ]; then 2) restore_backup ;;
restore_backup 3) home ;;
elif [ "$backup_choice" = "3" ]; then *) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}"
home read -p "Press Enter to continue..."
else backup_menu ;;
echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}" esac
read -p "Press Enter to continue..."
backup_menu
fi
} }
# Function to switch to the Release branch in SillyTavern # Function to switch to the Release branch in SillyTavern
switch_release_st() { switch_release_st() {
log_message "INFO" "Switching to release branch..." log_message "INFO" "Switching to release branch..."
@@ -397,18 +410,15 @@ switch_branch_menu() {
read -p "Choose Your Destiny: " branch_choice read -p "Choose Your Destiny: " branch_choice
# Home Menu - Backend # switch branch menu - Backend
if [ "$branch_choice" = "1" ]; then case $branch_choice in
switch_release_st 1) switch_release_st ;;
elif [ "$branch_choice" = "2" ]; then 2) switch_staging_st ;;
switch_staging_st 3) home ;;
elif [ "$branch_choice" = "3" ]; then *) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}"
home read -p "Press Enter to continue..."
else switch_branch_menu ;;
echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}" esac
read -p "Press Enter to continue..."
switch_branch_menu
fi
} }
# Function to edit environment variables # Function to edit environment variables
@@ -562,11 +572,11 @@ reinstall_extras() {
conda config --set auto_activate_base false conda config --set auto_activate_base false
conda init bash conda init bash
log_message "INFO" "Creating Conda environment sillytavernextras..." log_message "INFO" "Creating Conda environment extras..."
conda create -n sillytavernextras -y conda create -n extras -y
log_message "INFO" "Activating Conda environment sillytavernextras..." log_message "INFO" "Activating Conda environment extras..."
conda activate sillytavernextras conda activate extras
log_message "INFO" "Installing Python and Git in the Conda environment..." log_message "INFO" "Installing Python and Git in the Conda environment..."
conda install python=3.11 git -y conda install python=3.11 git -y
@@ -590,6 +600,33 @@ reinstall_extras() {
toolbox toolbox
} }
# Function to uninstall SillyTavern + Extras
uninstall_st_extras() {
echo
echo -e "${red_bg}╔════ DANGER ZONE ═══════════════════════════════════════════════════════════════════╗${reset}"
echo -e "${red_bg}║ WARNING: This will delete all data in Sillytavern + Extras ║${reset}"
echo -e "${red_bg}║ If you want to keep any data, make sure to create a backup before proceeding. ║${reset}"
echo -e "${red_bg}╚════════════════════════════════════════════════════════════════════════════════════╝${reset}"
echo
echo -n "Are you sure you want to proceed? [Y/N]: "
read confirmation
if [ "$confirmation" = "Y" ] || [ "$confirmation" = "y" ]; then
cd "$PWD"
log_message "INFO" "Removing the SillyTavern + Sillytavern-extras directory..."
rm -rf SillyTavern SillyTavern-extras
log_message "INFO" "Removing the Conda environment 'extras'..."
conda remove --name extras --all -y
log_message "INFO" "${green_fg_strong}SillyTavern + Extras uninstalled successfully.${reset}"
else
echo "Uninstall canceled."
fi
pause
toolbox
}
toolbox() { toolbox() {
echo -e "\033]0;SillyTavern [TOOLBOX]\007" echo -e "\033]0;SillyTavern [TOOLBOX]\007"
clear clear
@@ -603,7 +640,8 @@ toolbox() {
echo "5. Edit Extras Modules" echo "5. Edit Extras Modules"
echo "6. Reinstall SillyTavern" echo "6. Reinstall SillyTavern"
echo "7. Reinstall Extras" echo "7. Reinstall Extras"
echo "8. Back to Home" echo "8. Uninstall SillyTavern + Extras"
echo "9. Back to Home"
read -p "Choose Your Destiny: " toolbox_choice read -p "Choose Your Destiny: " toolbox_choice
@@ -615,7 +653,8 @@ toolbox() {
5) edit_extras_modules ;; 5) edit_extras_modules ;;
6) reinstall_sillytavern ;; 6) reinstall_sillytavern ;;
7) reinstall_extras ;; 7) reinstall_extras ;;
8) home ;; 8) uninstall_st_extras ;;
9) home ;;
*) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}" *) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}"
read -p "Press Enter to continue..." read -p "Press Enter to continue..."
toolbox ;; toolbox ;;