Skip to content

Commit

Permalink
Username & Password will be generated randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
MHSanaei committed Oct 9, 2024
1 parent 4f2f855 commit e37f2d3
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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 "###############################################"
Expand All @@ -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
Expand Down

0 comments on commit e37f2d3

Please sign in to comment.