wireguard.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/usr/bin/env bash
  2. source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
  3. # Copyright (c) 2021-2023 tteck
  4. # Author: tteck (tteckster)
  5. # License: MIT
  6. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  7. function header_info {
  8. clear
  9. cat <<"EOF"
  10. _ ___ ______ __
  11. | | / (_)_______ / ____/_ ______ __________/ /
  12. | | /| / / / ___/ _ \/ / __/ / / / __ `/ ___/ __ /
  13. | |/ |/ / / / / __/ /_/ / /_/ / /_/ / / / /_/ /
  14. |__/|__/_/_/ \___/\____/\__,_/\__,_/_/ \__,_/
  15. EOF
  16. }
  17. header_info
  18. echo -e "Loading..."
  19. APP="Wireguard"
  20. var_disk="2"
  21. var_cpu="1"
  22. var_ram="512"
  23. var_os="debian"
  24. var_version="11"
  25. variables
  26. color
  27. catch_errors
  28. function default_settings() {
  29. CT_TYPE="1"
  30. PW=""
  31. CT_ID=$NEXTID
  32. HN=$NSAPP
  33. DISK_SIZE="$var_disk"
  34. CORE_COUNT="$var_cpu"
  35. RAM_SIZE="$var_ram"
  36. BRG="vmbr0"
  37. NET="dhcp"
  38. GATE=""
  39. DISABLEIP6="no"
  40. MTU=""
  41. SD=""
  42. NS=""
  43. MAC=""
  44. VLAN=""
  45. SSH="no"
  46. VERB="no"
  47. echo_default
  48. }
  49. function update_script() {
  50. if [[ ! -d /etc/pivpn/wireguard ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
  51. UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \
  52. "1" "Update ${APP} LXC" ON \
  53. "2" "Install WGDashboard" OFF \
  54. 3>&1 1>&2 2>&3)
  55. header_info
  56. if [ "$UPD" == "1" ]; then
  57. msg_info "Updating ${APP} LXC"
  58. apt-get update &>/dev/null
  59. apt-get -y upgrade &>/dev/null
  60. msg_ok "Updated Successfully"
  61. exit
  62. fi
  63. if [ "$UPD" == "2" ]; then
  64. if [[ -f /etc/systemd/system/wg-dashboard.service ]]; then
  65. msg_error "Existing WGDashboard Installation Found!";
  66. exit
  67. fi
  68. IP=$(hostname -I | awk '{print $1}')
  69. msg_info "Installing Python3-pip"
  70. apt-get install -y python3-pip &>/dev/null
  71. pip install flask &>/dev/null
  72. pip install ifcfg &>/dev/null
  73. pip install flask_qrcode &>/dev/null
  74. pip install icmplib &>/dev/null
  75. msg_ok "Installed Python3-pip"
  76. msg_info "Installing WGDashboard"
  77. WGDREL=$(curl -s https://api.github.com/repos/donaldzou/WGDashboard/releases/latest |
  78. grep "tag_name" |
  79. awk '{print substr($2, 2, length($2)-3) }')
  80. git clone -b ${WGDREL} https://github.com/donaldzou/WGDashboard.git /etc/wgdashboard &>/dev/null
  81. cd /etc/wgdashboard/src
  82. sudo chmod u+x wgd.sh
  83. sudo ./wgd.sh install &>/dev/null
  84. sudo chmod -R 755 /etc/wireguard
  85. msg_ok "Installed WGDashboard"
  86. msg_info "Creating Service"
  87. service_path="/etc/systemd/system/wg-dashboard.service"
  88. echo "[Unit]
  89. After=systemd-networkd.service
  90. [Service]
  91. WorkingDirectory=/etc/wgdashboard/src
  92. ExecStart=/usr/bin/python3 /etc/wgdashboard/src/dashboard.py
  93. Restart=always
  94. [Install]
  95. WantedBy=default.target" >$service_path
  96. chmod 664 /etc/systemd/system/wg-dashboard.service
  97. systemctl daemon-reload
  98. systemctl enable wg-dashboard.service &>/dev/null
  99. systemctl start wg-dashboard.service &>/dev/null
  100. msg_ok "Created Service"
  101. echo -e "WGDashboard should be reachable by going to the following URL.
  102. ${BL}http://${IP}:10086${CL} admin|admin \n"
  103. exit
  104. fi
  105. }
  106. start
  107. build_container
  108. description
  109. msg_ok "Completed Successfully!\n"