x-ui.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  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}Runing${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}Runing${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. #install acme first
  406. install_acme
  407. if [ $? -ne 0 ]; then
  408. LOGE "install acme failed,please check logs"
  409. exit 1
  410. fi
  411. #install socat second
  412. if [[ x"${release}" == x"centos" ]]; then
  413. yum install socat -y
  414. else
  415. apt install socat -y
  416. fi
  417. if [ $? -ne 0 ]; then
  418. LOGE "install socat failed,please check logs"
  419. exit 1
  420. else
  421. LOGI "install socat succeed..."
  422. fi
  423. #creat a directory for install cert
  424. certPath=/root/cert
  425. if [ ! -d "$certPath" ]; then
  426. mkdir $certPath
  427. else
  428. rm -rf $certPath
  429. mkdir $certPath
  430. fi
  431. #get the domain here,and we need verify it
  432. local domain=""
  433. read -p "please input your domain:" domain
  434. LOGD "your domain is:${domain},check it..."
  435. #here we need to judge whether there exists cert already
  436. local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
  437. if [ ${currentCert} == ${domain} ]; then
  438. local certInfo=$(~/.acme.sh/acme.sh --list)
  439. LOGE "system already have certs here,can not issue again,current certs details:"
  440. LOGI "$certInfo"
  441. exit 1
  442. else
  443. LOGI "your domain is ready for issuing cert now..."
  444. fi
  445. #get needed port here
  446. local WebPort=80
  447. read -p "please choose which port do you use,default will be 80 port:" WebPort
  448. if [[ ${WebPort} -gt 65535 || ${WebPort} -lt 1 ]]; then
  449. LOGE "your input ${WebPort} is invalid,will use default port"
  450. fi
  451. LOGI "will use port:${WebPort} to issue certs,please make sure this port is open..."
  452. #NOTE:This should be handled by user
  453. #open the port and kill the occupied progress
  454. ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
  455. ~/.acme.sh/acme.sh --issue -d ${domain} --standalone --httpport ${WebPort}
  456. if [ $? -ne 0 ]; then
  457. LOGE "issue certs failed,please check logs"
  458. rm -rf ~/.acme.sh/${domain}
  459. exit 1
  460. else
  461. LOGE "issue certs succeed,installing certs..."
  462. fi
  463. #install cert
  464. ~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \
  465. --cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \
  466. --fullchain-file /root/cert/fullchain.cer
  467. if [ $? -ne 0 ]; then
  468. LOGE "install certs failed,exit"
  469. rm -rf ~/.acme.sh/${domain}
  470. exit 1
  471. else
  472. LOGI "install certs succeed,enable auto renew..."
  473. fi
  474. ~/.acme.sh/acme.sh --upgrade --auto-upgrade
  475. if [ $? -ne 0 ]; then
  476. LOGE "auto renew failed,certs details:"
  477. ls -lah cert
  478. chmod 755 $certPath
  479. exit 1
  480. else
  481. LOGI "auto renew succeed,certs details:"
  482. ls -lah cert
  483. chmod 755 $certPath
  484. fi
  485. }
  486. #method for DNS API mode
  487. ssl_cert_issue_by_cloudflare() {
  488. echo -E ""
  489. LOGD "******Preconditions******"
  490. LOGI "1.need Cloudflare account associated email"
  491. LOGI "2.need Cloudflare Global API Key"
  492. LOGI "3.your domain use Cloudflare as resolver"
  493. confirm "I have confirmed all these info above[y/n]" "y"
  494. if [ $? -eq 0 ]; then
  495. install_acme
  496. if [ $? -ne 0 ]; then
  497. LOGE "install acme failed,please check logs"
  498. exit 1
  499. fi
  500. CF_Domain=""
  501. CF_GlobalKey=""
  502. CF_AccountEmail=""
  503. certPath=/root/cert
  504. if [ ! -d "$certPath" ]; then
  505. mkdir $certPath
  506. else
  507. rm -rf $certPath
  508. mkdir $certPath
  509. fi
  510. LOGD "please input your domain:"
  511. read -p "Input your domain here:" CF_Domain
  512. LOGD "your domain is:${CF_Domain},check it..."
  513. #here we need to judge whether there exists cert already
  514. local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
  515. if [ ${currentCert} == ${CF_Domain} ]; then
  516. local certInfo=$(~/.acme.sh/acme.sh --list)
  517. LOGE "system already have certs here,can not issue again,current certs details:"
  518. LOGI "$certInfo"
  519. exit 1
  520. else
  521. LOGI "your domain is ready for issuing cert now..."
  522. fi
  523. LOGD "please inout your cloudflare global API key:"
  524. read -p "Input your key here:" CF_GlobalKey
  525. LOGD "your cloudflare global API key is:${CF_GlobalKey}"
  526. LOGD "please input your cloudflare account email:"
  527. read -p "Input your email here:" CF_AccountEmail
  528. LOGD "your cloudflare account email:${CF_AccountEmail}"
  529. ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
  530. if [ $? -ne 0 ]; then
  531. LOGE "change the default CA to Lets'Encrypt failed,exit"
  532. exit 1
  533. fi
  534. export CF_Key="${CF_GlobalKey}"
  535. export CF_Email=${CF_AccountEmail}
  536. ~/.acme.sh/acme.sh --issue --dns dns_cf -d ${CF_Domain} -d *.${CF_Domain} --log
  537. if [ $? -ne 0 ]; then
  538. LOGE "issue cert failed,exit"
  539. rm -rf ~/.acme.sh/${CF_Domain}
  540. exit 1
  541. else
  542. LOGI "Certificate issued Successfully, Installing..."
  543. fi
  544. ~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \
  545. --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
  546. --fullchain-file /root/cert/fullchain.cer
  547. if [ $? -ne 0 ]; then
  548. LOGE "install cert failed,exit"
  549. rm -rf ~/.acme.sh/${CF_Domain}
  550. exit 1
  551. else
  552. LOGI "Certificate installed Successfully,Turning on automatic updates..."
  553. fi
  554. ~/.acme.sh/acme.sh --upgrade --auto-upgrade
  555. if [ $? -ne 0 ]; then
  556. LOGE "Auto update setup Failed, script exiting..."
  557. ls -lah cert
  558. chmod 755 $certPath
  559. exit 1
  560. else
  561. LOGI "The certificate is installed and auto-renewal is turned on, Specific information is as follows"
  562. ls -lah cert
  563. chmod 755 $certPath
  564. fi
  565. else
  566. show_menu
  567. fi
  568. }
  569. show_usage() {
  570. echo "x-ui control menu usages: "
  571. echo "------------------------------------------"
  572. echo -e "x-ui - Enter control menu"
  573. echo -e "x-ui start - Start x-ui "
  574. echo -e "x-ui stop - Stop x-ui "
  575. echo -e "x-ui restart - Restart x-ui "
  576. echo -e "x-ui status - Show x-ui status"
  577. echo -e "x-ui enable - Enable x-ui on system startup"
  578. echo -e "x-ui disable - Disable x-ui on system startup"
  579. echo -e "x-ui log - Check x-ui logs"
  580. echo -e "x-ui update - Update x-ui "
  581. echo -e "x-ui install - Install x-ui "
  582. echo -e "x-ui uninstall - Uninstall x-ui "
  583. echo "------------------------------------------"
  584. }
  585. show_menu() {
  586. echo -e "
  587. ${green}3x-ui Panel Management Script${plain}
  588. ${green}0.${plain} Exit Script
  589. ————————————————
  590. ${green}1.${plain} Install x-ui
  591. ${green}2.${plain} Update x-ui
  592. ${green}3.${plain} Uninstall x-ui
  593. ————————————————
  594. ${green}4.${plain} Reset Username And Password
  595. ${green}5.${plain} Reset Panel Settings
  596. ${green}6.${plain} Change Panel Port
  597. ${green}7.${plain} View Current Panel Settings
  598. ————————————————
  599. ${green}8.${plain} Start x-ui
  600. ${green}9.${plain} Stop x-ui
  601. ${green}10.${plain} Restart x-ui
  602. ${green}11.${plain} Check x-ui Status
  603. ${green}12.${plain} Check x-ui Logs
  604. ————————————————
  605. ${green}13.${plain} Enable x-ui On Sysyem Startup
  606. ${green}14.${plain} Disabel x-ui On Sysyem Startup
  607. ————————————————
  608. ${green}15.${plain} Enable BBR
  609. ${green}16.${plain} Issuse Certs
  610. "
  611. show_status
  612. echo && read -p "Please enter your selection [0-16]: " num
  613. case "${num}" in
  614. 0)
  615. exit 0
  616. ;;
  617. 1)
  618. check_uninstall && install
  619. ;;
  620. 2)
  621. check_install && update
  622. ;;
  623. 3)
  624. check_install && uninstall
  625. ;;
  626. 4)
  627. check_install && reset_user
  628. ;;
  629. 5)
  630. check_install && reset_config
  631. ;;
  632. 6)
  633. check_install && set_port
  634. ;;
  635. 7)
  636. check_install && check_config
  637. ;;
  638. 8)
  639. check_install && start
  640. ;;
  641. 9)
  642. check_install && stop
  643. ;;
  644. 10)
  645. check_install && restart
  646. ;;
  647. 11)
  648. check_install && status
  649. ;;
  650. 12)
  651. check_install && show_log
  652. ;;
  653. 13)
  654. check_install && enable
  655. ;;
  656. 14)
  657. check_install && disable
  658. ;;
  659. 15)
  660. install_bbr
  661. ;;
  662. 16)
  663. ssl_cert_issue
  664. ;;
  665. *)
  666. LOGE "Please enter the correct number [0-16]"
  667. ;;
  668. esac
  669. }
  670. if [[ $# > 0 ]]; then
  671. case $1 in
  672. "start")
  673. check_install 0 && start 0
  674. ;;
  675. "stop")
  676. check_install 0 && stop 0
  677. ;;
  678. "restart")
  679. check_install 0 && restart 0
  680. ;;
  681. "status")
  682. check_install 0 && status 0
  683. ;;
  684. "enable")
  685. check_install 0 && enable 0
  686. ;;
  687. "disable")
  688. check_install 0 && disable 0
  689. ;;
  690. "log")
  691. check_install 0 && show_log 0
  692. ;;
  693. "update")
  694. check_install 0 && update 0
  695. ;;
  696. "install")
  697. check_uninstall 0 && install 0
  698. ;;
  699. "uninstall")
  700. check_install 0 && uninstall 0
  701. ;;
  702. *) show_usage ;;
  703. esac
  704. else
  705. show_menu
  706. fi