Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 122 lines (103 sloc) 3.7 KB
# 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