diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2024-10-29 17:07:56 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2024-10-29 17:20:38 +0300 |
| commit | 13f7e071285f57327c8c741d5c691ddf2a9f9621 (patch) | |
| tree | 92d05477d13a123294002d40a779a1fa48fc5097 | |
| parent | 0e3691fdbd5d760298e761b6f483abcbcfb07c77 (diff) | |
bash - Access URL
I will add https with domain later
| -rw-r--r-- | install.sh | 6 | ||||
| -rw-r--r-- | x-ui.sh | 9 |
2 files changed, 13 insertions, 2 deletions
@@ -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 @@ -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() { |
