Uninstallation

The wireguard-install script provides a straightforward way to completely remove the WireGuard installation and all associated configuration files.

How to Uninstall

  1. Run the installation script from the directory where you downloaded it:

    ./wireguard-install.sh

  2. When the management menu appears, select option 4:

    What do you want to do?
       1) Add a new user
       2) List all users
       3) Revoke existing user
       4) Uninstall WireGuard
       5) Exit
    Select an option [1-5]: 4

  3. The script will display a critical warning. You must confirm that you want to proceed with the removal.

    WARNING: This will uninstall WireGuard and remove all the configuration files!
    Please backup the /etc/wireguard directory if you want to keep your configuration files.
    
    Do you really want to remove WireGuard? [y/n]: y

What the Uninstaller Does

Upon confirmation, the script performs the following actions to clean the system:

  1. Stops and Disables the Service: It stops the active wg-quick@wg0 service and disables it to prevent it from starting on the next boot.

  2. Removes Packages: It uses the system's native package manager (apt, yum, dnf, pacman, apk) to remove the wireguard-tools and qrencode packages.

  3. Deletes Configuration Directory: It completely removes the /etc/wireguard directory, which contains the server configuration, keys, and the params file. This action is irreversible.

  4. Removes Sysctl Configuration: It deletes the /etc/sysctl.d/wg.conf file to disable IP forwarding on the next reboot.

  5. Reloads System Configuration: It runs sysctl --system to apply the removal of the IP forwarding rule immediately.

After these steps are completed, WireGuard will be fully removed from your system.