Files
Alte_Skripte/Change_Recovery-Key_with_User.sh
2026-02-16 15:05:15 +01:00

48 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
##########################################################################
# Script : Change FW-PW
# Autor : Andreas Vogel
# Copyright : macenterprise gmbh, 2020
##########################################################################
############################################# Variablen #########################################################################
Status=$(fdesetup 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
setpassword_fv
# jamf recon
else
rotatepassword_fv
# jamf recon
fi