Add uninstaller

Signed-off-by: Tiago Garcia <tiago.rgarcia@ua.pt>
This commit is contained in:
Tiago Garcia 2024-07-19 15:54:12 +01:00
parent e22fa683e0
commit 52ea711718
Signed by: TiagoRG
GPG Key ID: DFCD48E3F420DB42
2 changed files with 53 additions and 0 deletions

View File

@ -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 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 ### Run prebuilt binary
Head over to the [Releases Page](https://github.com/TiagoRG/gh-wh-handler/releases) and download the desired 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 sudo make install
``` ```
If you want to uninstall the application, you can run the following command:
```console
sudo make uninstall
```
## Usage ## Usage
The application is running on a systemd service, which is both enabled and started after installation. The application is running on a systemd service, which is both enabled and started after installation.

42
installer/uninstall.sh Normal file
View File

@ -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."