-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle-tor-control.sh
More file actions
executable file
·38 lines (33 loc) · 1.01 KB
/
toggle-tor-control.sh
File metadata and controls
executable file
·38 lines (33 loc) · 1.01 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
#!/bin/bash
WIDTH=500
HEIGHT=400
check_status() {
systemctl is-active tor > /dev/null 2>&1
}
status_message() {
if check_status; then
echo "TOR service is currently: ACTIVE"
else
echo "TOR service is currently: INACTIVE"
fi
}
ACTION=$(zenity --width=$WIDTH --height=$HEIGHT --list --radiolist \
--title="TOR Service Control" \
--text="$(status_message)\n\nChoose an action:" \
--column "Select" --column "Action" \
TRUE "Enable TOR" FALSE "Disable TOR" FALSE "Exit")
case "$ACTION" in
"Enable TOR")
bash -c 'pkexec systemctl start tor' && \
zenity --info --width=$WIDTH --title="Success" --text="TOR service has been enabled!" || \
zenity --error --width=$WIDTH --title="Error" --text="Failed to start TOR."
;;
"Disable TOR")
bash -c 'pkexec systemctl stop tor' && \
zenity --info --width=$WIDTH --title="Success" --text="TOR service has been disabled!" || \
zenity --error --width=$WIDTH --title="Error" --text="Failed to stop TOR."
;;
*)
exit 0
;;
esac