mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
bash - Reset Web Base Path
This commit is contained in:
parent
3ef4ab423f
commit
f481ab993e
2 changed files with 73 additions and 38 deletions
|
@ -121,6 +121,12 @@ install_base() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gen_random_string() {
|
||||||
|
local length="$1"
|
||||||
|
local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w "$length" | head -n 1)
|
||||||
|
echo "$random_string"
|
||||||
|
}
|
||||||
|
|
||||||
# This function will be called when user installed x-ui out of security
|
# This function will be called when user installed x-ui out of security
|
||||||
config_after_install() {
|
config_after_install() {
|
||||||
echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}"
|
echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}"
|
||||||
|
@ -146,7 +152,7 @@ config_after_install() {
|
||||||
if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then
|
if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then
|
||||||
local usernameTemp=$(head -c 6 /dev/urandom | base64)
|
local usernameTemp=$(head -c 6 /dev/urandom | base64)
|
||||||
local passwordTemp=$(head -c 6 /dev/urandom | base64)
|
local passwordTemp=$(head -c 6 /dev/urandom | base64)
|
||||||
local webBasePathTemp=$(head -c 6 /dev/urandom | base64)
|
local webBasePathTemp=$(gen_random_string 10)
|
||||||
/usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} -webBasePath ${webBasePathTemp}
|
/usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} -webBasePath ${webBasePathTemp}
|
||||||
echo -e "This is a fresh installation, will generate random login info for security concerns:"
|
echo -e "This is a fresh installation, will generate random login info for security concerns:"
|
||||||
echo -e "###############################################"
|
echo -e "###############################################"
|
||||||
|
|
103
x-ui.sh
103
x-ui.sh
|
@ -228,6 +228,31 @@ reset_user() {
|
||||||
confirm_restart
|
confirm_restart
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gen_random_string() {
|
||||||
|
local length="$1"
|
||||||
|
local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w "$length" | head -n 1)
|
||||||
|
echo "$random_string"
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_webbasepath() {
|
||||||
|
echo -e "${yellow}Resetting Web Base Path${plain}"
|
||||||
|
|
||||||
|
# Prompt user to set a new web base path
|
||||||
|
read -rp "Please set the new web base path [default is a random path]: " config_webBasePath
|
||||||
|
|
||||||
|
# If user input is empty, generate a random path
|
||||||
|
if [[ -z $config_webBasePath ]]; then
|
||||||
|
config_webBasePath=$(gen_random_string 10)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Apply the new web base path setting
|
||||||
|
/usr/local/x-ui/x-ui setting -webBasePath "${config_webBasePath}" >/dev/null 2>&1
|
||||||
|
|
||||||
|
# Display confirmation message
|
||||||
|
echo -e "Web base path has been reset to: ${green} ${config_webBasePath} ${plain}"
|
||||||
|
echo -e "${green} Please use the new web base path to access the panel. ${plain}"
|
||||||
|
}
|
||||||
|
|
||||||
reset_config() {
|
reset_config() {
|
||||||
confirm "Are you sure you want to reset all panel settings, Account data will not be lost, Username and password will not change" "n"
|
confirm "Are you sure you want to reset all panel settings, Account data will not be lost, Username and password will not change" "n"
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
|
@ -1282,31 +1307,32 @@ show_menu() {
|
||||||
${green}4.${plain} Uninstall
|
${green}4.${plain} Uninstall
|
||||||
————————————————
|
————————————————
|
||||||
${green}5.${plain} Reset Username & Password & Secret Token
|
${green}5.${plain} Reset Username & Password & Secret Token
|
||||||
${green}6.${plain} Reset Settings
|
${green}6.${plain} Reset Web Base Path
|
||||||
${green}7.${plain} Change Port
|
${green}7.${plain} Reset Settings
|
||||||
${green}8.${plain} View Current Settings
|
${green}8.${plain} Change Port
|
||||||
|
${green}9.${plain} View Current Settings
|
||||||
————————————————
|
————————————————
|
||||||
${green}9.${plain} Start
|
${green}10.${plain} Start
|
||||||
${green}10.${plain} Stop
|
${green}11.${plain} Stop
|
||||||
${green}11.${plain} Restart
|
${green}12.${plain} Restart
|
||||||
${green}12.${plain} Check Status
|
${green}13.${plain} Check Status
|
||||||
${green}13.${plain} Check Logs
|
${green}14.${plain} Check Logs
|
||||||
————————————————
|
————————————————
|
||||||
${green}14.${plain} Enable Autostart
|
${green}15.${plain} Enable Autostart
|
||||||
${green}15.${plain} Disable Autostart
|
${green}16.${plain} Disable Autostart
|
||||||
————————————————
|
————————————————
|
||||||
${green}16.${plain} SSL Certificate Management
|
${green}17.${plain} SSL Certificate Management
|
||||||
${green}17.${plain} Cloudflare SSL Certificate
|
${green}18.${plain} Cloudflare SSL Certificate
|
||||||
${green}18.${plain} IP Limit Management
|
${green}19.${plain} IP Limit Management
|
||||||
${green}19.${plain} WARP Management
|
${green}20.${plain} WARP Management
|
||||||
${green}20.${plain} Firewall Management
|
${green}21.${plain} Firewall Management
|
||||||
————————————————
|
————————————————
|
||||||
${green}21.${plain} Enable BBR
|
${green}22.${plain} Enable BBR
|
||||||
${green}22.${plain} Update Geo Files
|
${green}23.${plain} Update Geo Files
|
||||||
${green}23.${plain} Speedtest by Ookla
|
${green}24.${plain} Speedtest by Ookla
|
||||||
"
|
"
|
||||||
show_status
|
show_status
|
||||||
echo && read -p "Please enter your selection [0-23]: " num
|
echo && read -p "Please enter your selection [0-24]: " num
|
||||||
|
|
||||||
case "${num}" in
|
case "${num}" in
|
||||||
0)
|
0)
|
||||||
|
@ -1328,61 +1354,64 @@ show_menu() {
|
||||||
check_install && reset_user
|
check_install && reset_user
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
check_install && reset_config
|
check_install && reset_webbasepath
|
||||||
;;
|
;;
|
||||||
7)
|
7)
|
||||||
check_install && set_port
|
check_install && reset_config
|
||||||
;;
|
;;
|
||||||
8)
|
8)
|
||||||
check_install && check_config
|
check_install && set_port
|
||||||
;;
|
;;
|
||||||
9)
|
9)
|
||||||
check_install && start
|
check_install && check_config
|
||||||
;;
|
;;
|
||||||
10)
|
10)
|
||||||
check_install && stop
|
check_install && start
|
||||||
;;
|
;;
|
||||||
11)
|
11)
|
||||||
check_install && restart
|
check_install && stop
|
||||||
;;
|
;;
|
||||||
12)
|
12)
|
||||||
check_install && status
|
check_install && restart
|
||||||
;;
|
;;
|
||||||
13)
|
13)
|
||||||
check_install && show_log
|
check_install && status
|
||||||
;;
|
;;
|
||||||
14)
|
14)
|
||||||
check_install && enable
|
check_install && show_log
|
||||||
;;
|
;;
|
||||||
15)
|
15)
|
||||||
check_install && disable
|
check_install && enable
|
||||||
;;
|
;;
|
||||||
16)
|
16)
|
||||||
ssl_cert_issue_main
|
check_install && disable
|
||||||
;;
|
;;
|
||||||
17)
|
17)
|
||||||
ssl_cert_issue_CF
|
ssl_cert_issue_main
|
||||||
;;
|
;;
|
||||||
18)
|
18)
|
||||||
iplimit_main
|
ssl_cert_issue_CF
|
||||||
;;
|
;;
|
||||||
19)
|
19)
|
||||||
warp_cloudflare
|
iplimit_main
|
||||||
;;
|
;;
|
||||||
20)
|
20)
|
||||||
firewall_menu
|
warp_cloudflare
|
||||||
;;
|
;;
|
||||||
21)
|
21)
|
||||||
bbr_menu
|
firewall_menu
|
||||||
;;
|
;;
|
||||||
22)
|
22)
|
||||||
update_geo
|
bbr_menu
|
||||||
;;
|
;;
|
||||||
23)
|
23)
|
||||||
|
update_geo
|
||||||
|
;;
|
||||||
|
24)
|
||||||
run_speedtest
|
run_speedtest
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
LOGE "Please enter the correct number [0-23]"
|
LOGE "Please enter the correct number [0-24]"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue