Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

OS X shell script

$
0
0
hi all,

i have 2 user profiles (fred, fredmoo) with filevault 2 enabled.

i have the following bash:

## Get the logged in user's name
userName=$(/usr/bin/stat -f%Su /dev/console)


## This first user check sees if the logged in account is already authorized with FileVault 2

userCheck=`fdesetup list | awk -v usrN="$userName" -F, 'index($0, usrN) {print $1}'`
if [ "${userCheck}" != "${userName}" ]; then
echo "This user is not a FileVault 2 enabled user."
exit 3
fi

----------------
if i do echo userName, i get -----> fred

if i do echo userCheck, i get -----> fred fredmoo
------------------

the conditional statement above works well if there's only 1 profile. :b:

however since my mac has more than 1 user profiles, the statement will echo "This user is not a FileVault 2 enabled user." and exit.

userCheck has both profiles.

how do i modify the if statement to say if userName does NOT equal to the 1st userCheck or 2nd userCheck, then echo "This user is not a FileVault 2 enabled user." and exit?

i would appreciate any assistance. thanks so much!

Viewing all articles
Browse latest Browse all 16232

Trending Articles