-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirejail-switch
100 lines (82 loc) · 2.75 KB
/
firejail-switch
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
96
97
98
#!/bin/bash
#=============================================================================={
## Destiny: Developed for switch firejail in Linux
VERSION='2'
## Date: 2023.11.08 (Year.Month.Day)
## License: GNU GPL v.3 http://www.gnu.org/licenses/gpl-3.0.en.html
## Source: https://github.com/tele1/LinuxScripts
## Script usage: bash script_name
#==============================================================================}
# TUTORIALS:
# https://forums.linuxmint.com/viewtopic.php?f=42&t=240157
# https://sourceforge.net/p/yad-dialog/wiki/Examples/
# http://smokey01.com/yad/
# How Find Example GTK Icons:
# reset ; locate icons | grep -E 'actions.*gtk'
#==============================================================================={
# Check Dependecies - List created automatically by find.bash.dep.bash version=9
# source=https://github.com/tele1/LinuxScripts
[[ -z $(type -P echo) ]] && DEP="$DEP"$'\n'"echo"
[[ -z $(type -P firecfg) ]] && DEP="$DEP"$'\n'"firecfg"
[[ -z $(type -P ls) ]] && DEP="$DEP"$'\n'"ls"
[[ -z $(type -P pkexec) ]] && DEP="$DEP"$'\n'"pkexec"
[[ -z $(type -P true) ]] && DEP="$DEP"$'\n'"true"
[[ -z $(type -P yad) ]] && DEP="$DEP"$'\n'"yad"
# End script if exist any error
[ -z "$DEP" ] || { echo " Error: Missing dependencies, before run script please install: $DEP" ; exit 1 ;}
# Used Packages: firejail,pkexec,yad,
#==============================================================================={
WINDOW_INFO() {
yad --center --image=info --title "Info" --text="$1"
}
GET_STATUS() {
STATUS=$(ls -l /usr/local/bin/ | grep -q firejail ; echo "$?")
}
while true; do
GET_STATUS
if [[ 0 -eq "$STATUS" ]] ; then
TEXT_1=" Firejail is now Enabled"
else
TEXT_1=" Firejail is now Disabled"
fi
STATE=$(yad --center --width=450 --height=250 --title "Firejail Sanbox" \
--list --text "Menu" --radiolist \
--column "Choose" \
--column "Option" False "Disable Firejail" False "Enable Firejail" False "Check Status" \
--text=" \n $TEXT_1 \n " \
--button=gtk-quit:1 --button=gtk-ok:0 )
CODE="$?"
if [[ "$CODE" -eq 1 ]] ; then
echo "We go out with code 1." ; exit 0
elif [[ "$CODE" -eq 252 ]] ; then
echo "We go out with code 252." ; exit 0
else
echo "CODE = $CODE"
fi
while IFS="|" read -r THE_REST STATE ; do
echo $STATE ;
case "$STATE" in
"Disable Firejail")
echo 1
pkexec firecfg --clean
;;
"Enable Firejail")
echo 2
pkexec firecfg
;;
"Check Status")
echo 3
GET_STATUS
if [[ 0 -eq "$STATUS" ]] ; then
echo "STATUS = $STATUS"
echo "Firejail is Enabled"
WINDOW_INFO "Firejail is Enabled"
else
echo "STATUS = $STATUS"
echo "Firejail is Disabled"
WINDOW_INFO "Firejail is Disabled"
fi
;;
esac
done <<< $STATE
done