Username & Password will be generated randomly

This commit is contained in:
mhsanaei 2024-10-09 11:15:37 +02:00
parent 4f2f855c04
commit e37f2d3222
No known key found for this signature in database
GPG Key ID: 4DACC0663B5986F5

View File

@ -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