diff --git a/install.sh b/install.sh index ecd4fdb128..aaa4f7782a 100644 --- a/install.sh +++ b/install.sh @@ -142,6 +142,8 @@ config_after_install() { local existing_username=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'username: .+' | awk '{print $2}') local existing_password=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'password: .+' | awk '{print $2}') local existing_webBasePath=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'webBasePath: .+' | awk '{print $2}') + local existing_port=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'port: .+' | awk '{print $2}') + local server_ip=$(curl -s https://api.ipify.org) if [[ ${#existing_webBasePath} -lt 4 ]]; then if [[ "$existing_username" == "admin" && "$existing_password" == "admin" ]]; then @@ -149,7 +151,7 @@ config_after_install() { local config_username=$(gen_random_string 10) local config_password=$(gen_random_string 10) - read -p "Would you like to customize the Panel Port settings? (If not, random port will be applied) [y/n]: " config_confirm + read -p "Would you like to customize the Panel Port settings? (If not, a random port will be applied) [y/n]: " config_confirm if [[ "${config_confirm}" == "y" || "${config_confirm}" == "Y" ]]; then read -p "Please set up the panel port: " config_port echo -e "${yellow}Your Panel Port is: ${config_port}${plain}" @@ -165,6 +167,7 @@ config_after_install() { echo -e "${green}Password: ${config_password}${plain}" echo -e "${green}Port: ${config_port}${plain}" echo -e "${green}WebBasePath: ${config_webBasePath}${plain}" + echo -e "${green}Access URL: http://${server_ip}:${config_port}${config_webBasePath}${plain}" echo -e "###############################################" echo -e "${yellow}If you forgot your login info, you can type 'x-ui settings' to check${plain}" else @@ -172,6 +175,7 @@ config_after_install() { echo -e "${yellow}WebBasePath is missing or too short. Generating a new one...${plain}" /usr/local/x-ui/x-ui setting -webBasePath "${config_webBasePath}" echo -e "${green}New WebBasePath: ${config_webBasePath}${plain}" + echo -e "${green}Access URL: http://${server_ip}:${existing_port}${config_webBasePath}${plain}" fi else if [[ "$existing_username" == "admin" && "$existing_password" == "admin" ]]; then diff --git a/x-ui.sh b/x-ui.sh index e09d0b05e3..7d669d5f61 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -308,12 +308,19 @@ reset_config() { } check_config() { - info=$(/usr/local/x-ui/x-ui setting -show true) + local info=$(/usr/local/x-ui/x-ui setting -show true) if [[ $? != 0 ]]; then LOGE "get current settings error, please check logs" show_menu + return fi LOGI "${info}" + + local existing_webBasePath=$(echo "$info" | grep -Eo 'webBasePath: .+' | awk '{print $2}') + local existing_port=$(echo "$info" | grep -Eo 'port: .+' | awk '{print $2}') + local server_ip=$(curl -s https://api.ipify.org) + + echo -e "${green}Access URL: http://${server_ip}:${existing_port}${existing_webBasePath}${plain}" } set_port() {