forked from Kintoyyy/MikroTik-LibreQos-Integration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
54 lines (44 loc) · 1.49 KB
/
Copy pathuninstall.sh
File metadata and controls
54 lines (44 loc) · 1.49 KB
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
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
LIBREQOS_DIR="/opt/libreqos"
SRC_DIR="$LIBREQOS_DIR/src"
PYTHON_SCRIPT="$SRC_DIR/updatecsv.py"
CONFIG_JSON="$SRC_DIR/config.json"
SERVICE_FILE="/etc/systemd/system/updatecsv.service"
DELETED_FILES=()
log_deleted_file() {
if [ -f "$1" ] || [ -d "$1" ]; then
rm -f "$1"
DELETED_FILES+=("$1")
fi
}
if [[ $EUID -ne 0 ]]; then
printf "${RED}✘ This script must be run as root. Use sudo.${NC}\n"
exit 1
fi
printf "${BLUE}➜ Stopping LibreQoS update service...${NC}\n"
systemctl stop updatecsv.service 2>/dev/null
systemctl disable updatecsv.service 2>/dev/null
log_deleted_file "$PYTHON_SCRIPT"
log_deleted_file "$CONFIG_JSON"
log_deleted_file "$CONFIG_JSON.bak"
log_deleted_file "$SERVICE_FILE"
if [ -d "$LIBREQOS_DIR/venv" ]; then
printf "${BLUE}➜ Removing Python dependencies...${NC}\n"
"$LIBREQOS_DIR/venv/bin/pip" freeze | xargs "$LIBREQOS_DIR/venv/bin/pip" uninstall -y
fi
if [ ${#DELETED_FILES[@]} -gt 0 ]; then
printf "\n${GREEN}✔ Deleted Files:${NC}\n"
for file in "${DELETED_FILES[@]}"; do
printf "${YELLOW} • $file${NC}\n"
done
printf "\n${GREEN}✔ Total files deleted: ${#DELETED_FILES[@]}${NC}\n"
else
printf "${YELLOW}➜ No files were deleted.${NC}\n"
fi
printf "${GREEN}✔ LibreQoS uninstallation process complete.${NC}\n"
printf "${BLUE}➜ Please adjust your ShapedDevice.csv and network.json to avoid sanity errors${NC}\n"