-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.sh
executable file
·55 lines (44 loc) · 1.37 KB
/
uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Variables
SERVICE_NAME="whispercpp.service"
SERVICE_USER="whispercpp"
SERVICE_GROUP="whispercpp"
APP_DIR="/opt/whispercpp"
# Stop and disable the systemd service
echo "Stopping and disabling systemd service..."
sudo systemctl stop "$SERVICE_NAME"
sudo systemctl disable "$SERVICE_NAME"
# Remove the systemd service file
if [ -f "/etc/systemd/system/$SERVICE_NAME" ]; then
echo "Removing systemd service file..."
sudo rm "/etc/systemd/system/$SERVICE_NAME"
fi
# Reload systemd daemon to apply changes
echo "Reloading systemd daemon..."
sudo systemctl daemon-reload
# Delete the user and group
if id -u "$SERVICE_USER" >/dev/null 2>&1; then
echo "Deleting user: $SERVICE_USER..."
sudo userdel "$SERVICE_USER"
fi
if getent group "$SERVICE_GROUP" >/dev/null 2>&1; then
echo "Deleting group: $SERVICE_GROUP..."
sudo groupdel "$SERVICE_GROUP"
fi
# Remove application directory
if [ -d "$APP_DIR" ]; then
echo "Removing application directory: $APP_DIR..."
sudo rm -rf "$APP_DIR"
fi
# Remove any logs and temporary files
LOG_DIR="$APP_DIR/logs"
TMP_AUDIO_DIR="$APP_DIR/tmp/audio"
if [ -d "$LOG_DIR" ]; then
echo "Removing log directory: $LOG_DIR..."
sudo rm -rf "$LOG_DIR"
fi
if [ -d "$TMP_AUDIO_DIR" ]; then
echo "Removing temporary audio directory: $TMP_AUDIO_DIR..."
sudo rm -rf "$TMP_AUDIO_DIR"
fi
echo "Uninstallation complete!"