Update wireguard.sh

- refactor code
- breaking change
This commit is contained in:
tteckster 2024-08-21 16:10:49 -04:00 committed by GitHub
parent de1a4b0914
commit 9d579083bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,11 +19,11 @@ EOF
header_info header_info
echo -e "Loading..." echo -e "Loading..."
APP="Wireguard" APP="Wireguard"
var_disk="2" var_disk="4"
var_cpu="1" var_cpu="1"
var_ram="512" var_ram="512"
var_os="debian" var_os="debian"
var_version="11" var_version="12"
variables variables
color color
catch_errors catch_errors
@ -53,70 +53,9 @@ function default_settings() {
} }
function update_script() { function update_script() {
if [[ ! -d /etc/pivpn/wireguard ]]; then msg_error "No ${APP} Installation Found!"; exit; fi if [[ ! -d /etc/wireguard ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ msg_error "Update WireGuard via apt"
"1" "Update ${APP} LXC" ON \
"2" "Install WGDashboard" OFF \
3>&1 1>&2 2>&3)
header_info
if [ "$UPD" == "1" ]; then
msg_info "Updating ${APP} LXC"
apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null
msg_ok "Updated ${APP} LXC"
exit exit
fi
if [ "$UPD" == "2" ]; then
if [[ -f /etc/systemd/system/wg-dashboard.service ]]; then
cd /etc/wgdashboard/src
chmod u+x wgd.sh
./wgd.sh update
msg_ok "Updated Successfully"
exit
fi
IP=$(hostname -I | awk '{print $1}')
msg_info "Installing Python3-pip"
apt-get install -y python3-pip &>/dev/null
pip install flask &>/dev/null
pip install ifcfg &>/dev/null
pip install flask_qrcode &>/dev/null
pip install icmplib &>/dev/null
msg_ok "Installed Python3-pip"
msg_info "Installing WGDashboard"
WGDREL=$(curl -s https://api.github.com/repos/donaldzou/WGDashboard/releases/latest |
grep "tag_name" |
awk '{print substr($2, 2, length($2)-3) }')
git clone -b ${WGDREL} https://github.com/donaldzou/WGDashboard.git /etc/wgdashboard &>/dev/null
cd /etc/wgdashboard/src
chmod u+x wgd.sh
./wgd.sh install &>/dev/null
chmod -R 755 /etc/wireguard
msg_ok "Installed WGDashboard"
msg_info "Creating Service"
service_path="/etc/systemd/system/wg-dashboard.service"
echo "[Unit]
After=systemd-networkd.service
[Service]
WorkingDirectory=/etc/wgdashboard/src
ExecStart=/usr/bin/python3 /etc/wgdashboard/src/dashboard.py
Restart=always
[Install]
WantedBy=default.target" >$service_path
chmod 664 /etc/systemd/system/wg-dashboard.service
systemctl daemon-reload
systemctl enable wg-dashboard.service &>/dev/null
systemctl start wg-dashboard.service &>/dev/null
msg_ok "Created Service"
echo -e "WGDashboard should be reachable by going to the following URL.
${BL}http://${IP}:10086${CL} admin|admin \n"
exit
fi
} }
start start
@ -124,3 +63,5 @@ build_container
description description
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
echo -e "WGDashboard should be reachable by going to the following URL.
${BL}http://${IP}:10086${CL} admin|admin \n"