forked from webzfs/webzfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall_linux.sh
More file actions
98 lines (82 loc) · 2.71 KB
/
uninstall_linux.sh
File metadata and controls
98 lines (82 loc) · 2.71 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# WebZFS Uninstallation Script for Linux
# This script removes WebZFS from /opt/webzfs
set -e
INSTALL_DIR="/opt/webzfs"
DATA_DIR="${INSTALL_DIR}/.config/webzfs"
WEBZFS_USER="webzfs"
SYSTEMD_SERVICE="/etc/systemd/system/webzfs.service"
SUDOERS_FILE="/etc/sudoers.d/webzfs"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo "========================================"
echo "WebZFS Uninstallation Script for Linux"
echo "========================================"
echo
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Error: This script must be run as root${NC}"
echo "Please run: sudo $0"
exit 1
fi
echo -e "${YELLOW}Warning: This will completely remove WebZFS and all its data!${NC}"
echo -e "${YELLOW}Make sure to backup any important data before proceeding.${NC}"
echo
read -p "Are you sure you want to uninstall WebZFS? (yes/no): " -r
if [[ ! $REPLY =~ ^[Yy][Ee][Ss]$ ]]; then
echo "Uninstallation cancelled."
exit 0
fi
echo
# Stop and disable the service
if systemctl is-active --quiet webzfs 2>/dev/null; then
echo "Stopping WebZFS service..."
systemctl stop webzfs
echo -e "${GREEN}✓${NC} Service stopped"
fi
if systemctl is-enabled --quiet webzfs 2>/dev/null; then
echo "Disabling WebZFS service..."
systemctl disable webzfs
echo -e "${GREEN}✓${NC} Service disabled"
fi
# Remove systemd service file
if [ -f "$SYSTEMD_SERVICE" ]; then
echo "Removing systemd service file..."
rm -f "$SYSTEMD_SERVICE"
systemctl daemon-reload
echo -e "${GREEN}✓${NC} Systemd service file removed"
fi
# Remove sudoers file
if [ -f "$SUDOERS_FILE" ]; then
echo "Removing sudoers configuration..."
rm -f "$SUDOERS_FILE"
echo -e "${GREEN}✓${NC} Sudoers configuration removed"
fi
# Remove user and group
if id "$WEBZFS_USER" >/dev/null 2>&1; then
echo "Removing WebZFS user and group..."
userdel -r "$WEBZFS_USER" 2>/dev/null || true
echo -e "${GREEN}✓${NC} User and group removed"
fi
# Remove installation directory
if [ -d "$INSTALL_DIR" ]; then
echo "Removing installation directory: $INSTALL_DIR"
rm -rf "$INSTALL_DIR"
echo -e "${GREEN}✓${NC} Installation directory removed"
fi
# Remove data directory (if it exists separately)
if [ -d "$DATA_DIR" ]; then
echo "Removing data directory: $DATA_DIR"
rm -rf "$DATA_DIR"
echo -e "${GREEN}✓${NC} Data directory removed"
fi
echo
echo -e "${GREEN}✓ WebZFS has been successfully uninstalled!${NC}"
echo
echo "Note: If you had any custom configurations or data that you want to keep,"
echo "you should have backed them up before running this uninstaller."
echo
echo "To reinstall WebZFS, run the install_linux.sh script."