-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkext_script.sh
More file actions
45 lines (36 loc) · 963 Bytes
/
kext_script.sh
File metadata and controls
45 lines (36 loc) · 963 Bytes
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
#!/bin/bash
# Check if running with root privileges
if [[ $EUID -ne 0 ]]; then
echo "Please run this script as root."
exit 1
fi
# Check if enough arguments are provided
if [[ $# -lt 2 ]]; then
echo "Usage: sudo ./kext_script.sh <load|unload> <kext_path>"
exit 1
fi
# Set the action (load/unload)
action="$1"
# Set the kext path
kext_path="$2"
# Check if the specified kext exists
if [[ ! -d "$kext_path" ]]; then
echo "Invalid kext path. Please provide the correct path to the kext."
exit 1
fi
# Set the correct ownership and permissions for the kext
chown -R root:wheel "$kext_path"
chmod -R 755 "$kext_path"
# Perform the specified action (load/unload)
if [[ "$action" == "load" ]]; then
# Load the kext
kextload "$kext_path"
exit $?
elif [[ "$action" == "unload" ]]; then
# Unload the kext
kextunload "$kext_path"
exit $?
else
echo "Invalid action. Please specify 'load' or 'unload'."
exit 1
fi