-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathstop-procs.sh
executable file
·58 lines (45 loc) · 1.43 KB
/
stop-procs.sh
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
#!/bin/bash
SCRIPT_NAME="stop-procs.sh"
SCRIPT_VERSION="20230220"
# Purpose: Stop processes that may interfer with monitor mode applications
# Usage: $ sudo ./stop-procs.sh
# check to ensure sudo was used to start the script
if [ "$(id -u)" -ne 0 ]; then
echo "You must run this script with superuser (root) privileges."
echo "Try: \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
# displays script name and version
echo
echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}"
# disable interfering processes
PROCESSES="wpa_action\|wpa_supplicant\|wpa_cli\|dhclient\|ifplugd\|dhcdbd\|dhcpcd\|udhcpc\|NetworkManager\|knetworkmanager\|avahi-autoipd\|avahi-daemon\|wlassistant\|wifibox\|net_applet\|wicd-daemon\|wicd-client\|iwd"
# shellcheck disable=SC2009
badProcs=$(ps -A -o pid=PID -o comm=Name | grep "${PROCESSES}\|PID")
# shellcheck disable=SC2009
for pid in $(ps -A -o pid= -o comm= | grep ${PROCESSES} | awk '{print $1}'); do
command kill -19 "${pid}"
# (-19 = STOP)
done
echo
echo ' The following processes have been stopped:'
echo
echo "${badProcs}"
echo
printf " Press 'Enter' when you are ready to restart the above processes."
read -r REPLY
case "$REPLY" in
[*]) ;;
esac
# enable interfering processes
# shellcheck disable=SC2009
for pid in $(ps -A -o pid= -o comm= | grep ${PROCESSES} | awk '{print $1}'); do
command kill -18 "${pid}"
# (-18 = CONT)
done
echo
echo ' The following processes have been restarted:'
echo
echo "${badProcs}"
echo
exit 0