diff --git a/install.sh b/install.sh index 2ead995472..01a67bdf90 100644 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash red='\033[0;31m' green='\033[0;32m' @@ -97,8 +97,22 @@ config_after_install() { echo -e "${yellow}面板端口设定完成${plain}" else echo -e "${red}已取消设定...${plain}" - echo -e "${red}如属于全新安装,默认网页端口为 ${green}54321${plain},用户名与密码均为 ${green}admin${plain},请及时修改" - echo -e "${red}如属于版本升级,则保留之前设置项,登录方式保持不变,可输入x-ui后键入数字7查看登录信息${plain}" + if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then + local usernameTemp=$(head -c 6 /dev/urandom | base64) + local passwordTemp=$(head -c 6 /dev/urandom | base64) + local portTemp=$(echo $RANDOM) + /usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} + /usr/local/x-ui/x-ui setting -port ${portTemp} + echo -e "检测到您属于全新安装,出于安全考虑已自动为您生成随机用户与端口:" + echo -e "###############################################" + echo -e "${green}面板登录用户名:${usernameTemp}${plain}" + echo -e "${green}面板登录用户密码:${passwordTemp}${plain}" + echo -e "${red}面板登录端口:${portTemp}${plain}" + echo -e "###############################################" + echo -e "${red}如您遗忘了面板登录相关信息,可在安装完成后输入x-ui,输入选项7查看面板登录信息${plain}" + else + echo -e "${red}当前属于版本升级,保留之前设置项,登录方式保持不变,可输入x-ui后键入数字7查看面板登录信息${plain}" + fi fi } diff --git a/install_en.sh b/install_en.sh index 0faa419c74..cc532d04e5 100644 --- a/install_en.sh +++ b/install_en.sh @@ -97,8 +97,22 @@ config_after_install() { echo -e "${yellow}panel port set down!${plain}" else echo -e "${red}cancel...${plain}" - echo -e "${red}if this is your first time to install,the default panel port is ${green}54321${plain},username and password both are${green}admin${plain},please change them in time" - echo -e "${red}if this is your upgrade,keep the old settings,if you forgot you login info,you can type x-ui and then type 7 to check${plain}" + if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then + local usernameTemp=$(head -c 6 /dev/urandom | base64) + local passwordTemp=$(head -c 6 /dev/urandom | base64) + local portTemp=$(echo $RANDOM) + /usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} + /usr/local/x-ui/x-ui setting -port ${portTemp} + echo -e "this is a fresh installation,will generate random login info for security concerns:" + echo -e "###############################################" + echo -e "${green}user name:${usernameTemp}${plain}" + echo -e "${green}user password:${passwordTemp}${plain}" + echo -e "${red}web port:${portTemp}${plain}" + echo -e "###############################################" + echo -e "${red}if you forgot your login info,you can type x-ui and then type 7 to check after installation${plain}" + else + echo -e "${red} this is your upgrade,will keep old settings,if you forgot your login info,you can type x-ui and then type 7 to check${plain}" + fi fi } diff --git a/x-ui.sh b/x-ui.sh index d39cd2aaab..4284b540e4 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -519,8 +519,8 @@ ssl_cert_issue_standalone() { fi #install cert ~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \ - --cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \ - --fullchain-file /root/cert/fullchain.cer + --cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \ + --fullchain-file /root/cert/fullchain.cer if [ $? -ne 0 ]; then LOGE "证书安装失败,脚本退出" @@ -604,8 +604,8 @@ ssl_cert_issue_by_cloudflare() { LOGI "证书签发成功,安装中..." fi ~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \ - --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ - --fullchain-file /root/cert/fullchain.cer + --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ + --fullchain-file /root/cert/fullchain.cer if [ $? -ne 0 ]; then LOGE "证书安装失败,脚本退出" rm -rf ~/.acme.sh/${CF_Domain} @@ -816,7 +816,7 @@ show_menu() { ${green}17.${plain} 配置x-ui定时任务 " show_status - echo && read -p "请输入选择 [0-16]: " num + echo && read -p "请输入选择 [0-17],查看面板登录信息请输入数字7:" num case "${num}" in 0) @@ -874,7 +874,7 @@ show_menu() { check_install && cron_jobs ;; *) - LOGE "请输入正确的数字 [0-16]" + LOGE "请输入正确的数字 [0-17],查看面板登录信息请输入数字7" ;; esac } diff --git a/x-ui_en.sh b/x-ui_en.sh index b220e32df7..5848646dc0 100644 --- a/x-ui_en.sh +++ b/x-ui_en.sh @@ -512,8 +512,8 @@ ssl_cert_issue_standalone() { fi #install cert ~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \ - --cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \ - --fullchain-file /root/cert/fullchain.cer + --cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \ + --fullchain-file /root/cert/fullchain.cer if [ $? -ne 0 ]; then LOGE "install certs failed,exit" @@ -595,8 +595,8 @@ ssl_cert_issue_by_cloudflare() { LOGI "issue cert succeed,installing..." fi ~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \ - --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ - --fullchain-file /root/cert/fullchain.cer + --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ + --fullchain-file /root/cert/fullchain.cer if [ $? -ne 0 ]; then LOGE "install cert failed,exit" rm -rf ~/.acme.sh/${CF_Domain} @@ -664,7 +664,7 @@ show_menu() { ${green}16.${plain} issuse certs " show_status - echo && read -p "please input a legal number[0-16]: " num + echo && read -p "please input a legal number[0-16],input 7 for checking login info:" num case "${num}" in 0) @@ -719,7 +719,7 @@ show_menu() { ssl_cert_issue ;; *) - LOGE "please input a legal number[0-16]" + LOGE "please input a legal number[0-16],input 7 for checking login info" ;; esac }