-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathlauncher.sh
executable file
·1407 lines (1239 loc) · 51.2 KB
/
launcher.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# SillyTavern Launcher
# Created by: Deffcolony
#
# Description:
# This script runs SillyTavern and/or Extras on your Linux system.
#
# Usage:
# chmod +x launcher.sh && ./launcher.sh
#
# In automated environments, you may want to run as root.
# If using curl, we recommend using the -fsSL flags.
#
# This script is intended for use on Linux systems. Please
# report any issues or bugs on the GitHub repository.
#
# App Github: https://github.com/SillyTavern/SillyTavern.git
#
# GitHub: https://github.com/SillyTavern/SillyTavern-Launcher
# Issues: https://github.com/SillyTavern/SillyTavern-Launcher/issues
# ----------------------------------------------------------
# Note: Modify the script as needed to fit your requirements.
# ----------------------------------------------------------
echo -e "\033]0;SillyTavern Launcher\007"
# ANSI Escape Code for Colors
reset="\033[0m"
white_fg_strong="\033[90m"
red_fg_strong="\033[91m"
green_fg_strong="\033[92m"
yellow_fg_strong="\033[93m"
blue_fg_strong="\033[94m"
magenta_fg_strong="\033[95m"
cyan_fg_strong="\033[96m"
# Normal Background Colors
red_bg="\033[41m"
blue_bg="\033[44m"
yellow_bg="\033[43m"
# Environment Variables (TOOLBOX 7-Zip)
zip7version="7z2301-x64"
zip7_install_path="/usr/local/bin"
# Environment Variables (TOOLBOX FFmpeg)
ffmpeg_url="https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z"
ffdownload_path="/tmp/ffmpeg.7z"
ffextract_path="/opt/ffmpeg"
bin_path="$ffextract_path/bin"
# Environment Variables (TOOLBOX Node.js)
node_installer_path="/tmp/NodejsInstaller.sh"
# Environment Variables (TOOLBOX Install Extras)
miniconda_path="$HOME/miniconda3"
# Define variables to track module status
modules_path="$HOME/modules.txt"
coqui_trigger="false"
rvc_trigger="false"
talkinghead_trigger="false"
caption_trigger="false"
summarize_trigger="false"
edge_tts_trigger="false"
# Function to log messages with timestamps and colors
log_message() {
# This is only time
current_time=$(date +'%H:%M:%S')
# This is with date and time
# current_time=$(date +'%Y-%m-%d %H:%M:%S')
case "$1" in
"INFO")
echo -e "${blue_bg}[$current_time]${reset} ${blue_fg_strong}[INFO]${reset} $2"
;;
"WARN")
echo -e "${yellow_bg}[$current_time]${reset} ${yellow_fg_strong}[WARN]${reset} $2"
;;
"ERROR")
echo -e "${red_bg}[$current_time]${reset} ${red_fg_strong}[ERROR]${reset} $2"
;;
*)
echo -e "${blue_bg}[$current_time]${reset} ${blue_fg_strong}[DEBUG]${reset} $2"
;;
esac
}
# Log your messages test window
#log_message "INFO" "Something has been launched."
#log_message "WARN" "${yellow_fg_strong}Something is not installed on this system.${reset}"
#log_message "ERROR" "${red_fg_strong}An error occurred during the process.${reset}"
#log_message "DEBUG" "This is a debug message."
#read -p "Press Enter to continue..."
# Function to install Git
install_git() {
if ! command -v git &> /dev/null; then
log_message "WARN" "${yellow_fg_strong}Git is not installed on this system${reset}"
if command -v apt-get &>/dev/null; then
# Debian/Ubuntu-based system
log_message "INFO" "Installing Git using apt..."
sudo apt-get update
sudo apt-get install -y git
elif command -v yum &>/dev/null; then
# Red Hat/Fedora-based system
log_message "INFO" "Installing Git using yum..."
sudo yum install -y git
elif command -v apk &>/dev/null; then
# Alpine Linux-based system
log_message "INFO" "Installing Git using apk..."
sudo apk add git
elif command -v pacman &>/dev/null; then
# Arch Linux-based system
log_message "INFO" "Installing Git using pacman..."
sudo pacman -S --noconfirm git
elif command -v emerge &>/dev/null; then
# Gentoo Linux-based system
log_message "INFO" "Installing Git using emerge..."
sudo emerge --ask dev-vcs/git
else
log_message "ERROR" "${red_fg_strong}Unsupported Linux distribution.${reset}"
exit 1
fi
log_message "INFO" "${green_fg_strong}Git is installed.${reset}"
else
echo -e "${blue_fg_strong}[INFO] Git is already installed.${reset}"
fi
}
# Change the current directory to 'sillytavern' folder
cd "$(dirname "$0")/SillyTavern" || exit 1
# Check for updates
git fetch origin
update_status="Up to Date"
current_branch="$(git branch --show-current)"
# Check for updates
if [[ "$(git rev-list HEAD...origin/$current_branch)" ]]; then
update_status="Update Available"
fi
# Go back to base dir
cd ..
############################################################
################## HOME - FRONTEND #########################
############################################################
home() {
echo -e "\033]0;SillyTavern [HOME]\007"
clear
echo -e "${blue_fg_strong}/ Home${reset}"
echo "------------------------------------------------"
echo "What would you like to do?"
echo "1. Start SillyTavern"
echo "2. Start Extras"
echo "3. Start XTTS"
echo "4. Update"
echo "5. Backup"
echo "6. Switch branch"
echo "7. Toolbox"
echo "8. Support"
echo "0. Exit"
echo "======== VERSION STATUS ========"
echo -e "SillyTavern branch: ${cyan_fg_strong}$current_branch${reset}"
echo -e "Sillytavern: $update_status"
echo -e "Launcher: V1.0.8"
echo "================================"
read -p "Choose Your Destiny: " home_choice
# Default to choice 1 if no input is provided
if [ -z "$home_choice" ]; then
home_choice=1
fi
################## HOME - BACKEND #########################
case $home_choice in
1) start_st ;;
2) start_extras ;;
3) start_xtts ;;
4) update ;;
5) backup_menu ;;
6) switch_branch_menu ;;
7) toolbox ;;
8) support ;;
0) 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
if [ $? -ne 0 ]; then
echo -e "${red_fg_strong}[ERROR] node command not found in PATH${reset}"
echo -e "${red_bg}Please make sure Node.js is installed and added to your PATH.${reset}"
echo -e "${blue_bg}To install Node.js, go to Toolbox${reset}"
read -p "Press Enter to continue..."
home
fi
}
# Function to find a suitable terminal emulator
find_terminal()
{
for term in "$TERM"
do
if command -v "$term" > /dev/null 2>&1; then
echo "$term"
return 0
fi
done
for terminal in "$TERMINAL"
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_st()
{
check_nodejs
cd "SillyTavern" || exit 1
#if LAUNCH_NEW_WIN is set to 0, SillyTavern will launch in the same window
if [ "$LAUNCH_NEW_WIN" = "0" ]; then
log_message "INFO" "SillyTavern launched"
./start.sh
else
log_message "INFO" "SillyTavern launched in a new window."
# 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
if [ "$(uname)" == "Darwin" ]; then
log_message "INFO" "Detected macOS. Opening new Terminal window."
open -a Terminal "start.sh"
else
exec "$detected_terminal" -e "./start.sh" &
fi
fi
cd ..
home
}
# Function to start SillyTavern with Extras
start_extras() {
check_nodejs
if [ "$LAUNCH_NEW_WIN" = "0" ]; then
local main_pid=$!
log_message "INFO" "Extras launched under pid $main_pid"
{
#has to be after the first one, so we are 1 directory up
cd "SillyTavern-extras" || {
log_message "ERROR" "SillyTavern-extras directory not found. Please make sure you have installed SillyTavern-extras."
kill $main_pid
exit 1
}
log_message "INFO" "Working dir: $(pwd)"
./start.sh
} &
local extras_pid=$!
log_message "INFO" "Extras launched under pid $extras_pid"
wait $main_pid
kill $extras_pid
else
cd "SillyTavern-extras"
log_message "INFO" "Extras launched in a new window."
# 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
if [ "$(uname)" == "Darwin" ]; then
log_message "INFO" "Detected macOS. Opening new Terminal window."
open -a Terminal --args --title="SillyTavern Extras" --working-directory="SillyTavern-extras" --command "python server.py --listen --rvc-save-file --max-content-length=1000 --enable-modules=rvc,caption; exec bash"
else
exec "$detected_terminal" -e "python server.py --listen --rvc-save-file --max-content-length=1000 --enable-modules=rvc,caption; bash"
fi
fi
home
}
# Function to start xtts
start_xtts() {
check_nodejs
if [ "$LAUNCH_NEW_WIN" = "0" ]; then
local main_pid=$!
log_message "INFO" "xtts launched under pid $main_pid"
# Move to xtts directory
cd "xtts" || {
log_message "ERROR" "xtts directory not found. Please make sure you have installed xtts"
kill "$main_pid"
exit 1
}
log_message "INFO" "Working dir: $(pwd)"
./start.sh &
local xtts_pid=$!
log_message "INFO" "xtts launched under pid $xtts_pid"
wait "$main_pid"
kill "$xtts_pid"
else
cd "xtts"
log_message "INFO" "xtts launched in a new window."
# 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 XTTS in the detected terminal
if [ "$(uname)" == "Darwin" ]; then
log_message "INFO" "Detected macOS. Opening new Terminal window."
open -a Terminal --args --title="XTTSv2 API Server" --working-directory="xtts" --command "conda activate xtts; python -m xtts_api_server; exec bash"
else
exec "$detected_terminal" -e "conda activate xtts && python -m xtts_api_server; bash"
fi
fi
home
}
# Function to update
update() {
echo -e "\033]0;SillyTavern [UPDATE]\007"
log_message "INFO" "Updating SillyTavern-Launcher..."
git pull --rebase --autostash
# Update SillyTavern if directory exists
if [ -d "SillyTavern" ]; then
log_message "INFO" "Updating SillyTavern..."
cd "SillyTavern"
git pull --rebase --autostash
cd ..
log_message "INFO" "SillyTavern updated successfully."
else
log_message "WARN" "SillyTavern directory not found. Skipping SillyTavern update."
fi
# Update Extras if directory exists
if [ -d "SillyTavern-extras" ]; then
log_message "INFO" "Updating SillyTavern-extras..."
cd "SillyTavern-extras"
git pull --rebase --autostash
cd ..
log_message "INFO" "SillyTavern-extras updated successfully."
else
log_message "WARN" "SillyTavern-extras directory not found. Skipping SillyTavern-extras update."
fi
# Update XTTS if directory exists
if [ -d "xtts" ]; then
log_message "INFO" "Updating XTTS..."
cd "xtts"
source activate xtts
pip install --upgrade xtts-api-server
conda deactivate
cd ..
log_message "INFO" "XTTS updated successfully."
else
log_message "WARN" "xtts directory not found. Skipping XTTS update."
fi
read -p "Press Enter to continue..."
home
}
create_backup() {
echo -e "\033]0;SillyTavern [CREATE-BACKUP]\007"
# Define the backup file name with a formatted date and time
formatted_date=$(date +'%Y-%m-%d_%H%M')
backup_file="backups/backup_$formatted_date.tar.gz"
# Create the backup using tar
tar -czvf "$backup_file" \
"public/assets/" \
"public/Backgrounds/" \
"public/Characters/" \
"public/Chats/" \
"public/context/" \
"public/Group chats/" \
"public/Groups/" \
"public/instruct/" \
"public/KoboldAI Settings/" \
"public/movingUI/" \
"public/NovelAI Settings/" \
"public/OpenAI Settings/" \
"public/QuickReplies/" \
"public/TextGen Settings/" \
"public/themes/" \
"public/User Avatars/" \
"public/user/" \
"public/worlds/" \
"public/settings.json" \
"secrets.json"
echo -e "${green_fg_strong}Backup created successfully!${reset}"
read -p "Press Enter to continue..."
backup_menu
}
restore_backup() {
echo -e "\033]0;SillyTavern [RESTORE-BACKUP]\007"
# List available backups
echo "List of available backups:"
echo "========================"
backup_count=0
backup_files=()
for file in backups/backup_*.tar.gz; do
backup_count=$((backup_count + 1))
backup_files+=("$file")
echo -e "$backup_count. ${cyan_fg_strong}$(basename "$file")${reset}"
done
echo "========================"
read -p "Enter the number of the backup to restore: " restore_choice
if [ "$restore_choice" -ge 1 ] && [ "$restore_choice" -le "$backup_count" ]; then
selected_backup="${backup_files[restore_choice - 1]}"
echo "Restoring backup $selected_backup..."
# Extract the contents of the backup to a temporary directory
temp_dir=$(mktemp -d)
tar -xzvf "$selected_backup" -C "$temp_dir"
# Copy the restored files to the appropriate location
rsync -av "$temp_dir/public/" "public/"
# Clean up the temporary directory
rm -r "$temp_dir"
echo -e "${green_fg_strong}$selected_backup restored successfully.${reset}"
else
echo -e "${yellow_fg_strong}WARNING: Invalid backup number. Please insert a valid number.${reset}"
fi
read -p "Press Enter to continue..."
backup_menu
}
############################################################
################# BACKUP - FRONTEND ########################
############################################################
backup_menu() {
echo -e "\033]0;SillyTavern [BACKUP]\007"
clear
echo -e "${blue_fg_strong}/ Home / Backup${reset}"
echo "------------------------------------------------"
echo "What would you like to do?"
echo "1. Create Backup"
echo "2. Restore Backup"
echo "0. Back to Home"
read -p "Choose Your Destiny: " backup_choice
################# BACKUP - BACKEND ########################
case $backup_choice in
1) create_backup ;;
2) restore_backup ;;
0) 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..."
git switch release
read -p "Press Enter to continue..."
switch_branch_menu
}
# Function to switch to the Staging branch in SillyTavern
switch_staging_st() {
log_message "INFO" "Switching to staging branch..."
git switch staging
read -p "Press Enter to continue..."
switch_branch_menu
}
############################################################
############## SWITCH BRANCE - FRONTEND ####################
############################################################
switch_branch_menu() {
echo -e "\033]0;SillyTavern [SWITCH-BRANCE]\007"
clear
echo -e "${blue_fg_strong}/ Home / Switch Branch${reset}"
echo "------------------------------------------------"
echo "What would you like to do?"
echo "1. Switch to Release - SillyTavern"
echo "2. Switch to Staging - SillyTavern"
echo "0. Back to Home"
current_branch=$(git branch --show-current)
echo "======== VERSION STATUS ========"
echo -e "SillyTavern branch: ${cyan_fg_strong}$current_branch${reset}"
echo -e "Extras branch: ${cyan_fg_strong}$current_branch${reset}"
echo "================================"
read -p "Choose Your Destiny: " branch_choice
################# SWITCH BRANCE - BACKEND ########################
case $branch_choice in
1) switch_release_st ;;
2) switch_staging_st ;;
0) 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 install p7zip (7-Zip)
install_p7zip() {
if ! command -v 7z &> /dev/null; then
log_message "WARN" "${yellow_fg_strong}p7zip (7-Zip) is not installed on this system${reset}"
if command -v apt-get &>/dev/null; then
# Debian/Ubuntu-based system
log_message "INFO" "Installing p7zip (7-Zip) using apt..."
sudo apt-get update
sudo apt-get install -y p7zip-full
elif command -v yum &>/dev/null; then
# Red Hat/Fedora-based system
log_message "INFO" "Installing p7zip (7-Zip) using yum..."
sudo yum install -y p7zip p7zip-plugins
elif command -v apk &>/dev/null; then
# Alpine Linux-based system
log_message "INFO" "Installing p7zip (7-Zip) using apk..."
sudo apk add p7zip
elif command -v pacman &>/dev/null; then
# Arch Linux-based system
log_message "INFO" "Installing p7zip (7-Zip) using pacman..."
sudo pacman -Sy --noconfirm p7zip
elif command -v emerge &>/dev/null; then
# Gentoo Linux-based system
log_message "INFO" "Installing p7zip (7-Zip) using emerge..."
sudo emerge --ask app-arch/p7zip
else
log_message "ERROR" "${red_fg_strong}Unsupported Linux distribution.${reset}"
exit 1
fi
log_message "INFO" "${green_fg_strong}p7zip (7-Zip) is installed.${reset}"
else
log_message "INFO" "${blue_fg_strong}p7zip (7-Zip) is already installed.${reset}"
fi
}
# Function to install FFmpeg
install_ffmpeg() {
if ! command -v ffmpeg &> /dev/null; then
log_message "WARN" "${yellow_fg_strong}FFmpeg is not installed on this system${reset}"
if command -v apt-get &>/dev/null; then
# Debian/Ubuntu-based system
log_message "INFO" "Installing FFmpeg using apt..."
sudo apt-get update
sudo apt-get install -y ffmpeg
elif command -v yum &>/dev/null; then
# Red Hat/Fedora-based system
log_message "INFO" "Installing FFmpeg using yum..."
sudo yum install -y ffmpeg
elif command -v apk &>/dev/null; then
# Alpine Linux-based system
log_message "INFO" "Installing FFmpeg using apk..."
sudo apk add ffmpeg
elif command -v pacman &>/dev/null; then
# Arch Linux-based system
log_message "INFO" "Installing FFmpeg using pacman..."
sudo pacman -Sy --noconfirm ffmpeg
elif command -v emerge &>/dev/null; then
# Gentoo Linux-based system
log_message "INFO" "Installing FFmpeg using emerge..."
sudo emerge --ask media-video/ffmpeg
else
log_message "ERROR" "${red_fg_strong}Unsupported Linux distribution.${reset}"
exit 1
fi
log_message "INFO" "${green_fg_strong}FFmpeg is installed.${reset}"
else
log_message "INFO" "${blue_fg_strong}FFmpeg is already installed.${reset}"
fi
}
# Function to install Node.js
install_nodejs() {
if ! command -v node &> /dev/null; then
log_message "WARN" "${yellow_fg_strong}Node.js is not installed on this system${reset}"
if command -v apt-get &>/dev/null; then
# Debian/Ubuntu-based system
log_message "INFO" "Installing Node.js using apt..."
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
elif command -v yum &>/dev/null; then
# Red Hat/Fedora-based system
log_message "INFO" "Installing Node.js using yum..."
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs
elif command -v apk &>/dev/null; then
# Alpine Linux-based system
log_message "INFO" "Installing Node.js using apk..."
sudo apk add nodejs npm
elif command -v pacman &>/dev/null; then
# Arch Linux-based system
log_message "INFO" "Installing Node.js using pacman..."
sudo pacman -Sy --noconfirm nodejs npm
elif command -v emerge &>/dev/null; then
# Gentoo Linux-based system
log_message "INFO" "Installing Node.js using emerge..."
sudo emerge --ask nodejs
else
log_message "ERROR" "${red_fg_strong}Unsupported Linux distribution.${reset}"
exit 1
fi
log_message "INFO" "${green_fg_strong}Node.js is installed.${reset}"
else
log_message "INFO" "${blue_fg_strong}Node.js is already installed.${reset}"
fi
}
############################################################
############## APP INSTALLER - FRONTEND ####################
############################################################
app_installer() {
echo -e "\033]0;SillyTavern [APP INSTALLER]\007"
clear
echo -e "${blue_fg_strong}/ Home / Toolbox / App Installer${reset}"
echo "------------------------------------------------"
echo "What would you like to do?"
echo "1. Install 7-Zip"
echo "2. Install FFmpeg"
echo "3. Install Node.js"
echo "0. Back to Toolbox"
read -p "Choose Your Destiny: " app_installer_choice
################# APP INSTALLER - BACKEND #######################
case $app_installer_choice in
1) install_p7zip ;;
2) install_ffmpeg ;;
3) install_nodejs ;;
0) toolbox ;;
*) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}"
read -p "Press Enter to continue..."
app_installer ;;
esac
}
# Function to uninstall Extras
uninstall_extras() {
echo
echo -e "${red_bg}╔════ DANGER ZONE ═══════════════════════════════════════════════════════════════════╗${reset}"
echo -e "${red_bg}║ WARNING: This will delete all data in 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
log_message "INFO" "Removing the SillyTavern-extras directory..."
rm -rf SillyTavern-extras
log_message "INFO" "Removing the Conda environment: extras"
conda remove --name extras --all -y
log_message "INFO" "${green_fg_strong}Extras uninstalled successfully.${reset}"
else
echo "Uninstall canceled."
fi
pause
app_uninstaller
}
# Function to uninstall XTTS
uninstall_xtts() {
echo
echo -e "${red_bg}╔════ DANGER ZONE ═══════════════════════════════════════════════════════════════════╗${reset}"
echo -e "${red_bg}║ WARNING: This will delete all data in XTTS ║${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
log_message "INFO" "Removing the xtts directory..."
rm -rf xtts
log_message "INFO" "Removing the Conda environment: xtts"
conda remove --name xtts --all -y
log_message "INFO" "${green_fg_strong}XTTS uninstalled successfully.${reset}"
else
echo "Uninstall canceled."
fi
pause
app_uninstaller
}
# Function to uninstall SillyTavern
uninstall_st() {
echo
echo -e "${red_bg}╔════ DANGER ZONE ═══════════════════════════════════════════════════════════════════╗${reset}"
echo -e "${red_bg}║ WARNING: This will delete all data in SillyTavern ║${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
log_message "INFO" "Removing the SillyTavern directory..."
rm -rf SillyTavern
log_message "INFO" "${green_fg_strong}SillyTavern uninstalled successfully.${reset}"
else
echo "Uninstall canceled."
fi
pause
app_uninstaller
}
# Function to uninstall p7zip (7-Zip)
uninstall_p7zip() {
if command -v 7z &> /dev/null; then
log_message "WARN" "${yellow_fg_strong}p7zip (7-Zip) is installed on this system${reset}"
if command -v apt-get &>/dev/null; then
# Debian/Ubuntu-based system
log_message "INFO" "Uninstalling p7zip (7-Zip) using apt..."
sudo apt-get remove --purge -y p7zip p7zip-full
elif command -v yum &>/dev/null; then
# Red Hat/Fedora-based system
log_message "INFO" "Uninstalling p7zip (7-Zip) using yum..."
sudo yum remove -y p7zip p7zip-plugins
elif command -v apk &>/dev/null; then
# Alpine Linux-based system
log_message "INFO" "Uninstalling p7zip (7-Zip) using apk..."
sudo apk del p7zip
elif command -v pacman &>/dev/null; then
# Arch Linux-based system
log_message "INFO" "Uninstalling p7zip (7-Zip) using pacman..."
sudo pacman -Rns --noconfirm p7zip
elif command -v emerge &>/dev/null; then
# Gentoo Linux-based system
log_message "INFO" "Uninstalling p7zip (7-Zip) using emerge..."
sudo emerge --unmerge p7zip
else
log_message "ERROR" "${red_fg_strong}Unsupported Linux distribution.${reset}"
exit 1
fi
log_message "INFO" "${green_fg_strong}p7zip (7-Zip) is uninstalled.${reset}"
else
log_message "INFO" "${blue_fg_strong}p7zip (7-Zip) is not installed.${reset}"
fi
}
# Function to uninstall FFmpeg
uninstall_ffmpeg() {
if command -v ffmpeg &> /dev/null; then
log_message "WARN" "${yellow_fg_strong}FFmpeg is installed on this system${reset}"
if command -v apt-get &>/dev/null; then
# Debian/Ubuntu-based system
log_message "INFO" "Uninstalling FFmpeg using apt..."
sudo apt-get remove --purge -y ffmpeg
elif command -v yum &>/dev/null; then
# Red Hat/Fedora-based system
log_message "INFO" "Uninstalling FFmpeg using yum..."
sudo yum remove -y ffmpeg
elif command -v apk &>/dev/null; then
# Alpine Linux-based system
log_message "INFO" "Uninstalling FFmpeg using apk..."
sudo apk del ffmpeg
elif command -v pacman &>/dev/null; then
# Arch Linux-based system
log_message "INFO" "Uninstalling FFmpeg using pacman..."
sudo pacman -Rns --noconfirm ffmpeg
elif command -v emerge &>/dev/null; then
# Gentoo Linux-based system
log_message "INFO" "Uninstalling FFmpeg using emerge..."
sudo emerge --unmerge ffmpeg
else
log_message "ERROR" "${red_fg_strong}Unsupported Linux distribution.${reset}"
exit 1
fi
log_message "INFO" "${green_fg_strong}FFmpeg is uninstalled.${reset}"
else
log_message "INFO" "${blue_fg_strong}FFmpeg is not installed.${reset}"
fi
}
# Function to uninstall Node.js and npm
uninstall_nodejs() {
if command -v node &> /dev/null; then
log_message "WARN" "${yellow_fg_strong}Node.js is installed on this system${reset}"
if command -v apt-get &>/dev/null; then
# Debian/Ubuntu-based system
log_message "INFO" "Uninstalling Node.js using apt..."
sudo apt-get remove --purge -y nodejs npm
elif command -v yum &>/dev/null; then
# Red Hat/Fedora-based system
log_message "INFO" "Uninstalling Node.js using yum..."
sudo yum remove -y nodejs npm
elif command -v apk &>/dev/null; then
# Alpine Linux-based system
log_message "INFO" "Uninstalling Node.js using apk..."
sudo apk del nodejs npm
elif command -v pacman &>/dev/null; then
# Arch Linux-based system
log_message "INFO" "Uninstalling Node.js using pacman..."
sudo pacman -Rns --noconfirm nodejs npm
elif command -v emerge &>/dev/null; then
# Gentoo Linux-based system
log_message "INFO" "Uninstalling Node.js using emerge..."
sudo emerge --unmerge nodejs
else
log_message "ERROR" "${red_fg_strong}Unsupported Linux distribution.${reset}"
exit 1
fi
log_message "INFO" "${green_fg_strong}Node.js and npm are uninstalled.${reset}"
else
log_message "INFO" "${blue_fg_strong}Node.js is not installed.${reset}"
fi
}
# Function to uninstall Git
uninstall_git() {
if command -v git &> /dev/null; then
log_message "WARN" "${yellow_fg_strong}Git is installed on this system${reset}"
if command -v apt-get &>/dev/null; then
# Debian/Ubuntu-based system
log_message "INFO" "Uninstalling Git using apt..."
sudo apt-get remove --purge -y git
elif command -v yum &>/dev/null; then
# Red Hat/Fedora-based system
log_message "INFO" "Uninstalling Git using yum..."
sudo yum remove -y git
elif command -v apk &>/dev/null; then
# Alpine Linux-based system
log_message "INFO" "Uninstalling Git using apk..."
sudo apk del git
elif command -v pacman &>/dev/null; then
# Arch Linux-based system
log_message "INFO" "Uninstalling Git using pacman..."
sudo pacman -Rns --noconfirm git
elif command -v emerge &>/dev/null; then
# Gentoo Linux-based system
log_message "INFO" "Uninstalling Git using emerge..."
sudo emerge --unmerge dev-vcs/git
else
log_message "ERROR" "${red_fg_strong}Unsupported Linux distribution.${reset}"
exit 1
fi
log_message "INFO" "${green_fg_strong}Git is uninstalled.${reset}"
else
log_message "INFO" "${blue_fg_strong}Git is not installed.${reset}"
fi
}
############################################################
############## APP UNINSTALLER - FRONTEND ##################
############################################################
app_uninstaller() {
echo -e "\033]0;SillyTavern [APP UNINSTALLER]\007"
clear
echo -e "${blue_fg_strong}/ Home / Toolbox / App Uninstaller${reset}"
echo "------------------------------------------------"
echo "What would you like to do?"
echo "1. UNINSTALL Extras"
echo "2. UNINSTALL XTTS"
echo "3. UNINSTALL SillyTavern"
echo "4. UNINSTALL 7-Zip"
echo "5. UNINSTALL FFmpeg"
echo "6. UNINSTALL Node.js"
echo "7. UNINSTALL git"
echo "0. Back to Toolbox"
read -p "Choose Your Destiny: " app_uninstaller_choice
################# APP UNINSTALLER - BACKEND #######################
case $app_uninstaller_choice in
1) uninstall_extras ;;
2) uninstall_xtts ;;
3) uninstall_st ;;
4) uninstall_p7zip ;;
5) uninstall_ffmpeg ;;
6) uninstall_nodejs ;;
7) uninstall_git ;;
0) toolbox ;;
*) echo -e "${yellow_fg_strong}WARNING: Invalid number. Please insert a valid number.${reset}"
read -p "Press Enter to continue..."
app_uninstaller ;;
esac
}
# Function to print module options with color based on their status
printModule() {
if [ "$2" == "true" ]; then
echo -e "\e[32;1m$1 [Enabled]\e[0m"
else
echo -e "\e[31;1m$1 [Disabled]\e[0m"
fi
}
# Function to edit extras modules
edit_extras_modules() {
echo -e "\033]0;SillyTavern [EDIT-MODULES]\007"
clear
echo -e "${blue_fg_strong}/ Home / Toolbox / Editor / Edit Extras Modules${reset}"
echo "-------------------------------------"
echo "Choose extras modules to enable or disable (e.g., \"1 2 4\" to enable Cuda, RVC, and Caption)"
# Display module options with colors based on their status
printModule "1. Cuda (--gpu 0 --cuda --cuda-device=0)" "$cuda_trigger"
printModule "2. RVC (--enable-modules=rvc --rvc-save-file --max-content-length=1000)" "$rvc_trigger"
printModule "3. talkinghead (--enable-modules=talkinghead)" "$talkinghead_trigger"
printModule "4. caption (--enable-modules=caption)" "$caption_trigger"
printModule "5. summarize (--enable-modules=summarize)" "$summarize_trigger"
printModule "6. listen (--listen)" "$listen_trigger"
printModule "7. Edge TTS (--enable-modules=edge-tts)" "$edge_tts_trigger"
echo "0. Back to Toolbox"
set "python_command="
read -p "Choose modules to enable/disable (1-6): " module_choices
# Handle the user's module choices and construct the Python command
for i in $module_choices; do
case $i in
1) [ "$cuda_trigger" == "true" ] && cuda_trigger=false || cuda_trigger=true ;;
2) [ "$rvc_trigger" == "true" ] && rvc_trigger=false || rvc_trigger=true ;;
3) [ "$talkinghead_trigger" == "true" ] && talkinghead_trigger=false || talkinghead_trigger=true ;;
4) [ "$caption_trigger" == "true" ] && caption_trigger=false || caption_trigger=true ;;
5) [ "$summarize_trigger" == "true" ] && summarize_trigger=false || summarize_trigger=true ;;
6) [ "$listen_trigger" == "true" ] && listen_trigger=false || listen_trigger=true ;;
7) [ "$edge_tts_trigger" == "true" ] && edge_tts_trigger=false || edge_tts_trigger=true ;;
0) toolbox ;;
esac
done
# Save the module flags to modules.txt
modules_file="$(dirname "$0")/modules.txt"
echo "cuda_trigger=$cuda_trigger" > "$modules_file"
echo "rvc_trigger=$rvc_trigger" >> "$modules_file"
echo "talkinghead_trigger=$talkinghead_trigger" >> "$modules_file"
echo "caption_trigger=$caption_trigger" >> "$modules_file"