-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall_launchdaemon.sh
More file actions
executable file
·95 lines (82 loc) · 3.06 KB
/
uninstall_launchdaemon.sh
File metadata and controls
executable file
·95 lines (82 loc) · 3.06 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
#!/bin/bash
# Uninstallation script for DiskEncrypter LaunchDaemon
# Run with: sudo bash uninstall_launchdaemon.sh
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration
PLIST_NAME="com.custom.diskencrypter.volumewatcher.plist"
INSTALL_DIR="/Library/Application Support/Custom"
LAUNCHDAEMON_DIR="/Library/LaunchDaemons"
LOG_DIR="/var/log"
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}DiskEncrypter LaunchDaemon Uninstaller${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}ERROR: This script must be run as root${NC}"
echo "Usage: sudo bash uninstall_launchdaemon.sh"
exit 1
fi
# Unload daemon
echo -e "${YELLOW}Step 1/4: Unloading LaunchDaemon...${NC}"
if launchctl list | grep -q "com.custom.diskencrypter.volumewatcher"; then
launchctl unload "$LAUNCHDAEMON_DIR/$PLIST_NAME" 2>/dev/null || true
sleep 1
echo -e "${GREEN}✓ LaunchDaemon unloaded${NC}"
else
echo -e "${YELLOW}⚠ LaunchDaemon was not loaded${NC}"
fi
echo ""
# Remove plist
echo -e "${YELLOW}Step 2/4: Removing LaunchDaemon plist...${NC}"
if [[ -f "$LAUNCHDAEMON_DIR/$PLIST_NAME" ]]; then
rm "$LAUNCHDAEMON_DIR/$PLIST_NAME"
echo -e "${GREEN}✓ Removed $PLIST_NAME${NC}"
else
echo -e "${YELLOW}⚠ Plist not found${NC}"
fi
echo ""
# Remove script
echo -e "${YELLOW}Step 3/4: Removing script...${NC}"
if [[ -f "$INSTALL_DIR/DiskEncrypter_Enhanced.sh" ]]; then
rm "$INSTALL_DIR/DiskEncrypter_Enhanced.sh"
echo -e "${GREEN}✓ Removed DiskEncrypter_Enhanced.sh${NC}"
else
echo -e "${YELLOW}⚠ Script not found${NC}"
fi
# Remove directory if empty
if [[ -d "$INSTALL_DIR" ]] && [[ -z "$(ls -A "$INSTALL_DIR")" ]]; then
rmdir "$INSTALL_DIR"
echo -e "${GREEN}✓ Removed empty directory $INSTALL_DIR${NC}"
fi
echo ""
# Archive logs
echo -e "${YELLOW}Step 4/4: Handling log files...${NC}"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
if [[ -f "$LOG_DIR/diskencrypter.log" ]] || [[ -f "$LOG_DIR/diskencrypter_error.log" ]]; then
echo "Archiving log files to ~/diskencrypter_logs_$TIMESTAMP/"
mkdir -p ~/diskencrypter_logs_$TIMESTAMP
[[ -f "$LOG_DIR/diskencrypter.log" ]] && mv "$LOG_DIR/diskencrypter.log" ~/diskencrypter_logs_$TIMESTAMP/
[[ -f "$LOG_DIR/diskencrypter_error.log" ]] && mv "$LOG_DIR/diskencrypter_error.log" ~/diskencrypter_logs_$TIMESTAMP/
echo -e "${GREEN}✓ Logs archived to ~/diskencrypter_logs_$TIMESTAMP/${NC}"
else
echo -e "${YELLOW}⚠ No log files found${NC}"
fi
echo ""
# Verify removal
echo -e "${YELLOW}Verifying uninstallation...${NC}"
if launchctl list | grep -q "com.custom.diskencrypter.volumewatcher"; then
echo -e "${RED}✗ LaunchDaemon still loaded (this shouldn't happen)${NC}"
else
echo -e "${GREEN}✓ LaunchDaemon successfully removed${NC}"
fi
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Uninstallation Complete!${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""