Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
初次安装时增加随机用户名与密码、端口的设定
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzKafkaYu committed Feb 14, 2023
1 parent b7f3a1d commit dc7eb47
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
20 changes: 17 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

red='\033[0;31m'
green='\033[0;32m'
Expand Down Expand Up @@ -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
}

Expand Down
18 changes: 16 additions & 2 deletions install_en.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 6 additions & 6 deletions x-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "证书安装失败,脚本退出"
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -874,7 +874,7 @@ show_menu() {
check_install && cron_jobs
;;
*)
LOGE "请输入正确的数字 [0-16]"
LOGE "请输入正确的数字 [0-17],查看面板登录信息请输入数字7"
;;
esac
}
Expand Down
12 changes: 6 additions & 6 deletions x-ui_en.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit dc7eb47

Please sign in to comment.