blob: 1d9b8cc9e40e20b73be3afc17e1baeb038684281 (
plain) (
blame)
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
|
#!/bin/bash
# force_unload.sh - Force unload the stealth_launcher module when it's stuck
# Usage: sudo ./force_unload.sh
# Check if user is root
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
# Check if the module is loaded
if ! lsmod | grep -q "stealth_launcher"; then
echo "The stealth_launcher module is not loaded"
exit 0
fi
# Try normal rmmod first
echo "Attempting normal module removal..."
rmmod stealth_launcher 2>/dev/null
# Check if it worked
if ! lsmod | grep -q "stealth_launcher"; then
echo "Module successfully unloaded"
exit 0
fi
# Make sure the module parameters directory exists
if [ ! -d "/sys/module/stealth_launcher/parameters" ]; then
echo "Module parameters directory not found. Trying force removal..."
rmmod -f stealth_launcher
if ! lsmod | grep -q "stealth_launcher"; then
echo "Module successfully unloaded using rmmod -f"
exit 0
else
echo "Failed to unload module even with force. You may need to reboot."
exit 1
fi
fi
# Try method 1: Use the force_unload parameter
echo "Module is busy. Attempting force unload via parameter..."
echo 1 > /sys/module/stealth_launcher/parameters/force_unload 2>/dev/null
# Wait a moment
sleep 2
# Try rmmod again
rmmod stealth_launcher 2>/dev/null
# Check if it worked
if ! lsmod | grep -q "stealth_launcher"; then
echo "Module successfully unloaded"
exit 0
fi
# Try method 2: Kill any processes that might be keeping module busy
echo "Module still busy. Trying to terminate related processes..."
ps aux | grep -e "sleep" -e "bash" | grep -v grep | awk '{print $2}' | xargs -r kill -9 2>/dev/null
# Wait a moment
sleep 1
# Try rmmod again
rmmod stealth_launcher 2>/dev/null
# Check if it worked
if ! lsmod | grep -q "stealth_launcher"; then
echo "Module successfully unloaded after killing processes"
exit 0
fi
# Method 3: Force removal as last resort
echo "Attempting force removal as last resort..."
rmmod -f stealth_launcher 2>/dev/null
# Check if it worked
if ! lsmod | grep -q "stealth_launcher"; then
echo "Module successfully unloaded using rmmod -f"
exit 0
else
echo "Failed to unload module. You may need to reboot."
echo "Before rebooting, try these commands manually:"
echo " sudo kill -9 \$(lsof -t /dev/stealth_launcher 2>/dev/null)"
echo " sudo rmmod -f stealth_launcher"
exit 1
fi
|