mirror of
https://github.com/angristan/wireguard-install.git
synced 2024-11-22 04:35:09 +00:00
Add confirmation before removing WireGuard (#156)
This commit is contained in:
parent
e275546717
commit
a1b1ac2ece
@ -344,45 +344,52 @@ function revokeClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function uninstallWg() {
|
function uninstallWg() {
|
||||||
checkOS
|
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 stop "wg-quick@${SERVER_WG_NIC}"
|
||||||
systemctl disable "wg-quick@${SERVER_WG_NIC}"
|
systemctl disable "wg-quick@${SERVER_WG_NIC}"
|
||||||
|
|
||||||
if [[ ${OS} == 'ubuntu' ]]; then
|
if [[ ${OS} == 'ubuntu' ]]; then
|
||||||
apt-get autoremove --purge -y wireguard qrencode
|
apt-get autoremove --purge -y wireguard qrencode
|
||||||
elif [[ ${OS} == 'debian' ]]; then
|
elif [[ ${OS} == 'debian' ]]; then
|
||||||
apt-get autoremove --purge -y wireguard qrencode
|
apt-get autoremove --purge -y wireguard qrencode
|
||||||
elif [[ ${OS} == 'fedora' ]]; then
|
elif [[ ${OS} == 'fedora' ]]; then
|
||||||
dnf remove -y wireguard-tools qrencode
|
dnf remove -y wireguard-tools qrencode
|
||||||
if [[ ${VERSION_ID} -lt 32 ]]; then
|
if [[ ${VERSION_ID} -lt 32 ]]; then
|
||||||
dnf remove -y wireguard-dkms
|
dnf remove -y wireguard-dkms
|
||||||
dnf copr disable -y jdoss/wireguard
|
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
|
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 -rf /etc/wireguard
|
||||||
rm -f /etc/sysctl.d/wg.conf
|
rm -f /etc/sysctl.d/wg.conf
|
||||||
|
|
||||||
# Reload sysctl
|
# Reload sysctl
|
||||||
sysctl --system
|
sysctl --system
|
||||||
|
|
||||||
# Check if WireGuard is running
|
# Check if WireGuard is running
|
||||||
systemctl is-active --quiet "wg-quick@${SERVER_WG_NIC}"
|
systemctl is-active --quiet "wg-quick@${SERVER_WG_NIC}"
|
||||||
WG_RUNNING=$?
|
WG_RUNNING=$?
|
||||||
|
|
||||||
if [[ ${WG_RUNNING} -eq 0 ]]; then
|
if [[ ${WG_RUNNING} -eq 0 ]]; then
|
||||||
echo "WireGuard failed to uninstall properly."
|
echo "WireGuard failed to uninstall properly."
|
||||||
exit 1
|
exit 1
|
||||||
|
else
|
||||||
|
echo "WireGuard uninstalled successfully."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "WireGuard uninstalled successfully."
|
echo ""
|
||||||
exit 0
|
echo "Removal aborted!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user