Enable Legacy Filevault on Mac OS X Yosemite

Don't know who this person is, but this still works in Yosemite.

I know full disk encryption is better, but I run Undercover. I assume that if someone steals my Mac, they will take other things, and finding the Mac, might help find other things that have been stolen. I create a non-admin account with no password for them to login with, and encrypt my real account.

if [ $UID != 0 ]; then
        echo "Run me as with sudo"
        exit 0
echo "enter a master recovery password:"
echo "enter username"
echo "enter size of sparsebundle (eg. 500g)"
read SIZE


security create-filevaultmaster-keychain -p $MASTER_PASSWORD /Library/Keychains/FileVaultMaster.keychain
#"security export" is broken! we need to do this manually
security unlock-keychain -p $MASTER_PASSWORD /Library/Keychains/FileVaultMaster.keychain
while [ ! -f /Library/Keychains/FileVaultMaster.cer ]
        read -p "Add /Library/Keychains/FileVaultMaster.keychain in KeyChainAccess.app and export the certificate to /Library/Keychains/FileVaultMaster.cer You will need to export to a user owned folder first. Press ENTER to continue."
chown 0:0 /Library/Keychains/FileVaultMaster.cer
chmod 600 /Library/Keychains/FileVaultMaster.cer
chmod 644 /Library/Keychains/FileVaultMaster.keychain

cd /Users/$USER_NAME
echo "Enter your user password."
hdiutil create -size $SIZE -encryption -agentpass -certificate /Library/Keychains/FileVaultMaster.cer -uid $SBUID -gid $SBGID -mode 0700 -fs "HFS+J" -type SPARSEBUNDLE -layout SPUD -volname "$USER_NAME" $USER_NAME.sparsebundle
chown -R $SBUID:$SBGID /Users/$USER_NAME/$USER_NAME.sparsebundle
du -h -d 1 /Users/$USER_NAME
df -h
read -p "Check that you have the size of the homefolder free on the disk. Press enter to continue."
mkdir sbdest
hdiutil attach -owners on -mountpoint sbdest $USER_NAME.sparsebundle
rsync -avxHEP ./ sbdest/ -exclude="$USER_NAME".sparsebundle/ -exclude="sbdest/"
hdiutil detach sbdest
rmdir sbdest
cd /private/var/db/dslocal/nodes/Default/users/
cp -i $USER_NAME.plist $USER_NAME.plist.bak
eval "defaults write /private/var/db/dslocal/nodes/Default/users/$USER_NAME.plist home_loc -array '\"<home_dir><url>file://localhost/Users/$USER_NAME/$USER_NAME.sparsebundle</url></home_dir>\"'"
echo "Remember to delete/move everything in /home/$USER_NAME except /home/$USER_NAME/$USER_NAME.sparsebundle or you will waste space besides keeping a clear text copy of your data on your HD"