aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomshell <randshell@protonmail.com>2020-11-14 00:47:36 +0000
committerGitHub <noreply@github.com>2020-11-14 01:47:36 +0100
commita1b1ac2ececa50d35a6ddd078a86dd6f28003fb3 (patch)
tree8f5f94a55b4c5855caec8ab41b081e7596a7c43b
parente2755467172abfd42c2f45c3415782db3082caf9 (diff)
Add confirmation before removing WireGuard (#156)
-rw-r--r--wireguard-install.sh73
1 files changed, 40 insertions, 33 deletions
diff --git a/wireguard-install.sh b/wireguard-install.sh
index 77f4f3c..9e09caa 100644
--- a/wireguard-install.sh
+++ b/wireguard-install.sh
@@ -344,45 +344,52 @@ function revokeClient() {
}
function uninstallWg() {
- checkOS
-
- systemctl stop "wg-quick@${SERVER_WG_NIC}"
- systemctl disable "wg-quick@${SERVER_WG_NIC}"
-
- if [[ ${OS} == 'ubuntu' ]]; then
- apt-get autoremove --purge -y wireguard qrencode
- elif [[ ${OS} == 'debian' ]]; then
- apt-get autoremove --purge -y wireguard qrencode
- elif [[ ${OS} == 'fedora' ]]; then
- dnf remove -y wireguard-tools qrencode
- if [[ ${VERSION_ID} -lt 32 ]]; then
- dnf remove -y wireguard-dkms
- dnf copr disable -y jdoss/wireguard
+ echo ""
+ read -rp "Do you really want to remove WireGuard? [y/n]: " -e -i n REMOVE
+ if [[ $REMOVE == 'y' ]]; then
+ checkOS
+
+ systemctl stop "wg-quick@${SERVER_WG_NIC}"
+ systemctl disable "wg-quick@${SERVER_WG_NIC}"
+
+ if [[ ${OS} == 'ubuntu' ]]; then
+ apt-get autoremove --purge -y wireguard qrencode
+ elif [[ ${OS} == 'debian' ]]; then
+ apt-get autoremove --purge -y wireguard qrencode
+ elif [[ ${OS} == 'fedora' ]]; then
+ dnf remove -y wireguard-tools qrencode
+ if [[ ${VERSION_ID} -lt 32 ]]; then
+ dnf remove -y wireguard-dkms
+ dnf copr disable -y jdoss/wireguard
+ fi
+ dnf autoremove -y
+ elif [[ ${OS} == 'centos' ]]; then
+ yum -y remove kmod-wireguard wireguard-tools qrencode
+ yum -y autoremove
+ elif [[ ${OS} == 'arch' ]]; then
+ pacman -Rs --noconfirm wireguard-tools qrencode
fi
- dnf autoremove -y
- elif [[ ${OS} == 'centos' ]]; then
- yum -y remove kmod-wireguard wireguard-tools qrencode
- yum -y autoremove
- elif [[ ${OS} == 'arch' ]]; then
- pacman -Rs --noconfirm wireguard-tools qrencode
- fi
- rm -rf /etc/wireguard
- rm -f /etc/sysctl.d/wg.conf
+ rm -rf /etc/wireguard
+ rm -f /etc/sysctl.d/wg.conf
- # Reload sysctl
- sysctl --system
+ # Reload sysctl
+ sysctl --system
- # Check if WireGuard is running
- systemctl is-active --quiet "wg-quick@${SERVER_WG_NIC}"
- WG_RUNNING=$?
+ # Check if WireGuard is running
+ systemctl is-active --quiet "wg-quick@${SERVER_WG_NIC}"
+ WG_RUNNING=$?
- if [[ ${WG_RUNNING} -eq 0 ]]; then
- echo "WireGuard failed to uninstall properly."
- exit 1
+ if [[ ${WG_RUNNING} -eq 0 ]]; then
+ echo "WireGuard failed to uninstall properly."
+ exit 1
+ else
+ echo "WireGuard uninstalled successfully."
+ exit 0
+ fi
else
- echo "WireGuard uninstalled successfully."
- exit 0
+ echo ""
+ echo "Removal aborted!"
fi
}