-
Notifications
You must be signed in to change notification settings - Fork 4
/
LUKSUS.checks
executable file
·121 lines (103 loc) · 3.7 KB
/
LUKSUS.checks
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# CONDITIONAL CHECKING
# CHECKING IF RUNTIME ARGUMENTS ARE COOL
# Testing if the user has any options for LUKSUS. These should
# probably be ported to GETOPTS code, but it has to stay like this for
# now. Will fix later, maybe, one day.
if [ -z "$1" ]
then
GOGRAPHICAL=1
echo ""
fi
if [ -z "$2" ]
then
GOGRAPHICAL=1
echo ""
fi
# test to see if the user wants geli (FreeBSD)
if [[ "$3" = "geli" ]] || [[ "$4" = "geli" ]] || [[ "$5" = "geli" ]] || [[ "$6" = "geli" ]] || [[ "$7" = "geli" ]] || [[ "$8" = "geli" ]] || [[ "$9" = "geli" ]];
then
echo "Using GELI"
ENCRYPTION=GELI
if [ -z `which geli` ] ;then echo "Missing geli. Cannot continue. Please install geli" && exit; fi
else
echo ""
fi
# test to see if the user wants cgd (NetBSD)
if [[ "$3" = "cgd" ]] || [[ "$4" = "cgd" ]] || [[ "$5" = "cgd" ]] || [[ "$6" = "cgd" ]] || [[ "$7" = "cgd" ]] || [[ "$8" = "cgd" ]] || [[ "$9" = "cgd" ]];
then
echo "Using CGD"
ENCRYPTION=CGD
if [ -z `which cgdconfig` ] ;then echo "Missing cgdconfig. Cannot continue. Please install cgdconfig and cgd tools" && exit; fi
else
echo ""
fi
# Dialog checks
# Does the user explicitly not wish to see dialog? Those crazy purists!
if [[ "$3" = "nodialog" ]] || [[ "$4" = "nodialog" ]] || [[ "$5" = "nodialog" ]] || [[ "$6" = "nodialog" ]] || [[ "7" = "nodialog" ]] || [[ "$8" = "nodialog" ]] || [[ "$9" = "nodialog" ]];
then
dialog=false
echo Dialog disabled by user request
elif [ -z $(which dialog) ];
then
echo Dialog is not installed. Cannot continue.
dialog=false
exit 1
else
echo Dialog enabled
dialog=true
fi
# user wants to use a keyfile
if [[ "$3" = "usekey" ]] || [[ "$4" = "usekey" ]] || [[ "$5" = "usekey" ]] || [[ "$6" = "usekey" ]] || [[ "7" = "usekey" ]] || [[ "$3" = "keyfile" ]] || [[ "$4" = "keyfile" ]] || [[ "$5" = "keyfile" ]] || [[ "$6" = "keyfile" ]] || [[ "7" = "keyfile" ]] ;
then
echo "Using keyfile"
USEKEY=true
else
echo Using passphrase
USEKEY=false
fi
# WHIPTAIL SUPPORT IS TEMPORARILY REMOVED. IT REALLY IS LACKING A LOT
# OF DIALOG FEATURES.
## Dialog/Whiptail test - see which one to use
# check whether whiptail or dialog is installed
#read dialogapp <<< "$(which whiptail dialog 2> /dev/null)"
#
# exit if none found
#[[ "$dialogapp" ]] || {
# echo 'neither whiptail nor dialog found' >&2
# exit 1
#}
# just use whichever was found
# This is only cool for the dev himself # "$dialogapp" --msgbox "Message displayed with $dialogapp" 0 0
### HEAD OR GHEAD TEST
read HEADAPP <<< "$(which head ghead 2> /dev/null)"
[[ "$HEADAPP" ]] || {
echo 'neither head nor ghead found. Please install gnutools or coretools package' >&2
exit 1
}
### TAIL OR GTAIL TEST
read TAILAPP <<< "$(which tail gtail 2> /dev/null)"
[[ "$TAILAPP" ]] || {
echo 'neither tail nor gtail found. Please install gnutools or coretools package' >&2
exit 1
}
# user wants to force LUKS
if [[ "$3" = "luks" ]] || [[ "$4" = "luks" ]] || [[ "$5" = "luks" ]] || [[ "$6" = "luks" ]] || [[ "$7" = "luks" ]] || [[ "$8" = "luks" ]]
then
echo "LUKS encryption enabled"
ENCRYPTION=LUKS
if [ -z `which cryptsetup` ] ;then echo "Missing cryptsetup. Cannot continue. Please install cryptsetup" && exit; fi
else
echo ""
fi
# Sanity check
# Got root?
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo "Great! We are root"
echo "$programname is proceeding"
# Dependency check, could need a list and a for loop. recreate as a function and include a for loop
## Which unix system doesnt come with grep... This test is redundant. if [ -z `which grep` ] ;then echo "Missing grep" && exit; fi
if [ -z `which shred` ] ;then alias gshred=shred; fi
## This test is deprechated since times has changed and we are more refined now.if [ -z `which cryptsetup` ] ;then echo "Missing cryptsetup" && exit; fi