Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ########################
- # written by freccia #
- # 22.06.2017 #
- ########################
- # Make sure only root can run our script
- if [ "$(id -u)" != "0" ]; then
- echo "This script must be run as root" 1>&2
- exit 1
- fi
- # Get username and user Home #
- # variante:
- #echo "I am `who | cut -f 1 -d ' '`"
- loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
- loggedInUserHome=`dscl . -read /Users/$loggedInUser | grep NFSHomeDirectory: | /usr/bin/awk '{print $2}'`
- # Enable FileVault at next login #
- shopt -s nocasematch
- fileVaultStatus="`fdesetup status`"
- numberOfSkips="0"
- if [[ $fileVaultStatus == "FileVault is Off." ]] || [[ $fileVaultStatus == "FileVault is Off."* ]] ; then
- echo $fileVaultStatus
- echo "Filevault will be enabled at next login."
- fdesetup enable -defer "$loggedInUserHome"/Desktop/fde_recovery.plist -forceatlogin $numberOfSkips –dontaskatlogout
- else
- echo $fileVaultStatus
- fi
- shopt -u nocasematch
- # Set Ask for password immediately #
- echo "Set Ask for password for user: "$loggedInUser"..."
- requirePassword="1" # Integer (1 = true, 0 = false)
- timeBeforeRequiringPassword="0" # Integer: Seconds
- rm -rf "$loggedInUserHome"/Library/Preferences/com.apple.screensaver.plist
- touch "$loggedInUserHome"/Library/Preferences/com.apple.screensaver.plist
- if [[ -n $requirePassword ]]; then
- /usr/libexec/PlistBuddy -c "Add :askForPassword integer $requirePassword" "$loggedInUserHome"/Library/Preferences/com.apple.screensaver.plist
- fi
- if [[ -n $timeBeforeRequiringPassword ]]; then
- /usr/libexec/PlistBuddy -c "Add :askForPasswordDelay integer $timeBeforeRequiringPassword" "$loggedInUserHome"/Library/Preferences/com.apple.screensaver.plist
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement