Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit dc7eb47

Browse files
committed
初次安装时增加随机用户名与密码、端口的设定
1 parent b7f3a1d commit dc7eb47

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

install.sh

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
red='\033[0;31m'
44
green='\033[0;32m'
@@ -97,8 +97,22 @@ config_after_install() {
9797
echo -e "${yellow}面板端口设定完成${plain}"
9898
else
9999
echo -e "${red}已取消设定...${plain}"
100-
echo -e "${red}如属于全新安装,默认网页端口为 ${green}54321${plain},用户名与密码均为 ${green}admin${plain},请及时修改"
101-
echo -e "${red}如属于版本升级,则保留之前设置项,登录方式保持不变,可输入x-ui后键入数字7查看登录信息${plain}"
100+
if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then
101+
local usernameTemp=$(head -c 6 /dev/urandom | base64)
102+
local passwordTemp=$(head -c 6 /dev/urandom | base64)
103+
local portTemp=$(echo $RANDOM)
104+
/usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp}
105+
/usr/local/x-ui/x-ui setting -port ${portTemp}
106+
echo -e "检测到您属于全新安装,出于安全考虑已自动为您生成随机用户与端口:"
107+
echo -e "###############################################"
108+
echo -e "${green}面板登录用户名:${usernameTemp}${plain}"
109+
echo -e "${green}面板登录用户密码:${passwordTemp}${plain}"
110+
echo -e "${red}面板登录端口:${portTemp}${plain}"
111+
echo -e "###############################################"
112+
echo -e "${red}如您遗忘了面板登录相关信息,可在安装完成后输入x-ui,输入选项7查看面板登录信息${plain}"
113+
else
114+
echo -e "${red}当前属于版本升级,保留之前设置项,登录方式保持不变,可输入x-ui后键入数字7查看面板登录信息${plain}"
115+
fi
102116
fi
103117
}
104118

install_en.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,22 @@ config_after_install() {
9797
echo -e "${yellow}panel port set down!${plain}"
9898
else
9999
echo -e "${red}cancel...${plain}"
100-
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"
101-
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}"
100+
if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then
101+
local usernameTemp=$(head -c 6 /dev/urandom | base64)
102+
local passwordTemp=$(head -c 6 /dev/urandom | base64)
103+
local portTemp=$(echo $RANDOM)
104+
/usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp}
105+
/usr/local/x-ui/x-ui setting -port ${portTemp}
106+
echo -e "this is a fresh installation,will generate random login info for security concerns:"
107+
echo -e "###############################################"
108+
echo -e "${green}user name:${usernameTemp}${plain}"
109+
echo -e "${green}user password:${passwordTemp}${plain}"
110+
echo -e "${red}web port:${portTemp}${plain}"
111+
echo -e "###############################################"
112+
echo -e "${red}if you forgot your login info,you can type x-ui and then type 7 to check after installation${plain}"
113+
else
114+
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}"
115+
fi
102116
fi
103117
}
104118

x-ui.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ ssl_cert_issue_standalone() {
519519
fi
520520
#install cert
521521
~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \
522-
--cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \
523-
--fullchain-file /root/cert/fullchain.cer
522+
--cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \
523+
--fullchain-file /root/cert/fullchain.cer
524524

525525
if [ $? -ne 0 ]; then
526526
LOGE "证书安装失败,脚本退出"
@@ -604,8 +604,8 @@ ssl_cert_issue_by_cloudflare() {
604604
LOGI "证书签发成功,安装中..."
605605
fi
606606
~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \
607-
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
608-
--fullchain-file /root/cert/fullchain.cer
607+
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
608+
--fullchain-file /root/cert/fullchain.cer
609609
if [ $? -ne 0 ]; then
610610
LOGE "证书安装失败,脚本退出"
611611
rm -rf ~/.acme.sh/${CF_Domain}
@@ -816,7 +816,7 @@ show_menu() {
816816
${green}17.${plain} 配置x-ui定时任务
817817
"
818818
show_status
819-
echo && read -p "请输入选择 [0-16]: " num
819+
echo && read -p "请输入选择 [0-17],查看面板登录信息请输入数字7:" num
820820

821821
case "${num}" in
822822
0)
@@ -874,7 +874,7 @@ show_menu() {
874874
check_install && cron_jobs
875875
;;
876876
*)
877-
LOGE "请输入正确的数字 [0-16]"
877+
LOGE "请输入正确的数字 [0-17],查看面板登录信息请输入数字7"
878878
;;
879879
esac
880880
}

x-ui_en.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ ssl_cert_issue_standalone() {
512512
fi
513513
#install cert
514514
~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \
515-
--cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \
516-
--fullchain-file /root/cert/fullchain.cer
515+
--cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \
516+
--fullchain-file /root/cert/fullchain.cer
517517

518518
if [ $? -ne 0 ]; then
519519
LOGE "install certs failed,exit"
@@ -595,8 +595,8 @@ ssl_cert_issue_by_cloudflare() {
595595
LOGI "issue cert succeed,installing..."
596596
fi
597597
~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \
598-
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
599-
--fullchain-file /root/cert/fullchain.cer
598+
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
599+
--fullchain-file /root/cert/fullchain.cer
600600
if [ $? -ne 0 ]; then
601601
LOGE "install cert failed,exit"
602602
rm -rf ~/.acme.sh/${CF_Domain}
@@ -664,7 +664,7 @@ show_menu() {
664664
${green}16.${plain} issuse certs
665665
"
666666
show_status
667-
echo && read -p "please input a legal number[0-16]: " num
667+
echo && read -p "please input a legal number[0-16],input 7 for checking login info:" num
668668

669669
case "${num}" in
670670
0)
@@ -719,7 +719,7 @@ show_menu() {
719719
ssl_cert_issue
720720
;;
721721
*)
722-
LOGE "please input a legal number[0-16]"
722+
LOGE "please input a legal number[0-16],input 7 for checking login info"
723723
;;
724724
esac
725725
}

0 commit comments

Comments
 (0)