diff --git a/README.md b/README.md index 49cccd0..417acf5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ Run the installation script to install the application: curl -fsSL https://cdn.tiagorg.pt/gh-wh-handler/install.sh | sudo sh ``` +You can uninstall the application using the following command: + +```console +curl -fsSL https://cdn.tiagorg.pt/gh-wh-handler/uninstall.sh | sudo sh +``` + ### Run prebuilt binary Head over to the [Releases Page](https://github.com/TiagoRG/gh-wh-handler/releases) and download the desired binary. @@ -55,6 +61,11 @@ cmake .. sudo make install ``` +If you want to uninstall the application, you can run the following command: +```console +sudo make uninstall +``` + ## Usage The application is running on a systemd service, which is both enabled and started after installation. diff --git a/installer/uninstall.sh b/installer/uninstall.sh new file mode 100644 index 0000000..a8af099 --- /dev/null +++ b/installer/uninstall.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Check if the script is being run as root +if [ "$(id -u)" -ne 0 ]; then + echo "This script must be run as root." + exit 1 +fi + +# Save the current directory +CUR_DIR=$(pwd) + +# Get system architecture +ARCH=$(uname -m) + +echo "Uninstalling gh-wh-handler..." + +# Stop and disable the service +echo "Stopping and disabling service..." +systemctl stop gh-wh-handler +systemctl disable gh-wh-handler + +# Remove the service file +echo "Removing service file..." +rm /etc/systemd/system/gh-wh-handler.service + +# Reload systemd +echo "Reloading systemd..." +systemctl daemon-reload + +# Remove the symbolic link +echo "Removing symbolic link..." +rm /usr/bin/gh-wh-handler + +# Remove the logs directory and binary +echo "Removing files..." +rm -rf /services/gh-wh-handler/logs +rm -f /services/gh-wh-handler/gh-wh-handler.${ARCH} + +# Change back to the original directory +cd $CUR_DIR +echo "Uninstallation complete." +