Files
2026-02-16 15:05:15 +01:00

54 lines
1.5 KiB
Bash

#!/bin/bash
##########################################################################
# Script : Change FW-PW
# Autor : Andreas Vogel
# Copyright : macenterprise gmbh, 2021
##########################################################################
unset setpassword_fv
unset rotatepassword_fv
############################################# Variablen #########################################################################
Status=$(fdesetup status | cut -d ' ' -f 3)
echo $Status
user=$(stat -f '%u %Su' /dev/console | cut -d ' ' -f 2)
APASS=$(osascript -e 'text returned of (display dialog "Enter the login password" with hidden answer default answer "" buttons {"OK"} default button 1)')
############################################# Funktion #########################################################################
setpassword_fv () {
expect <<EOF
spawn fdesetup enable
expect "Enter the user name:"
send "$user\r"
expect "Enter the password for user '$user':"
send "$APASS\r"
expect EOF
EOF
}
rotatepassword_fv () {
expect <<EOF
spawn fdesetup changerecovery -personal
expect "Enter the user name:"
send "$user\r"
expect "Enter the password for user '$user':"
send "$APASS\r"
expect EOF
EOF
}
############################################# Ausführung #############################################################################
if [ $Status == "Off." ]
then
echo "FileVault is disabled and will now be enabled"
setpassword_fv
jamf recon
else
echo "FileVault is active. The key is changed"
rotatepassword_fv
jamf recon
fi