forked from rocksq/s-ui1
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy paths-ui.sh
More file actions
1098 lines (1013 loc) · 48.5 KB
/
Copy paths-ui.sh
File metadata and controls
1098 lines (1013 loc) · 48.5 KB
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
# S-UI management menu with multilingual UI (English / Russian / Chinese).
# Language is persisted in /etc/s-ui/lang and can be switched from
# menu item 21.
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
LANG_FILE="/etc/s-ui/lang"
load_language() {
if [[ -n "${SUI_LANG}" ]]; then
case "${SUI_LANG}" in
en|ru|zh) lang="${SUI_LANG}"; return ;;
esac
fi
if [[ -f "${LANG_FILE}" ]]; then
local saved
saved=$(cat "${LANG_FILE}" 2>/dev/null | tr -d '[:space:]')
case "${saved}" in
en|ru|zh) lang="${saved}"; return ;;
esac
fi
lang="en"
}
save_language() {
mkdir -p "$(dirname "${LANG_FILE}")"
printf '%s\n' "${lang}" >"${LANG_FILE}" 2>/dev/null || true
}
t() {
local key="$1"
if [[ "${lang}" == "zh" ]]; then
case "${key}" in
run_as_root) echo "错误:必须使用 root 权限运行此脚本!"; return ;;
detect_failed) echo "检测系统失败,请联系作者!"; return ;;
current_release) echo "当前系统发行版为:$2"; return ;;
debug_tag) echo "[调试]"; return ;;
error_tag) echo "[错误]"; return ;;
info_tag) echo "[信息]"; return ;;
default_n) echo "默认$2"; return ;;
press_enter_main) echo "按回车返回主菜单:"; return ;;
restart_service_q) echo "重启 $2 服务"; return ;;
install_force_q) echo "此功能将强制重装最新版本,数据不会丢失。是否继续?"; return ;;
cancelled) echo "已取消"; return ;;
update_done) echo "更新完成,面板已自动重启"; return ;;
enter_panel_version) echo "请输入面板版本(例如 v1.4.1):"; return ;;
version_required) echo "面板版本不能为空。正在退出。"; return ;;
downloading_version) echo "正在下载并安装面板版本 $2..."; return ;;
uninstall_q) echo "确定要卸载面板吗?"; return ;;
uninstall_done) echo "卸载成功。如果要删除此脚本,请在退出脚本后运行 rm /usr/local/s-ui -f。"; return ;;
reset_admin_warn) echo "不建议将管理员账号密码设置为默认值!"; return ;;
reset_admin_q) echo "确定要将管理员账号密码重置为默认值吗?"; return ;;
set_admin_warn) echo "不建议将管理员账号密码设置为过于复杂的文本。"; return ;;
set_username_p) echo "请设置用户名:"; return ;;
set_password_p) echo "请设置密码:"; return ;;
reset_settings_q) echo "确定要将设置重置为默认值吗?"; return ;;
enter_panel_port) echo "请输入面板端口(留空则使用现有/默认值):"; return ;;
enter_panel_path) echo "请输入面板路径(留空则使用现有/默认值):"; return ;;
enter_sub_port) echo "请输入订阅端口(留空则使用现有/默认值):"; return ;;
enter_sub_path) echo "请输入订阅路径(留空则使用现有/默认值):"; return ;;
initializing) echo "正在初始化,请稍候..."; return ;;
could_not_get_uri) echo "获取当前 URI 失败"; return ;;
panel_url) echo "你可以通过以下 URL 访问面板:"; return ;;
already_running) echo "$2 正在运行,无需再次启动;如果需要重启,请选择重启"; return ;;
start_ok) echo "$2 启动成功"; return ;;
start_fail) echo "启动 $2 失败,可能是启动时间超过两秒,请稍后查看日志信息"; return ;;
already_stopped) echo "$2 已停止,无需再次停止!"; return ;;
stop_ok) echo "$2 停止成功"; return ;;
stop_fail) echo "停止 $2 失败,可能是停止时间超过两秒,请稍后查看日志信息"; return ;;
restart_ok) echo "$2 重启成功"; return ;;
restart_fail) echo "重启 $2 失败,可能是启动时间超过两秒,请稍后查看日志信息"; return ;;
enable_ok) echo "已成功设置 $2 开机自启"; return ;;
enable_fail) echo "设置 $2 开机自启失败"; return ;;
disable_ok) echo "已成功取消 $2 开机自启"; return ;;
disable_fail) echo "取消 $2 开机自启失败"; return ;;
download_fail) echo "下载脚本失败,请检查当前机器是否可以连接 Github"; return ;;
script_updated) echo "脚本升级成功,请重新运行脚本"; return ;;
already_installed) echo "面板已安装,请勿重复安装"; return ;;
install_first) echo "请先安装面板"; return ;;
status_running) echo "$2 状态:运行中"; return ;;
status_stopped) echo "$2 状态:未运行"; return ;;
status_missing) echo "$2 状态:未安装"; return ;;
autostart_yes) echo "$2 开机自启:是"; return ;;
autostart_no) echo "$2 开机自启:否"; return ;;
invalid_choice) echo "无效选择"; return ;;
enable_bbr) echo "启用 BBR"; return ;;
disable_bbr) echo "禁用 BBR"; return ;;
back_main) echo "返回主菜单"; return ;;
select_option) echo "请选择一个选项:"; return ;;
bbr_already_off) echo "当前未启用 BBR。"; return ;;
bbr_to_cubic_ok) echo "已成功将 BBR 替换为 CUBIC。"; return ;;
bbr_to_cubic_fail) echo "将 BBR 替换为 CUBIC 失败。请检查系统配置。"; return ;;
bbr_already_on) echo "BBR 已启用!"; return ;;
bbr_enabled) echo "BBR 启用成功。"; return ;;
bbr_enable_fail) echo "启用 BBR 失败。请检查系统配置。"; return ;;
os_not_supported) echo "不支持的操作系统。请检查脚本并手动安装必要的软件包。"; return ;;
installing_acme) echo "正在安装 acme..."; return ;;
acme_install_fail) echo "安装 acme 失败"; return ;;
acme_install_ok) echo "安装 acme 成功"; return ;;
ssl_get) echo "获取 SSL"; return ;;
ssl_revoke) echo "吊销证书"; return ;;
ssl_force_renew) echo "强制续签"; return ;;
ssl_self_signed) echo "自签名证书"; return ;;
menu_title) echo "S-UI 管理脚本"; return ;;
menu_exit) echo "退出"; return ;;
menu_install) echo "安装"; return ;;
menu_update) echo "更新"; return ;;
menu_custom_version) echo "自定义版本"; return ;;
menu_uninstall) echo "卸载"; return ;;
menu_reset_admin) echo "将管理员账号密码重置为默认值"; return ;;
menu_set_admin) echo "设置管理员账号密码"; return ;;
menu_view_admin) echo "查看管理员账号密码"; return ;;
menu_reset_settings) echo "重置面板设置"; return ;;
menu_set_settings) echo "设置面板设置"; return ;;
menu_view_settings) echo "查看面板设置"; return ;;
menu_start) echo "启动 S-UI"; return ;;
menu_stop) echo "停止 S-UI"; return ;;
menu_restart) echo "重启 S-UI"; return ;;
menu_status) echo "查看 S-UI 状态"; return ;;
menu_log) echo "查看 S-UI 日志"; return ;;
menu_enable_auto) echo "启用 S-UI 开机自启"; return ;;
menu_disable_auto) echo "禁用 S-UI 开机自启"; return ;;
menu_bbr) echo "启用或禁用 BBR"; return ;;
menu_ssl) echo "SSL 证书管理"; return ;;
menu_ssl_cf) echo "Cloudflare SSL 证书"; return ;;
menu_language) echo "语言"; return ;;
enter_choice_range) echo "请输入你的选择 [0-21]:"; return ;;
enter_valid_number) echo "请输入正确的数字 [0-21]"; return ;;
lang_select) echo "Select language / Выберите язык / 请选择语言"; return ;;
lang_set_to) echo "语言已设置为:$2"; return ;;
usage_title) echo "S-UI 控制菜单用法"; return ;;
usage_main) echo "s-ui - 管理员管理脚本"; return ;;
usage_start) echo "s-ui start - 启动 s-ui"; return ;;
usage_stop) echo "s-ui stop - 停止 s-ui"; return ;;
usage_restart) echo "s-ui restart - 重启 s-ui"; return ;;
usage_status) echo "s-ui status - 查看当前 s-ui 状态"; return ;;
usage_enable) echo "s-ui enable - 启用开机自启"; return ;;
usage_disable) echo "s-ui disable - 禁用开机自启"; return ;;
usage_log) echo "s-ui log - 查看 s-ui 日志"; return ;;
usage_update) echo "s-ui update - 更新"; return ;;
usage_install) echo "s-ui install - 安装"; return ;;
usage_uninstall) echo "s-ui uninstall - 卸载"; return ;;
usage_help) echo "s-ui help - 管理菜单帮助"; return ;;
esac
fi
case "${lang}:${key}" in
en:run_as_root) echo "Error: this script must be run as root!";;
ru:run_as_root) echo "Ошибка: этот скрипт нужно запускать с правами root!";;
en:detect_failed) echo "Could not detect the system, please contact the maintainer!";;
ru:detect_failed) echo "Не удалось определить систему, обратитесь к автору!";;
en:current_release) echo "Detected distribution: $2";;
ru:current_release) echo "Текущий дистрибутив: $2";;
en:debug_tag) echo "[Debug]";;
ru:debug_tag) echo "[Отладка]";;
en:error_tag) echo "[Error]";;
ru:error_tag) echo "[Ошибка]";;
en:info_tag) echo "[Info]";;
ru:info_tag) echo "[Инфо]";;
en:default_n) echo "default $2";;
ru:default_n) echo "по умолчанию $2";;
en:press_enter_main) echo "Press Enter to return to the main menu: ";;
ru:press_enter_main) echo "Нажмите Enter, чтобы вернуться в главное меню: ";;
en:restart_service_q) echo "Restart the service $2?";;
ru:restart_service_q) echo "Перезапустить службу $2?";;
en:install_force_q) echo "This will force-reinstall the latest version. Data is preserved. Continue?";;
ru:install_force_q) echo "Эта функция принудительно переустановит последнюю версию. Данные не будут потеряны. Продолжить?";;
en:cancelled) echo "Cancelled";;
ru:cancelled) echo "Отменено";;
en:update_done) echo "Update complete; the panel has been restarted automatically";;
ru:update_done) echo "Обновление завершено, панель автоматически перезапущена";;
en:enter_panel_version) echo "Enter the panel version (for example v1.4.1):";;
ru:enter_panel_version) echo "Введите версию панели (например, v1.4.1):";;
en:version_required) echo "Panel version cannot be empty. Exiting.";;
ru:version_required) echo "Версия панели не может быть пустой. Выход.";;
en:downloading_version) echo "Downloading and installing panel $2...";;
ru:downloading_version) echo "Скачивание и установка версии панели $2...";;
en:uninstall_q) echo "Are you sure you want to uninstall the panel?";;
ru:uninstall_q) echo "Вы уверены, что хотите удалить панель?";;
en:uninstall_done) echo "Uninstall complete. To remove this script run rm /usr/local/s-ui -f after exiting.";;
ru:uninstall_done) echo "Удаление завершено. Если нужно удалить этот скрипт, после выхода выполните rm /usr/local/s-ui -f.";;
en:reset_admin_warn) echo "Setting default admin credentials is not recommended!";;
ru:reset_admin_warn) echo "Не рекомендуется устанавливать учетные данные администратора по умолчанию!";;
en:reset_admin_q) echo "Reset admin credentials to default?";;
ru:reset_admin_q) echo "Сбросить учетные данные администратора к значениям по умолчанию?";;
en:set_admin_warn) echo "Avoid using overly complex strings for the admin credentials.";;
ru:set_admin_warn) echo "Не рекомендуется использовать слишком сложный текст для учетных данных администратора.";;
en:set_username_p) echo "Username: ";;
ru:set_username_p) echo "Имя пользователя: ";;
en:set_password_p) echo "Password: ";;
ru:set_password_p) echo "Пароль: ";;
en:reset_settings_q) echo "Reset settings to default values?";;
ru:reset_settings_q) echo "Сбросить настройки к значениям по умолчанию?";;
en:enter_panel_port) echo "Enter panel port (leave empty to keep current/default):";;
ru:enter_panel_port) echo "Введите порт панели (оставьте пустым, чтобы использовать текущее/стандартное значение):";;
en:enter_panel_path) echo "Enter panel path (leave empty to keep current/default):";;
ru:enter_panel_path) echo "Введите путь панели (оставьте пустым, чтобы использовать текущее/стандартное значение):";;
en:enter_sub_port) echo "Enter subscription port (leave empty to keep current/default):";;
ru:enter_sub_port) echo "Введите порт подписки (оставьте пустым, чтобы использовать текущее/стандартное значение):";;
en:enter_sub_path) echo "Enter subscription path (leave empty to keep current/default):";;
ru:enter_sub_path) echo "Введите путь подписки (оставьте пустым, чтобы использовать текущее/стандартное значение):";;
en:initializing) echo "Initializing, please wait...";;
ru:initializing) echo "Инициализация, подождите...";;
en:could_not_get_uri) echo "Could not retrieve the current URI";;
ru:could_not_get_uri) echo "Не удалось получить текущий URI";;
en:panel_url) echo "Panel is available at:";;
ru:panel_url) echo "Панель доступна по адресу:";;
en:already_running) echo "$2 is already running; restart it from the menu if needed.";;
ru:already_running) echo "$2 уже работает, повторный запуск не нужен; если нужно, выберите перезапуск.";;
en:start_ok) echo "$2 started successfully";;
ru:start_ok) echo "$2 успешно запущен";;
en:start_fail) echo "Could not start $2; the start may take more than two seconds, check the log later.";;
ru:start_fail) echo "Не удалось запустить $2; возможно, запуск занимает больше двух секунд. Проверьте журнал позже.";;
en:already_stopped) echo "$2 is already stopped.";;
ru:already_stopped) echo "$2 уже остановлен, повторная остановка не нужна.";;
en:stop_ok) echo "$2 stopped successfully";;
ru:stop_ok) echo "$2 успешно остановлен";;
en:stop_fail) echo "Could not stop $2; check the log later.";;
ru:stop_fail) echo "Не удалось остановить $2; проверьте журнал позже.";;
en:restart_ok) echo "$2 restarted successfully";;
ru:restart_ok) echo "$2 успешно перезапущен";;
en:restart_fail) echo "Could not restart $2; check the log later.";;
ru:restart_fail) echo "Не удалось перезапустить $2; проверьте журнал позже.";;
en:enable_ok) echo "Autostart for $2 enabled";;
ru:enable_ok) echo "Автозапуск $2 успешно включен";;
en:enable_fail) echo "Could not enable autostart for $2";;
ru:enable_fail) echo "Не удалось включить автозапуск $2";;
en:disable_ok) echo "Autostart for $2 disabled";;
ru:disable_ok) echo "Автозапуск $2 успешно отключен";;
en:disable_fail) echo "Could not disable autostart for $2";;
ru:disable_fail) echo "Не удалось отключить автозапуск $2";;
en:download_fail) echo "Could not download the script. Check that the server has GitHub access.";;
ru:download_fail) echo "Не удалось скачать скрипт. Проверьте, есть ли на сервере доступ к GitHub.";;
en:script_updated) echo "Script updated successfully, run it again";;
ru:script_updated) echo "Скрипт успешно обновлен, запустите его заново";;
en:already_installed) echo "Panel already installed; reinstallation is not required.";;
ru:already_installed) echo "Панель уже установлена, повторная установка не нужна.";;
en:install_first) echo "Install the panel first.";;
ru:install_first) echo "Сначала установите панель.";;
en:status_running) echo "$2 status: running";;
ru:status_running) echo "$2 статус: работает";;
en:status_stopped) echo "$2 status: stopped";;
ru:status_stopped) echo "$2 статус: не работает";;
en:status_missing) echo "$2 status: not installed";;
ru:status_missing) echo "$2 статус: не установлен";;
en:autostart_yes) echo "$2 autostart: yes";;
ru:autostart_yes) echo "$2 автозапуск: да";;
en:autostart_no) echo "$2 autostart: no";;
ru:autostart_no) echo "$2 автозапуск: нет";;
en:invalid_choice) echo "Invalid choice";;
ru:invalid_choice) echo "Недопустимый выбор";;
en:enable_bbr) echo "Enable BBR";;
ru:enable_bbr) echo "Включить BBR";;
en:disable_bbr) echo "Disable BBR";;
ru:disable_bbr) echo "Отключить BBR";;
en:back_main) echo "Return to the main menu";;
ru:back_main) echo "Вернуться в главное меню";;
en:select_option) echo "Select an option: ";;
ru:select_option) echo "Выберите пункт: ";;
en:bbr_already_off) echo "BBR is currently disabled.";;
ru:bbr_already_off) echo "BBR сейчас не включен.";;
en:bbr_to_cubic_ok) echo "BBR replaced with CUBIC successfully.";;
ru:bbr_to_cubic_ok) echo "BBR успешно заменен на CUBIC.";;
en:bbr_to_cubic_fail) echo "Could not replace BBR with CUBIC. Check the system configuration.";;
ru:bbr_to_cubic_fail) echo "Не удалось заменить BBR на CUBIC. Проверьте системную конфигурацию.";;
en:bbr_already_on) echo "BBR is already enabled!";;
ru:bbr_already_on) echo "BBR уже включен!";;
en:bbr_enabled) echo "BBR enabled successfully.";;
ru:bbr_enabled) echo "BBR успешно включен.";;
en:bbr_enable_fail) echo "Could not enable BBR. Check the system configuration.";;
ru:bbr_enable_fail) echo "Не удалось включить BBR. Проверьте системную конфигурацию.";;
en:os_not_supported) echo "Operating system is not supported. Inspect the script and install the required packages manually.";;
ru:os_not_supported) echo "Операционная система не поддерживается. Проверьте скрипт и установите нужные пакеты вручную.";;
en:installing_acme) echo "Installing acme...";;
ru:installing_acme) echo "Установка acme...";;
en:acme_install_fail) echo "Could not install acme";;
ru:acme_install_fail) echo "Не удалось установить acme";;
en:acme_install_ok) echo "acme installed successfully";;
ru:acme_install_ok) echo "acme успешно установлен";;
en:ssl_get) echo "Issue an SSL certificate";;
ru:ssl_get) echo "Получить SSL";;
en:ssl_revoke) echo "Revoke a certificate";;
ru:ssl_revoke) echo "Отозвать сертификат";;
en:ssl_force_renew) echo "Force renew";;
ru:ssl_force_renew) echo "Принудительно продлить";;
en:ssl_self_signed) echo "Self-signed certificate";;
ru:ssl_self_signed) echo "Самоподписанный сертификат";;
en:menu_title) echo "S-UI management script";;
ru:menu_title) echo "Скрипт управления S-UI";;
en:menu_exit) echo "Exit";;
ru:menu_exit) echo "Выход";;
en:menu_install) echo "Install";;
ru:menu_install) echo "Установить";;
en:menu_update) echo "Update";;
ru:menu_update) echo "Обновить";;
en:menu_custom_version) echo "Custom version";;
ru:menu_custom_version) echo "Пользовательская версия";;
en:menu_uninstall) echo "Uninstall";;
ru:menu_uninstall) echo "Удалить";;
en:menu_reset_admin) echo "Reset admin credentials to default";;
ru:menu_reset_admin) echo "Сбросить учетные данные администратора по умолчанию";;
en:menu_set_admin) echo "Set admin credentials";;
ru:menu_set_admin) echo "Задать учетные данные администратора";;
en:menu_view_admin) echo "Show admin credentials";;
ru:menu_view_admin) echo "Показать учетные данные администратора";;
en:menu_reset_settings) echo "Reset panel settings";;
ru:menu_reset_settings) echo "Сбросить настройки панели";;
en:menu_set_settings) echo "Configure panel";;
ru:menu_set_settings) echo "Настроить панель";;
en:menu_view_settings) echo "Show panel settings";;
ru:menu_view_settings) echo "Показать настройки панели";;
en:menu_start) echo "Start S-UI";;
ru:menu_start) echo "Запустить S-UI";;
en:menu_stop) echo "Stop S-UI";;
ru:menu_stop) echo "Остановить S-UI";;
en:menu_restart) echo "Restart S-UI";;
ru:menu_restart) echo "Перезапустить S-UI";;
en:menu_status) echo "Show S-UI status";;
ru:menu_status) echo "Показать статус S-UI";;
en:menu_log) echo "Show S-UI log";;
ru:menu_log) echo "Показать журнал S-UI";;
en:menu_enable_auto) echo "Enable S-UI autostart";;
ru:menu_enable_auto) echo "Включить автозапуск S-UI";;
en:menu_disable_auto) echo "Disable S-UI autostart";;
ru:menu_disable_auto) echo "Отключить автозапуск S-UI";;
en:menu_bbr) echo "Enable or disable BBR";;
ru:menu_bbr) echo "Включить или отключить BBR";;
en:menu_ssl) echo "Manage SSL certificates";;
ru:menu_ssl) echo "Управление SSL-сертификатами";;
en:menu_ssl_cf) echo "Cloudflare SSL certificate";;
ru:menu_ssl_cf) echo "SSL-сертификат Cloudflare";;
en:menu_language) echo "Language";;
ru:menu_language) echo "Язык";;
en:enter_choice_range) echo "Enter your choice [0-21]: ";;
ru:enter_choice_range) echo "Введите ваш выбор [0-21]: ";;
en:enter_valid_number) echo "Enter a valid number [0-21]";;
ru:enter_valid_number) echo "Введите корректное число [0-21]";;
en:lang_select) echo "Select language / Выберите язык / 请选择语言";;
ru:lang_select) echo "Select language / Выберите язык / 请选择语言";;
en:lang_set_to) echo "Language set to: $2";;
ru:lang_set_to) echo "Язык установлен: $2";;
en:usage_title) echo "S-UI management menu usage";;
ru:usage_title) echo "Использование меню управления S-UI";;
en:usage_main) echo "s-ui - admin management script";;
ru:usage_main) echo "s-ui - скрипт управления администратора";;
en:usage_start) echo "s-ui start - start s-ui";;
ru:usage_start) echo "s-ui start - запустить s-ui";;
en:usage_stop) echo "s-ui stop - stop s-ui";;
ru:usage_stop) echo "s-ui stop - остановить s-ui";;
en:usage_restart) echo "s-ui restart - restart s-ui";;
ru:usage_restart) echo "s-ui restart - перезапустить s-ui";;
en:usage_status) echo "s-ui status - show current s-ui status";;
ru:usage_status) echo "s-ui status - показать текущий статус s-ui";;
en:usage_enable) echo "s-ui enable - enable autostart";;
ru:usage_enable) echo "s-ui enable - включить автозапуск";;
en:usage_disable) echo "s-ui disable - disable autostart";;
ru:usage_disable) echo "s-ui disable - отключить автозапуск";;
en:usage_log) echo "s-ui log - show s-ui log";;
ru:usage_log) echo "s-ui log - показать журнал s-ui";;
en:usage_update) echo "s-ui update - update";;
ru:usage_update) echo "s-ui update - обновить";;
en:usage_install) echo "s-ui install - install";;
ru:usage_install) echo "s-ui install - установить";;
en:usage_uninstall) echo "s-ui uninstall - uninstall";;
ru:usage_uninstall) echo "s-ui uninstall - удалить";;
en:usage_help) echo "s-ui help - management menu help";;
ru:usage_help) echo "s-ui help - справка по меню управления";;
*) echo "${key}";;
esac
}
load_language
function LOGD() { echo -e "${yellow}$(t debug_tag) $* ${plain}"; }
function LOGE() { echo -e "${red}$(t error_tag) $* ${plain}"; }
function LOGI() { echo -e "${green}$(t info_tag) $* ${plain}"; }
[[ $EUID -ne 0 ]] && LOGE "$(t run_as_root)\n" && exit 1
if [[ -f /etc/os-release ]]; then
source /etc/os-release
release=$ID
elif [[ -f /usr/lib/os-release ]]; then
source /usr/lib/os-release
release=$ID
else
echo "$(t detect_failed)" >&2
exit 1
fi
echo "$(t current_release "${release}")"
confirm() {
if [[ $# > 1 ]]; then
echo && read -p "$1 [$(t default_n "$2")]: " temp
if [[ x"${temp}" == x"" ]]; then
temp=$2
fi
else
read -p "$1 [y/n]: " temp
fi
if [[ x"${temp}" == x"y" || x"${temp}" == x"Y" ]]; then
return 0
else
return 1
fi
}
confirm_restart() {
confirm "$(t restart_service_q "${1}")" "y"
if [[ $? == 0 ]]; then
restart
else
show_menu
fi
}
before_show_menu() {
echo && echo -n -e "${yellow}$(t press_enter_main)${plain}" && read temp
show_menu
}
install() {
bash <(curl -Ls https://raw.githubusercontent.com/deposist/s-ui-rus-inst/main/install.sh)
if [[ $? == 0 ]]; then
if [[ $# == 0 ]]; then
start
else
start 0
fi
fi
}
update() {
confirm "$(t install_force_q)" "n"
if [[ $? != 0 ]]; then
LOGE "$(t cancelled)"
if [[ $# == 0 ]]; then
before_show_menu
fi
return 0
fi
bash <(curl -Ls https://raw.githubusercontent.com/deposist/s-ui-rus-inst/main/install.sh)
if [[ $? == 0 ]]; then
LOGI "$(t update_done)"
exit 0
fi
}
custom_version() {
echo "$(t enter_panel_version)"
read panel_version
if [ -z "$panel_version" ]; then
echo "$(t version_required)"
exit 1
fi
[[ "${panel_version}" != v* ]] && panel_version="v${panel_version}"
download_link="https://raw.githubusercontent.com/deposist/s-ui-rus-inst/main/install.sh"
install_command="bash <(curl -Ls $download_link) $panel_version"
echo "$(t downloading_version "${panel_version}")"
eval "$install_command"
}
uninstall() {
confirm "$(t uninstall_q)" "n"
if [[ $? != 0 ]]; then
if [[ $# == 0 ]]; then
show_menu
fi
return 0
fi
systemctl stop s-ui
systemctl disable s-ui
rm /etc/systemd/system/s-ui.service -f
systemctl daemon-reload
systemctl reset-failed
rm /etc/s-ui/ -rf
rm /usr/local/s-ui/ -rf
echo ""
echo -e "$(t uninstall_done)"
echo ""
if [[ $# == 0 ]]; then
before_show_menu
fi
}
reset_admin() {
echo "$(t reset_admin_warn)"
confirm "$(t reset_admin_q)" "n"
if [[ $? == 0 ]]; then
/usr/local/s-ui/sui admin -reset
fi
before_show_menu
}
set_admin() {
echo "$(t set_admin_warn)"
read -p "$(t set_username_p)" config_account
read -p "$(t set_password_p)" config_password
/usr/local/s-ui/sui admin -username "${config_account}" -password "${config_password}"
before_show_menu
}
view_admin() {
/usr/local/s-ui/sui admin -show
before_show_menu
}
reset_setting() {
confirm "$(t reset_settings_q)" "n"
if [[ $? == 0 ]]; then
/usr/local/s-ui/sui setting -reset
fi
before_show_menu
}
set_setting() {
echo -e "$(t enter_panel_port)"
read config_port
echo -e "$(t enter_panel_path)"
read config_path
echo -e "$(t enter_sub_port)"
read config_subPort
echo -e "$(t enter_sub_path)"
read config_subPath
echo -e "${yellow}$(t initializing)${plain}"
params=""
[ -z "$config_port" ] || params="$params -port $config_port"
[ -z "$config_path" ] || params="$params -path $config_path"
[ -z "$config_subPort" ] || params="$params -subPort $config_subPort"
[ -z "$config_subPath" ] || params="$params -subPath $config_subPath"
/usr/local/s-ui/sui setting ${params}
before_show_menu
}
view_setting() {
/usr/local/s-ui/sui setting -show
view_uri
before_show_menu
}
view_uri() {
info=$(/usr/local/s-ui/sui uri)
if [[ $? != 0 ]]; then
LOGE "$(t could_not_get_uri)"
before_show_menu
fi
LOGI "$(t panel_url)"
echo -e "${green}${info}${plain}"
}
start() {
check_status $1
if [[ $? == 0 ]]; then
echo ""
LOGI "$(t already_running "${1}")"
else
systemctl start $1
sleep 2
check_status $1
if [[ $? == 0 ]]; then
LOGI "$(t start_ok "${1}")"
else
LOGE "$(t start_fail "${1}")"
fi
fi
if [[ $# == 1 ]]; then
before_show_menu
fi
}
stop() {
check_status $1
if [[ $? == 1 ]]; then
echo ""
LOGI "$(t already_stopped "${1}")"
else
systemctl stop $1
sleep 2
check_status
if [[ $? == 1 ]]; then
LOGI "$(t stop_ok "${1}")"
else
LOGE "$(t stop_fail "${1}")"
fi
fi
if [[ $# == 1 ]]; then
before_show_menu
fi
}
restart() {
systemctl restart $1
sleep 2
check_status $1
if [[ $? == 0 ]]; then
LOGI "$(t restart_ok "${1}")"
else
LOGE "$(t restart_fail "${1}")"
fi
if [[ $# == 1 ]]; then
before_show_menu
fi
}
status() {
systemctl status s-ui -l
if [[ $# == 0 ]]; then
before_show_menu
fi
}
enable() {
systemctl enable $1
if [[ $? == 0 ]]; then
LOGI "$(t enable_ok "${1}")"
else
LOGE "$(t enable_fail "${1}")"
fi
if [[ $# == 1 ]]; then
before_show_menu
fi
}
disable() {
systemctl disable $1
if [[ $? == 0 ]]; then
LOGI "$(t disable_ok "${1}")"
else
LOGE "$(t disable_fail "${1}")"
fi
if [[ $# == 1 ]]; then
before_show_menu
fi
}
show_log() {
journalctl -u $1.service -e --no-pager -f
if [[ $# == 1 ]]; then
before_show_menu
fi
}
update_shell() {
wget -O /usr/bin/s-ui -N --no-check-certificate https://github.com/deposist/s-ui-rus-inst/raw/main/s-ui.sh
if [[ $? != 0 ]]; then
echo ""
LOGE "$(t download_fail)"
before_show_menu
else
chmod +x /usr/bin/s-ui
LOGI "$(t script_updated)" && exit 0
fi
}
check_status() {
if [[ ! -f "/etc/systemd/system/$1.service" ]]; then
return 2
fi
temp=$(systemctl status "$1" | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1)
if [[ x"${temp}" == x"running" ]]; then
return 0
else
return 1
fi
}
check_enabled() {
temp=$(systemctl is-enabled $1)
if [[ x"${temp}" == x"enabled" ]]; then
return 0
else
return 1
fi
}
check_uninstall() {
check_status s-ui
if [[ $? != 2 ]]; then
echo ""
LOGE "$(t already_installed)"
if [[ $# == 0 ]]; then
before_show_menu
fi
return 1
else
return 0
fi
}
check_install() {
check_status s-ui
if [[ $? == 2 ]]; then
echo ""
LOGE "$(t install_first)"
if [[ $# == 0 ]]; then
before_show_menu
fi
return 1
else
return 0
fi
}
show_status() {
check_status $1
case $? in
0)
echo -e "${green}$(t status_running "${1}")${plain}"
show_enable_status $1
;;
1)
echo -e "${yellow}$(t status_stopped "${1}")${plain}"
show_enable_status $1
;;
2)
echo -e "${red}$(t status_missing "${1}")${plain}"
;;
esac
}
show_enable_status() {
check_enabled $1
if [[ $? == 0 ]]; then
echo -e "${green}$(t autostart_yes "${1}")${plain}"
else
echo -e "${red}$(t autostart_no "${1}")${plain}"
fi
}
bbr_menu() {
echo -e "${green}\t1.${plain} $(t enable_bbr)"
echo -e "${green}\t2.${plain} $(t disable_bbr)"
echo -e "${green}\t0.${plain} $(t back_main)"
read -p "$(t select_option)" choice
case "$choice" in
0) show_menu ;;
1) enable_bbr ;;
2) disable_bbr ;;
*) echo "$(t invalid_choice)" ;;
esac
}
disable_bbr() {
if ! grep -q "net.core.default_qdisc=fq" /etc/sysctl.conf || ! grep -q "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then
echo -e "${yellow}$(t bbr_already_off)${plain}"
exit 0
fi
sed -i 's/net.core.default_qdisc=fq/net.core.default_qdisc=pfifo_fast/' /etc/sysctl.conf
sed -i 's/net.ipv4.tcp_congestion_control=bbr/net.ipv4.tcp_congestion_control=cubic/' /etc/sysctl.conf
sysctl -p
if [[ $(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}') == "cubic" ]]; then
echo -e "${green}$(t bbr_to_cubic_ok)${plain}"
else
echo -e "${red}$(t bbr_to_cubic_fail)${plain}"
fi
}
enable_bbr() {
if grep -q "net.core.default_qdisc=fq" /etc/sysctl.conf && grep -q "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then
echo -e "${green}$(t bbr_already_on)${plain}"
exit 0
fi
case "${release}" in
ubuntu | debian | armbian)
apt-get update && apt-get install -yqq --no-install-recommends ca-certificates ;;
centos | almalinux | rocky | oracle)
yum -y update && yum -y install ca-certificates ;;
fedora)
dnf -y update && dnf -y install ca-certificates ;;
arch | manjaro | parch)
pacman -Sy --noconfirm ca-certificates ;;
*)
echo -e "${red}$(t os_not_supported)${plain}\n"
exit 1 ;;
esac
echo "net.core.default_qdisc=fq" | tee -a /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" | tee -a /etc/sysctl.conf
sysctl -p
if [[ $(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}') == "bbr" ]]; then
echo -e "${green}$(t bbr_enabled)${plain}"
else
echo -e "${red}$(t bbr_enable_fail)${plain}"
fi
}
install_acme() {
cd ~
LOGI "$(t installing_acme)"
curl https://get.acme.sh | sh
if [ $? -ne 0 ]; then
LOGE "$(t acme_install_fail)"
return 1
else
LOGI "$(t acme_install_ok)"
fi
return 0
}
ssl_cert_issue_main() {
echo -e "${green}\t1.${plain} $(t ssl_get)"
echo -e "${green}\t2.${plain} $(t ssl_revoke)"
echo -e "${green}\t3.${plain} $(t ssl_force_renew)"
echo -e "${green}\t4.${plain} $(t ssl_self_signed)"
read -p "$(t select_option)" choice
case "$choice" in
1) ssl_cert_issue ;;
2)
local domain=""
read -p "Domain to revoke / Введите домен сертификата для отзыва: " domain
~/.acme.sh/acme.sh --revoke -d "${domain}"
LOGI "Certificate revoked / Сертификат отозван"
;;
3)
local domain=""
read -p "Domain to force-renew / Введите домен SSL-сертификата для принудительного продления: " domain
~/.acme.sh/acme.sh --renew -d "${domain}" --force ;;
4) generate_self_signed_cert ;;
*) echo "$(t invalid_choice)" ;;
esac
}
ssl_cert_issue() {
if ! command -v ~/.acme.sh/acme.sh &>/dev/null; then
echo "acme.sh not found, installing / acme.sh не найден, будет выполнена установка"
install_acme
if [ $? -ne 0 ]; then
LOGE "Could not install acme / Не удалось установить acme"
exit 1
fi
fi
case "${release}" in
ubuntu | debian | armbian) apt update && apt install socat -y ;;
centos | almalinux | rocky | oracle) yum -y update && yum -y install socat ;;
fedora) dnf -y update && dnf -y install socat ;;
arch | manjaro | parch) pacman -Sy --noconfirm socat ;;
*) echo -e "${red}$(t os_not_supported)${plain}\n"; exit 1 ;;
esac
local domain=""
read -p "Domain / Домен: " domain
LOGD "Domain: ${domain}"
local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
if [ "${currentCert}" == "${domain}" ]; then
local certInfo=$(~/.acme.sh/acme.sh --list)
LOGE "Certificate already exists; cannot reissue. Current data:"
LOGI "$certInfo"
exit 1
fi
certPath="/root/cert/${domain}"
rm -rf "$certPath"
mkdir -p "$certPath"
local WebPort=80
read -p "Port (default 80) / Порт (по умолчанию 80): " WebPort
if [[ ${WebPort} -gt 65535 || ${WebPort} -lt 1 ]]; then
LOGE "Invalid port; using default."
WebPort=80
fi
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
~/.acme.sh/acme.sh --issue -d "${domain}" --standalone --httpport "${WebPort}"
if [ $? -ne 0 ]; then
LOGE "Issue failed; aborting."
rm -rf ~/.acme.sh/${domain}
exit 1
fi
~/.acme.sh/acme.sh --installcert -d "${domain}" \
--key-file "/root/cert/${domain}/privkey.pem" \
--fullchain-file "/root/cert/${domain}/fullchain.pem"
~/.acme.sh/acme.sh --upgrade --auto-upgrade
chmod 755 "$certPath"/*
ls -lah "$certPath"/*
}
ssl_cert_issue_CF() {
LOGD "******Cloudflare SSL******"
echo "1) Issue / Выпустить новый сертификат через Cloudflare"
echo "2) Force renew / Принудительно продлить существующий сертификат"
echo "3) Back / Вернуться"
read -p "Choice [1-3]: " choice
certPath="/root/cert-CF"
case $choice in
1|2)
force_flag=""
[ "$choice" -eq 2 ] && force_flag="--force"
if ! command -v ~/.acme.sh/acme.sh &>/dev/null; then
install_acme || exit 1
fi
CF_Domain=""
CF_GlobalKey=""
CF_AccountEmail=""
read -p "Domain / Домен: " CF_Domain
read -p "Cloudflare Global API key / API key: " CF_GlobalKey
read -p "Cloudflare account email / Email: " CF_AccountEmail
rm -rf "$certPath" && mkdir -p "$certPath"
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt || exit 1
export CF_Key="${CF_GlobalKey}"
export CF_Email="${CF_AccountEmail}"
~/.acme.sh/acme.sh --issue --dns dns_cf -d "${CF_Domain}" -d "*.${CF_Domain}" $force_flag --log || exit 1
mkdir -p "${certPath}/${CF_Domain}"
~/.acme.sh/acme.sh --installcert -d "${CF_Domain}" -d "*.${CF_Domain}" \
--fullchain-file "${certPath}/${CF_Domain}/fullchain.pem" \
--key-file "${certPath}/${CF_Domain}/privkey.pem"
~/.acme.sh/acme.sh --upgrade --auto-upgrade
chmod 755 "${certPath}/${CF_Domain}"
ls -lah "${certPath}/${CF_Domain}"
show_menu
;;
3) show_menu ;;
*) echo "$(t invalid_choice)"; show_menu ;;
esac
}
generate_self_signed_cert() {
cert_dir="/etc/sing-box"
mkdir -p "$cert_dir"
LOGI "Choose certificate type / Выберите тип сертификата:"
echo -e "${green}\t1.${plain} Ed25519 (recommended / рекомендуется)"
echo -e "${green}\t2.${plain} RSA 2048"
echo -e "${green}\t3.${plain} RSA 4096"
echo -e "${green}\t4.${plain} ECDSA prime256v1"
echo -e "${green}\t5.${plain} ECDSA secp384r1"
read -p "Choice [1-5, default 1]: " cert_type
cert_type=${cert_type:-1}
case "$cert_type" in
1) algo="ed25519"; key_opt="-newkey ed25519" ;;
2) algo="rsa"; key_opt="-newkey rsa:2048" ;;
3) algo="rsa"; key_opt="-newkey rsa:4096" ;;
4) algo="ecdsa"; key_opt="-newkey ec -pkeyopt ec_paramgen_curve:prime256v1" ;;
5) algo="ecdsa"; key_opt="-newkey ec -pkeyopt ec_paramgen_curve:secp384r1" ;;
*) algo="ed25519"; key_opt="-newkey ed25519" ;;
esac
LOGI "Generating self-signed certificate ($algo)..."
sudo openssl req -x509 -nodes -days 3650 $key_opt \
-keyout "${cert_dir}/self.key" \
-out "${cert_dir}/self.crt" \
-subj "/CN=myserver"
if [[ $? -eq 0 ]]; then
sudo chmod 600 "${cert_dir}/self."*
LOGI "Self-signed certificate created."
LOGI "Path: ${cert_dir}/self.crt"
LOGI "Key: ${cert_dir}/self.key"
else
LOGE "Could not create self-signed certificate."
fi
before_show_menu
}
choose_language() {
echo "$(t lang_select):"
echo " 1) English"
echo " 2) Русский"
echo " 3) 中文"
read -rp "[1-3]: " lang_choice
case "${lang_choice}" in
1|en|EN|English) lang="en" ;;
2|ru|RU|Russian|Русский) lang="ru" ;;
3|zh|ZH|Chinese|中文|简体中文) lang="zh" ;;
*) ;;
esac
save_language
LOGI "$(t lang_set_to "${lang}")"
before_show_menu
}