1
0

x-ui.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. #!/bin/bash
  2. red='\033[0;31m'
  3. green='\033[0;32m'
  4. yellow='\033[0;33m'
  5. plain='\033[0m'
  6. #Add some basic function here
  7. function LOGD() {
  8. echo -e "${yellow}[DEG] $* ${plain}"
  9. }
  10. function LOGE() {
  11. echo -e "${red}[ERR] $* ${plain}"
  12. }
  13. function LOGI() {
  14. echo -e "${green}[INF] $* ${plain}"
  15. }
  16. # check root
  17. [[ $EUID -ne 0 ]] && LOGE "ERROR: You must be root to run this script! \n" && exit 1
  18. # check os
  19. if [[ -f /etc/redhat-release ]]; then
  20. release="centos"
  21. elif cat /etc/issue | grep -Eqi "debian"; then
  22. release="debian"
  23. elif cat /etc/issue | grep -Eqi "ubuntu"; then
  24. release="ubuntu"
  25. elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
  26. release="centos"
  27. elif cat /proc/version | grep -Eqi "debian"; then
  28. release="debian"
  29. elif cat /proc/version | grep -Eqi "ubuntu"; then
  30. release="ubuntu"
  31. elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
  32. release="centos"
  33. else
  34. LOGE "check system OS failed,please contact with author! \n" && exit 1
  35. fi
  36. os_version=""
  37. # os version
  38. if [[ -f /etc/os-release ]]; then
  39. os_version=$(awk -F'[= ."]' '/VERSION_ID/{print $3}' /etc/os-release)
  40. fi
  41. if [[ -z "$os_version" && -f /etc/lsb-release ]]; then
  42. os_version=$(awk -F'[= ."]+' '/DISTRIB_RELEASE/{print $2}' /etc/lsb-release)
  43. fi
  44. if [[ x"${release}" == x"centos" ]]; then
  45. if [[ ${os_version} -le 6 ]]; then
  46. LOGE "please use CentOS 7 or higher version! \n" && exit 1
  47. fi
  48. elif [[ x"${release}" == x"ubuntu" ]]; then
  49. if [[ ${os_version} -lt 16 ]]; then
  50. LOGE "please use Ubuntu 16 or higher version!\n" && exit 1
  51. fi
  52. elif [[ x"${release}" == x"debian" ]]; then
  53. if [[ ${os_version} -lt 8 ]]; then
  54. LOGE "please use Debian 8 or higher version!\n" && exit 1
  55. fi
  56. fi
  57. confirm() {
  58. if [[ $# > 1 ]]; then
  59. echo && read -p "$1 [Default$2]: " temp
  60. if [[ x"${temp}" == x"" ]]; then
  61. temp=$2
  62. fi
  63. else
  64. read -p "$1 [y/n]: " temp
  65. fi
  66. if [[ x"${temp}" == x"y" || x"${temp}" == x"Y" ]]; then
  67. return 0
  68. else
  69. return 1
  70. fi
  71. }
  72. confirm_restart() {
  73. confirm "Restart the panel, Attention: Restarting the panel will also restart xray" "y"
  74. if [[ $? == 0 ]]; then
  75. restart
  76. else
  77. show_menu
  78. fi
  79. }
  80. before_show_menu() {
  81. echo && echo -n -e "${yellow}Press enter to return to the main menu: ${plain}" && read temp
  82. show_menu
  83. }
  84. install() {
  85. bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/main/install.sh)
  86. if [[ $? == 0 ]]; then
  87. if [[ $# == 0 ]]; then
  88. start
  89. else
  90. start 0
  91. fi
  92. fi
  93. }
  94. update() {
  95. confirm "This function will forcefully reinstall the latest version, and the data will not be lost. Do you want to continue?" "n"
  96. if [[ $? != 0 ]]; then
  97. LOGE "Cancelled"
  98. if [[ $# == 0 ]]; then
  99. before_show_menu
  100. fi
  101. return 0
  102. fi
  103. bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/main/install.sh)
  104. if [[ $? == 0 ]]; then
  105. LOGI "Update is complete, Panel has automatically restarted "
  106. exit 0
  107. fi
  108. }
  109. uninstall() {
  110. confirm "Are you sure you want to uninstall the panel? xray will also uninstalled!" "n"
  111. if [[ $? != 0 ]]; then
  112. if [[ $# == 0 ]]; then
  113. show_menu
  114. fi
  115. return 0
  116. fi
  117. systemctl stop x-ui
  118. systemctl disable x-ui
  119. rm /etc/systemd/system/x-ui.service -f
  120. systemctl daemon-reload
  121. systemctl reset-failed
  122. rm /etc/x-ui/ -rf
  123. rm /usr/local/x-ui/ -rf
  124. echo ""
  125. echo -e "Uninstalled Successfully,If you want to remove this script,then after exiting the script run ${green}rm /usr/bin/x-ui -f${plain} to delete it."
  126. echo ""
  127. if [[ $# == 0 ]]; then
  128. before_show_menu
  129. fi
  130. }
  131. reset_user() {
  132. confirm "Reset your username and password to admin?" "n"
  133. if [[ $? != 0 ]]; then
  134. if [[ $# == 0 ]]; then
  135. show_menu
  136. fi
  137. return 0
  138. fi
  139. /usr/local/x-ui/x-ui setting -username admin -password admin
  140. echo -e "Username and password have been reset to ${green}admin${plain},Please restart the panel now."
  141. confirm_restart
  142. }
  143. reset_config() {
  144. confirm "Are you sure you want to reset all panel settings,Account data will not be lost,Username and password will not change" "n"
  145. if [[ $? != 0 ]]; then
  146. if [[ $# == 0 ]]; then
  147. show_menu
  148. fi
  149. return 0
  150. fi
  151. /usr/local/x-ui/x-ui setting -reset
  152. echo -e "All panel settings have been reset to default,Please restart the panel now,and use the default ${green}2053${plain} Port to Access the web Panel"
  153. confirm_restart
  154. }
  155. check_config() {
  156. info=$(/usr/local/x-ui/x-ui setting -show true)
  157. if [[ $? != 0 ]]; then
  158. LOGE "get current settings error,please check logs"
  159. show_menu
  160. fi
  161. LOGI "${info}"
  162. }
  163. set_port() {
  164. echo && echo -n -e "Enter port number[1-65535]: " && read port
  165. if [[ -z "${port}" ]]; then
  166. LOGD "Cancelled"
  167. before_show_menu
  168. else
  169. /usr/local/x-ui/x-ui setting -port ${port}
  170. echo -e "The port is set,Please restart the panel now,and use the new port ${green}${port}${plain} to access web panel"
  171. confirm_restart
  172. fi
  173. }
  174. start() {
  175. check_status
  176. if [[ $? == 0 ]]; then
  177. echo ""
  178. LOGI "Panel is running,No need to start again,If you need to restart, please select restart"
  179. else
  180. systemctl start x-ui
  181. sleep 2
  182. check_status
  183. if [[ $? == 0 ]]; then
  184. LOGI "x-ui Started Successfully"
  185. else
  186. LOGE "panel Failed to start,Probably because it takes longer than two seconds to start,Please check the log information later"
  187. fi
  188. fi
  189. if [[ $# == 0 ]]; then
  190. before_show_menu
  191. fi
  192. }
  193. stop() {
  194. check_status
  195. if [[ $? == 1 ]]; then
  196. echo ""
  197. LOGI "Panel stopped,No need to stop again!"
  198. else
  199. systemctl stop x-ui
  200. sleep 2
  201. check_status
  202. if [[ $? == 1 ]]; then
  203. LOGI "x-ui and xray stopped successfully"
  204. else
  205. LOGE "Panel stop failed,Probably because the stop time exceeds two seconds,Please check the log information later"
  206. fi
  207. fi
  208. if [[ $# == 0 ]]; then
  209. before_show_menu
  210. fi
  211. }
  212. restart() {
  213. systemctl restart x-ui
  214. sleep 2
  215. check_status
  216. if [[ $? == 0 ]]; then
  217. LOGI "x-ui and xray Restarted successfully"
  218. else
  219. LOGE "Panel restart failed,Probably because it takes longer than two seconds to start,Please check the log information later"
  220. fi
  221. if [[ $# == 0 ]]; then
  222. before_show_menu
  223. fi
  224. }
  225. status() {
  226. systemctl status x-ui -l
  227. if [[ $# == 0 ]]; then
  228. before_show_menu
  229. fi
  230. }
  231. enable() {
  232. systemctl enable x-ui
  233. if [[ $? == 0 ]]; then
  234. LOGI "x-ui Set to boot automatically on startup successfully"
  235. else
  236. LOGE "x-ui Failed to set Autostart"
  237. fi
  238. if [[ $# == 0 ]]; then
  239. before_show_menu
  240. fi
  241. }
  242. disable() {
  243. systemctl disable x-ui
  244. if [[ $? == 0 ]]; then
  245. LOGI "x-ui Autostart Cancelled successfully"
  246. else
  247. LOGE "x-ui Failed to cancel autostart"
  248. fi
  249. if [[ $# == 0 ]]; then
  250. before_show_menu
  251. fi
  252. }
  253. show_log() {
  254. journalctl -u x-ui.service -e --no-pager -f
  255. if [[ $# == 0 ]]; then
  256. before_show_menu
  257. fi
  258. }
  259. migrate_v2_ui() {
  260. /usr/local/x-ui/x-ui v2-ui
  261. before_show_menu
  262. }
  263. install_bbr() {
  264. # temporary workaround for installing bbr
  265. bash <(curl -L -s https://raw.githubusercontent.com/teddysun/across/master/bbr.sh)
  266. echo ""
  267. before_show_menu
  268. }
  269. update_shell() {
  270. wget -O /usr/bin/x-ui -N --no-check-certificate https://github.com/mhsanaei/3x-ui/raw/main/x-ui.sh
  271. if [[ $? != 0 ]]; then
  272. echo ""
  273. LOGE "Failed to download script,Please check whether the machine can connect Github"
  274. before_show_menu
  275. else
  276. chmod +x /usr/bin/x-ui
  277. LOGI "Upgrade script succeeded,Please rerun the script" && exit 0
  278. fi
  279. }
  280. # 0: running, 1: not running, 2: not installed
  281. check_status() {
  282. if [[ ! -f /etc/systemd/system/x-ui.service ]]; then
  283. return 2
  284. fi
  285. temp=$(systemctl status x-ui | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1)
  286. if [[ x"${temp}" == x"running" ]]; then
  287. return 0
  288. else
  289. return 1
  290. fi
  291. }
  292. check_enabled() {
  293. temp=$(systemctl is-enabled x-ui)
  294. if [[ x"${temp}" == x"enabled" ]]; then
  295. return 0
  296. else
  297. return 1
  298. fi
  299. }
  300. check_uninstall() {
  301. check_status
  302. if [[ $? != 2 ]]; then
  303. echo ""
  304. LOGE "Panel installed,Please do not reinstall"
  305. if [[ $# == 0 ]]; then
  306. before_show_menu
  307. fi
  308. return 1
  309. else
  310. return 0
  311. fi
  312. }
  313. check_install() {
  314. check_status
  315. if [[ $? == 2 ]]; then
  316. echo ""
  317. LOGE "Please install the panel first"
  318. if [[ $# == 0 ]]; then
  319. before_show_menu
  320. fi
  321. return 1
  322. else
  323. return 0
  324. fi
  325. }
  326. show_status() {
  327. check_status
  328. case $? in
  329. 0)
  330. echo -e "Panel state: ${green}Running${plain}"
  331. show_enable_status
  332. ;;
  333. 1)
  334. echo -e "Panel state: ${yellow}Not Running${plain}"
  335. show_enable_status
  336. ;;
  337. 2)
  338. echo -e "Panel state: ${red}Not Installed${plain}"
  339. ;;
  340. esac
  341. show_xray_status
  342. }
  343. show_enable_status() {
  344. check_enabled
  345. if [[ $? == 0 ]]; then
  346. echo -e "Start automatically: ${green}Yes${plain}"
  347. else
  348. echo -e "Start automatically: ${red}No${plain}"
  349. fi
  350. }
  351. check_xray_status() {
  352. count=$(ps -ef | grep "xray-linux" | grep -v "grep" | wc -l)
  353. if [[ count -ne 0 ]]; then
  354. return 0
  355. else
  356. return 1
  357. fi
  358. }
  359. show_xray_status() {
  360. check_xray_status
  361. if [[ $? == 0 ]]; then
  362. echo -e "xray state: ${green}Running${plain}"
  363. else
  364. echo -e "xray state: ${red}Not Running${plain}"
  365. fi
  366. }
  367. #this will be an entrance for ssl cert issue
  368. #here we can provide two different methods to issue cert
  369. #first.standalone mode second.DNS API mode
  370. ssl_cert_issue() {
  371. local method=""
  372. echo -E ""
  373. LOGD "********Usage********"
  374. LOGI "this shell script will use acme to help issue certs."
  375. LOGI "here we provide two methods for issuing certs:"
  376. LOGI "method 1:acme standalone mode,need to keep port:80 open"
  377. LOGI "method 2:acme DNS API mode,need provide Cloudflare Global API Key"
  378. LOGI "recommend method 2 first,if it fails,you can try method 1."
  379. LOGI "certs will be installed in /root/cert directory"
  380. read -p "please choose which method do you want,type 1 or 2": method
  381. LOGI "you choosed method:${method}"
  382. if [ "${method}" == "1" ]; then
  383. ssl_cert_issue_standalone
  384. elif [ "${method}" == "2" ]; then
  385. ssl_cert_issue_by_cloudflare
  386. else
  387. LOGE "invalid input,please check it..."
  388. exit 1
  389. fi
  390. }
  391. install_acme() {
  392. cd ~
  393. LOGI "install acme..."
  394. curl https://get.acme.sh | sh
  395. if [ $? -ne 0 ]; then
  396. LOGE "install acme failed"
  397. return 1
  398. else
  399. LOGI "install acme succeed"
  400. fi
  401. return 0
  402. }
  403. #method for standalone mode
  404. ssl_cert_issue_standalone() {
  405. #check for acme.sh first
  406. if ! command -v ~/.acme.sh/acme.sh &>/dev/null; then
  407. echo "acme.sh could not be found. we will install it"
  408. install_acme
  409. if [ $? -ne 0 ]; then
  410. LOGE "install acme failed, please check logs"
  411. exit 1
  412. fi
  413. fi
  414. #install socat second
  415. if [[ x"${release}" == x"centos" ]]; then
  416. yum install socat -y
  417. else
  418. apt install socat -y
  419. fi
  420. if [ $? -ne 0 ]; then
  421. LOGE "install socat failed,please check logs"
  422. exit 1
  423. else
  424. LOGI "install socat succeed..."
  425. fi
  426. #creat a directory for install cert
  427. certPath=/root/cert
  428. if [ ! -d "$certPath" ]; then
  429. mkdir $certPath
  430. else
  431. rm -rf $certPath
  432. mkdir $certPath
  433. fi
  434. #get the domain here,and we need verify it
  435. local domain=""
  436. read -p "please input your domain:" domain
  437. LOGD "your domain is:${domain},check it..."
  438. #here we need to judge whether there exists cert already
  439. local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
  440. if [ ${currentCert} == ${domain} ]; then
  441. local certInfo=$(~/.acme.sh/acme.sh --list)
  442. LOGE "system already have certs here,can not issue again,current certs details:"
  443. LOGI "$certInfo"
  444. exit 1
  445. else
  446. LOGI "your domain is ready for issuing cert now..."
  447. fi
  448. #get needed port here
  449. local WebPort=80
  450. read -p "please choose which port do you use,default will be 80 port:" WebPort
  451. if [[ ${WebPort} -gt 65535 || ${WebPort} -lt 1 ]]; then
  452. LOGE "your input ${WebPort} is invalid,will use default port"
  453. fi
  454. LOGI "will use port:${WebPort} to issue certs,please make sure this port is open..."
  455. #NOTE:This should be handled by user
  456. #open the port and kill the occupied progress
  457. ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
  458. ~/.acme.sh/acme.sh --issue -d ${domain} --standalone --httpport ${WebPort}
  459. if [ $? -ne 0 ]; then
  460. LOGE "issue certs failed,please check logs"
  461. rm -rf ~/.acme.sh/${domain}
  462. exit 1
  463. else
  464. LOGE "issue certs succeed,installing certs..."
  465. fi
  466. #install cert
  467. ~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \
  468. --cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \
  469. --fullchain-file /root/cert/fullchain.cer
  470. if [ $? -ne 0 ]; then
  471. LOGE "install certs failed,exit"
  472. rm -rf ~/.acme.sh/${domain}
  473. exit 1
  474. else
  475. LOGI "install certs succeed,enable auto renew..."
  476. fi
  477. ~/.acme.sh/acme.sh --upgrade --auto-upgrade
  478. if [ $? -ne 0 ]; then
  479. LOGE "auto renew failed,certs details:"
  480. ls -lah cert
  481. chmod 755 $certPath
  482. exit 1
  483. else
  484. LOGI "auto renew succeed,certs details:"
  485. ls -lah cert
  486. chmod 755 $certPath
  487. fi
  488. }
  489. #method for DNS API mode
  490. ssl_cert_issue_by_cloudflare() {
  491. echo -E ""
  492. LOGD "******Preconditions******"
  493. LOGI "1.need Cloudflare account associated email"
  494. LOGI "2.need Cloudflare Global API Key"
  495. LOGI "3.your domain use Cloudflare as resolver"
  496. confirm "I have confirmed all these info above[y/n]" "y"
  497. if [ $? -eq 0 ]; then
  498. install_acme
  499. if [ $? -ne 0 ]; then
  500. LOGE "install acme failed,please check logs"
  501. exit 1
  502. fi
  503. CF_Domain=""
  504. CF_GlobalKey=""
  505. CF_AccountEmail=""
  506. certPath=/root/cert
  507. if [ ! -d "$certPath" ]; then
  508. mkdir $certPath
  509. else
  510. rm -rf $certPath
  511. mkdir $certPath
  512. fi
  513. LOGD "please input your domain:"
  514. read -p "Input your domain here:" CF_Domain
  515. LOGD "your domain is:${CF_Domain},check it..."
  516. #here we need to judge whether there exists cert already
  517. local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
  518. if [ ${currentCert} == ${CF_Domain} ]; then
  519. local certInfo=$(~/.acme.sh/acme.sh --list)
  520. LOGE "system already have certs here,can not issue again,current certs details:"
  521. LOGI "$certInfo"
  522. exit 1
  523. else
  524. LOGI "your domain is ready for issuing cert now..."
  525. fi
  526. LOGD "please inout your cloudflare global API key:"
  527. read -p "Input your key here:" CF_GlobalKey
  528. LOGD "your cloudflare global API key is:${CF_GlobalKey}"
  529. LOGD "please input your cloudflare account email:"
  530. read -p "Input your email here:" CF_AccountEmail
  531. LOGD "your cloudflare account email:${CF_AccountEmail}"
  532. ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
  533. if [ $? -ne 0 ]; then
  534. LOGE "change the default CA to Lets'Encrypt failed,exit"
  535. exit 1
  536. fi
  537. export CF_Key="${CF_GlobalKey}"
  538. export CF_Email=${CF_AccountEmail}
  539. ~/.acme.sh/acme.sh --issue --dns dns_cf -d ${CF_Domain} -d *.${CF_Domain} --log
  540. if [ $? -ne 0 ]; then
  541. LOGE "issue cert failed,exit"
  542. rm -rf ~/.acme.sh/${CF_Domain}
  543. exit 1
  544. else
  545. LOGI "Certificate issued Successfully, Installing..."
  546. fi
  547. ~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \
  548. --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
  549. --fullchain-file /root/cert/fullchain.cer
  550. if [ $? -ne 0 ]; then
  551. LOGE "install cert failed,exit"
  552. rm -rf ~/.acme.sh/${CF_Domain}
  553. exit 1
  554. else
  555. LOGI "Certificate installed Successfully,Turning on automatic updates..."
  556. fi
  557. ~/.acme.sh/acme.sh --upgrade --auto-upgrade
  558. if [ $? -ne 0 ]; then
  559. LOGE "Auto update setup Failed, script exiting..."
  560. ls -lah cert
  561. chmod 755 $certPath
  562. exit 1
  563. else
  564. LOGI "The certificate is installed and auto-renewal is turned on, Specific information is as follows"
  565. ls -lah cert
  566. chmod 755 $certPath
  567. fi
  568. else
  569. show_menu
  570. fi
  571. }
  572. show_usage() {
  573. echo "x-ui control menu usages: "
  574. echo "------------------------------------------"
  575. echo -e "x-ui - Enter control menu"
  576. echo -e "x-ui start - Start x-ui "
  577. echo -e "x-ui stop - Stop x-ui "
  578. echo -e "x-ui restart - Restart x-ui "
  579. echo -e "x-ui status - Show x-ui status"
  580. echo -e "x-ui enable - Enable x-ui on system startup"
  581. echo -e "x-ui disable - Disable x-ui on system startup"
  582. echo -e "x-ui log - Check x-ui logs"
  583. echo -e "x-ui update - Update x-ui "
  584. echo -e "x-ui install - Install x-ui "
  585. echo -e "x-ui uninstall - Uninstall x-ui "
  586. echo "------------------------------------------"
  587. }
  588. show_menu() {
  589. echo -e "
  590. ${green}3X-ui Panel Management Script${plain}
  591. ${green}0.${plain} Exit Script
  592. ————————————————
  593. ${green}1.${plain} Install x-ui
  594. ${green}2.${plain} Update x-ui
  595. ${green}3.${plain} Uninstall x-ui
  596. ————————————————
  597. ${green}4.${plain} Reset Username And Password
  598. ${green}5.${plain} Reset Panel Settings
  599. ${green}6.${plain} Change Panel Port
  600. ${green}7.${plain} View Current Panel Settings
  601. ————————————————
  602. ${green}8.${plain} Start x-ui
  603. ${green}9.${plain} Stop x-ui
  604. ${green}10.${plain} Restart x-ui
  605. ${green}11.${plain} Check x-ui Status
  606. ${green}12.${plain} Check x-ui Logs
  607. ————————————————
  608. ${green}13.${plain} Enable x-ui On Sysyem Startup
  609. ${green}14.${plain} Disabel x-ui On Sysyem Startup
  610. ————————————————
  611. ${green}15.${plain} Enable BBR
  612. ${green}16.${plain} Issuse Certs
  613. "
  614. show_status
  615. echo && read -p "Please enter your selection [0-16]: " num
  616. case "${num}" in
  617. 0)
  618. exit 0
  619. ;;
  620. 1)
  621. check_uninstall && install
  622. ;;
  623. 2)
  624. check_install && update
  625. ;;
  626. 3)
  627. check_install && uninstall
  628. ;;
  629. 4)
  630. check_install && reset_user
  631. ;;
  632. 5)
  633. check_install && reset_config
  634. ;;
  635. 6)
  636. check_install && set_port
  637. ;;
  638. 7)
  639. check_install && check_config
  640. ;;
  641. 8)
  642. check_install && start
  643. ;;
  644. 9)
  645. check_install && stop
  646. ;;
  647. 10)
  648. check_install && restart
  649. ;;
  650. 11)
  651. check_install && status
  652. ;;
  653. 12)
  654. check_install && show_log
  655. ;;
  656. 13)
  657. check_install && enable
  658. ;;
  659. 14)
  660. check_install && disable
  661. ;;
  662. 15)
  663. install_bbr
  664. ;;
  665. 16)
  666. ssl_cert_issue
  667. ;;
  668. *)
  669. LOGE "Please enter the correct number [0-16]"
  670. ;;
  671. esac
  672. }
  673. if [[ $# > 0 ]]; then
  674. case $1 in
  675. "start")
  676. check_install 0 && start 0
  677. ;;
  678. "stop")
  679. check_install 0 && stop 0
  680. ;;
  681. "restart")
  682. check_install 0 && restart 0
  683. ;;
  684. "status")
  685. check_install 0 && status 0
  686. ;;
  687. "enable")
  688. check_install 0 && enable 0
  689. ;;
  690. "disable")
  691. check_install 0 && disable 0
  692. ;;
  693. "log")
  694. check_install 0 && show_log 0
  695. ;;
  696. "update")
  697. check_install 0 && update 0
  698. ;;
  699. "install")
  700. check_uninstall 0 && install 0
  701. ;;
  702. "uninstall")
  703. check_install 0 && uninstall 0
  704. ;;
  705. *) show_usage ;;
  706. esac
  707. else
  708. show_menu
  709. fi