From e37f2d322256ed4468fd0277b0cb10a5bf4ccaa9 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Wed, 9 Oct 2024 11:15:37 +0200 Subject: [PATCH] Username & Password will be generated randomly --- install.sh | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index 2926f6b33..c4cc6798f 100644 --- a/install.sh +++ b/install.sh @@ -138,27 +138,25 @@ gen_random_string() { config_after_install() { 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 + read -p "Would you like to customize ${yellow}the Panel Port ${plain}settings? (If not, random settings will be applied) [y/n]: " config_confirm - local config_webBasePath=$(gen_random_string 10) + local config_webBasePath=$(gen_random_string 15) + local config_account=$(gen_random_string 10) + local config_password=$(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}" + echo -e "${yellow}Your Panel Port is: ${config_port}${plain}" - echo -e "${yellow}Your web base path will be generated randomly: ${config_webBasePath}${plain}" + echo -e "${yellow}Your Username will be generated randomly: ${config_account}${plain}" + echo -e "${yellow}Your Password will be generated randomly: ${config_password}${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}" -port "${config_port}" -webBasePath "${config_webBasePath}" - echo -e "${yellow}Settings applied successfully!${plain}" + echo -e "${green}Settings applied successfully!${plain}" echo -e "###############################################" echo -e "${green}Username: ${config_account}${plain}" @@ -173,15 +171,13 @@ config_after_install() { if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then - 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}" + /usr/local/x-ui/x-ui setting -username "${config_account}" -password "${config_password}" -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}Username: ${config_account}${plain}" + echo -e "${green}Password: ${config_password}${plain}" echo -e "${green}Port: ${portTemp}${plain}" echo -e "${green}WebBasePath: ${config_webBasePath}${plain}" echo -e "###############################################" @@ -195,7 +191,7 @@ config_after_install() { echo -e "${yellow}WebBasePath is empty, generating a random one...${plain}" /usr/local/x-ui/x-ui setting -webBasePath "${config_webBasePath}" - echo -e "${green}New webBasePath: ${config_webBasePath}${plain}" + echo -e "${green}New WebBasePath: ${config_webBasePath}${plain}" fi fi fi