diff --git a/Launcher.bat b/Launcher.bat index f597b0a..52ad53d 100644 --- a/Launcher.bat +++ b/Launcher.bat @@ -160,7 +160,7 @@ if not defined choice set "choice=1" REM Home - backend if "%choice%"=="1" ( - call :start + call :start_st ) else if "%choice%"=="2" ( call :start_st_extras ) else if "%choice%"=="3" ( @@ -181,7 +181,7 @@ if "%choice%"=="1" ( ) -:start +:start_st REM Check if Node.js is installed node --version > nul 2>&1 if %errorlevel% neq 0 ( diff --git a/README.md b/README.md index ed208e5..c555635 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,26 @@ # 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` \ No newline at end of file diff --git a/install.sh b/install.sh index dbce7e5..10e8b3a 100644 --- a/install.sh +++ b/install.sh @@ -223,11 +223,11 @@ install_st_extras() { conda config --set auto_activate_base false conda init bash - log_message "INFO" "Creating Conda environment sillytavernextras..." - conda create -n sillytavernextras -y + log_message "INFO" "Creating Conda environment extras..." + conda create -n extras -y - log_message "INFO" "Activating Conda environment sillytavernextras..." - conda activate sillytavernextras + log_message "INFO" "Activating Conda environment extras..." + conda activate extras log_message "INFO" "Installing Python and Git in the Conda environment..." conda install python=3.11 git -y @@ -297,11 +297,11 @@ install_extras() { conda config --set auto_activate_base false conda init bash - log_message "INFO" "Creating Conda environment sillytavernextras..." - conda create -n sillytavernextras -y + log_message "INFO" "Creating Conda environment extras..." + conda create -n extras -y - log_message "INFO" "Activating Conda environment sillytavernextras..." - conda activate sillytavernextras + log_message "INFO" "Activating Conda environment extras..." + conda activate extras log_message "INFO" "Installing Python and Git in the Conda environment..." conda install python=3.11 git -y diff --git a/launcher.sh b/launcher.sh index e774062..5b403bb 100644 --- a/launcher.sh +++ b/launcher.sh @@ -164,35 +164,29 @@ home() { echo -e "Update Status: $update_status" 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 - if [ -z "$choice" ]; then - choice=1 + if [ -z "$home_choice" ]; then + home_choice=1 fi - # home - Backend - if [ "$choice" = "1" ]; then - start_sillytavern - elif [ "$choice" = "2" ]; then - start_sillytavern_with_extras - elif [ "$choice" = "3" ]; then - update - elif [ "$choice" = "4" ]; then - backup_menu - elif [ "$choice" = "5" ]; then - switch_branch_menu - elif [ "$choice" = "6" ]; then - toolbox - 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 + # Home menu - Backend + case $home_choice in + 1) start_st ;; + 2) start_st_extras ;; + 3) update ;; + 4) backup_menu ;; + 5) switch_branch_menu ;; + 6) toolbox ;; + 7) exit ;; + *) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}" + read -p "Press Enter to continue..." + home ;; + esac } + # Function to check if Node.js is installed check_nodejs() { 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 -start_sillytavern() { +start_st() { check_nodejs log_message "INFO" "SillyTavern launched in a new window." - - # Start a terminal emulator for "start.sh" (adjust the command as needed) - x-terminal-emulator -e "cd $(dirname "$0")./SillyTavern && ./start.sh" & + # Find a suitable terminal + 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 in the detected terminal + exec "$detected_terminal" -e "cd $(dirname "$0")./SillyTavern && ./start.sh" & home } # Function to start SillyTavern with Extras -start_sillytavern_with_extras() { +start_st_extras() { 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" "Extras launched in a new window." - x-terminal-emulator -e "cd $(dirname "$0")./SillyTavern && ./start.sh" & - x-terminal-emulator -e "cd $(dirname "$0")./SillyTavern-extras && ./start.sh" & + # Find a suitable terminal + 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 } @@ -347,21 +364,17 @@ backup_menu() { read -p "Choose Your Destiny: " backup_choice # Backup menu - Backend - if [ "$backup_choice" = "1" ]; then - create_backup - elif [ "$backup_choice" = "2" ]; then - restore_backup - elif [ "$backup_choice" = "3" ]; then - home - else - echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}" - read -p "Press Enter to continue..." - backup_menu - fi + case $backup_choice in + 1) create_backup ;; + 2) restore_backup ;; + 3) home ;; + *) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}" + read -p "Press Enter to continue..." + backup_menu ;; + esac } - # Function to switch to the Release branch in SillyTavern switch_release_st() { log_message "INFO" "Switching to release branch..." @@ -397,18 +410,15 @@ switch_branch_menu() { read -p "Choose Your Destiny: " branch_choice - # Home Menu - Backend - if [ "$branch_choice" = "1" ]; then - switch_release_st - elif [ "$branch_choice" = "2" ]; then - switch_staging_st - elif [ "$branch_choice" = "3" ]; then - home - else - echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}" - read -p "Press Enter to continue..." - switch_branch_menu - fi + # switch branch menu - Backend + case $branch_choice in + 1) switch_release_st ;; + 2) switch_staging_st ;; + 3) home ;; + *) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}" + read -p "Press Enter to continue..." + switch_branch_menu ;; + esac } # Function to edit environment variables @@ -562,11 +572,11 @@ reinstall_extras() { conda config --set auto_activate_base false conda init bash - log_message "INFO" "Creating Conda environment sillytavernextras..." - conda create -n sillytavernextras -y + log_message "INFO" "Creating Conda environment extras..." + conda create -n extras -y - log_message "INFO" "Activating Conda environment sillytavernextras..." - conda activate sillytavernextras + log_message "INFO" "Activating Conda environment extras..." + conda activate extras log_message "INFO" "Installing Python and Git in the Conda environment..." conda install python=3.11 git -y @@ -590,6 +600,33 @@ reinstall_extras() { 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() { echo -e "\033]0;SillyTavern [TOOLBOX]\007" clear @@ -603,7 +640,8 @@ toolbox() { echo "5. Edit Extras Modules" echo "6. Reinstall SillyTavern" 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 @@ -615,7 +653,8 @@ toolbox() { 5) edit_extras_modules ;; 6) reinstall_sillytavern ;; 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}" read -p "Press Enter to continue..." toolbox ;;