Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhsanaei <ho3ein.sanaei@gmail.com>2024-10-04 12:17:59 +0300
committermhsanaei <ho3ein.sanaei@gmail.com>2024-10-04 14:41:52 +0300
commitc3ce1da0d6090c2d6019dc2049dde908f7288a99 (patch)
tree646bf337c6232defb5f25843b99a8cc7b627e587
parent02bc488c1c1024e9be44ae3cfdf678b20bb4d6b3 (diff)
Web base path will be generated randomly
-rw-r--r--README.es_ES.md9
-rw-r--r--README.md9
-rw-r--r--README.ru_RU.md9
-rw-r--r--README.zh_CN.md9
-rw-r--r--install.sh59
-rw-r--r--x-ui.sh11
6 files changed, 71 insertions, 35 deletions
diff --git a/README.es_ES.md b/README.es_ES.md
index 24f7f309..5da2e5a6 100644
--- a/README.es_ES.md
+++ b/README.es_ES.md
@@ -284,11 +284,14 @@ Nuestra plataforma ofrece compatibilidad con una amplia gama de arquitecturas y
<details>
<summary>Haz clic para ver los detalles de la configuración predeterminada</summary>
-### Nombre de Usuario & Contraseña & Ruta Base Web:
+### Nombre de usuario, Contraseña, Puerto y Ruta Base Web
- Estos se generarán aleatoriamente si no los modificas.
+Si elige no modificar estas configuraciones, se generarán aleatoriamente (esto no se aplica a Docker).
- - **Puerto:** el puerto predeterminado para el panel es `2053`
+**Configuraciones predeterminadas para Docker:**
+- **Nombre de usuario:** admin
+- **Contraseña:** admin
+- **Puerto:** 2053
### Gestión de la Base de Datos:
diff --git a/README.md b/README.md
index b15c4064..a2edad7f 100644
--- a/README.md
+++ b/README.md
@@ -315,11 +315,14 @@ Our platform offers compatibility with a diverse range of architectures and devi
<details>
<summary>Click for default settings details</summary>
-### Username & Password & webbasepath:
+### Username, Password, Port, and Web Base Path
- These will be generated randomly if you skip modifying them.
+If you choose not to modify these settings, they will be generated randomly (this does not apply to Docker).
- - **Port:** the default port for panel is `2053`
+**Default Settings for Docker:**
+- **Username:** admin
+- **Password:** admin
+- **Port:** 2053
### Database Management:
diff --git a/README.ru_RU.md b/README.ru_RU.md
index 329c6cc1..0da90fb6 100644
--- a/README.ru_RU.md
+++ b/README.ru_RU.md
@@ -312,11 +312,14 @@ location /sub {
<details>
<summary>Нажмите для получения информации о настройках по умолчанию</summary>
-### Имя пользователя и пароль & webbasepath:
+### Имя пользователя, Пароль, Порт и Web Base Path
-Эти параметры будут сгенерированы случайным образом, если вы пропустите их изменение.
+Если вы не измените эти настройки, они будут сгенерированы случайным образом (это не относится к Docker).
- - **Порт:** порт панели по умолчанию — `2053`
+**Настройки по умолчанию для Docker:**
+- **Имя пользователя:** admin
+- **Пароль:** admin
+- **Порт:** 2053
### Управление базой данных:
diff --git a/README.zh_CN.md b/README.zh_CN.md
index 240095f4..0aa7efcf 100644
--- a/README.zh_CN.md
+++ b/README.zh_CN.md
@@ -306,11 +306,14 @@ location /sub {
<details>
<summary>点击查看默认设置详情</summary>
-### 用户名 & 密码 & Web基础路径:
+### 用户名、密码、端口和 Web Base Path
- 如果不修改这些,它们将会随机生成。
+如果您选择不修改这些设置,它们将随机生成(不适用于 Docker)。
- - **端口号:** 面板的默认端口号是 `2053`
+**Docker 的默认设置:**
+- **用户名:** admin
+- **密码:** admin
+- **端口:** 2053
### 数据库管理:
diff --git a/install.sh b/install.sh
index 3435fc76..6076acde 100644
--- a/install.sh
+++ b/install.sh
@@ -131,44 +131,67 @@ gen_random_string() {
echo "$random_string"
}
-# This function will be called when user installed x-ui out of security
config_after_install() {
- echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}"
+ echo -e "${yellow}Install/update finished! For security, it's recommended to modify panel settings ${plain}"
read -p "Would you like to customize the panel settings? (If not, random settings will be applied) [y/n]: " config_confirm
+
+ local config_webBasePath=$(gen_random_string 10)
+
if [[ "${config_confirm}" == "y" || "${config_confirm}" == "Y" ]]; then
+
read -p "Please set up your username: " config_account
echo -e "${yellow}Your username will be: ${config_account}${plain}"
+
read -p "Please set up your password: " config_password
echo -e "${yellow}Your password will be: ${config_password}${plain}"
+
read -p "Please set up the panel port: " config_port
echo -e "${yellow}Your panel port is: ${config_port}${plain}"
- read -p "Please set up the web base path (ip:port/webbasepath/): " config_webBasePath
- echo -e "${yellow}Your web base path is: ${config_webBasePath}${plain}"
+
+ echo -e "${yellow}Your web base path will be generated randomly: ${config_webBasePath}${plain}"
+
echo -e "${yellow}Initializing, please wait...${plain}"
- /usr/local/x-ui/x-ui setting -username ${config_account} -password ${config_password}
- echo -e "${yellow}Account name and password set successfully!${plain}"
- /usr/local/x-ui/x-ui setting -port ${config_port}
- echo -e "${yellow}Panel port set successfully!${plain}"
- /usr/local/x-ui/x-ui setting -webBasePath ${config_webBasePath}
- echo -e "${yellow}Web base path set successfully!${plain}"
+
+ /usr/local/x-ui/x-ui setting -username "${config_account}" -password "${config_password}" -port "${config_port}" -webBasePath "${config_webBasePath}"
+ echo -e "${yellow}Settings applied successfully!${plain}"
+
+ echo -e "###############################################"
+ echo -e "${green}Username: ${config_account}${plain}"
+ echo -e "${green}Password: ${config_password}${plain}"
+ echo -e "${green}Port: ${config_port}${plain}"
+ echo -e "${green}WebBasePath: ${config_webBasePath}${plain}"
+ echo -e "###############################################"
+
else
+
echo -e "${red}Cancel...${plain}"
+
if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then
- local usernameTemp=$(head -c 6 /dev/urandom | base64)
- local passwordTemp=$(head -c 6 /dev/urandom | base64)
- local webBasePathTemp=$(gen_random_string 10)
- /usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} -webBasePath ${webBasePathTemp}
- echo -e "This is a fresh installation, will generate random login info for security concerns:"
+
+ local usernameTemp=$(gen_random_string 10)
+ local passwordTemp=$(gen_random_string 10)
+ local portTemp=$(shuf -i 1024-62000 -n 1)
+
+ /usr/local/x-ui/x-ui setting -username "${usernameTemp}" -password "${passwordTemp}" -port "${portTemp}" -webBasePath "${config_webBasePath}"
+ echo -e "This is a fresh installation, generating random login info for security concerns:"
echo -e "###############################################"
echo -e "${green}Username: ${usernameTemp}${plain}"
echo -e "${green}Password: ${passwordTemp}${plain}"
- echo -e "${green}WebBasePath: ${webBasePathTemp}${plain}"
+ echo -e "${green}Port: ${portTemp}${plain}"
+ echo -e "${green}WebBasePath: ${config_webBasePath}${plain}"
echo -e "###############################################"
- echo -e "${yellow}If you forgot your login info, you can type "x-ui settings" to check after installation${plain}"
+ echo -e "${yellow}If you forgot your login info, you can type 'x-ui settings' to check after installation${plain}"
else
- echo -e "${yellow}This is your upgrade, will keep old settings. If you forgot your login info, you can type "x-ui settings" to check${plain}"
+ echo -e "${yellow}This is your upgrade, keeping old settings. If you forgot your login info, you can type 'x-ui settings' to check${plain}"
+
+ local existing_webBasePath=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'webBasePath: [^ ]+' | awk '{print $2}')
+ if [[ -z "$existing_webBasePath" ]]; then
+ echo -e "${yellow}WebBasePath is empty, generating a random one: ${config_webBasePath}${plain}"
+ /usr/local/x-ui/x-ui setting -webBasePath "${config_webBasePath}"
+ fi
fi
fi
+
/usr/local/x-ui/x-ui migrate
}
diff --git a/x-ui.sh b/x-ui.sh
index e4bc622b..545b1af5 100644
--- a/x-ui.sh
+++ b/x-ui.sh
@@ -265,12 +265,13 @@ gen_random_string() {
reset_webbasepath() {
echo -e "${yellow}Resetting Web Base Path${plain}"
- # Prompt user to set a new web base path
- read -rp "Please set the new web base path [press 'y' for a random path]: " config_webBasePath
-
- if [[ $config_webBasePath == "y" ]]; then
- config_webBasePath=$(gen_random_string 10)
+ read -rp "Are you sure you want to reset the web base path? (y/n): " confirm
+ if [[ $confirm != "y" && $confirm != "Y" ]]; then
+ echo -e "${yellow}Operation canceled.${plain}"
+ return
fi
+
+ config_webBasePath=$(gen_random_string 10)
# Apply the new web base path setting
/usr/local/x-ui/x-ui setting -webBasePath "${config_webBasePath}" >/dev/null 2>&1