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

80 lines
2.2 KiB
Bash

#!/bin/bash
##########################################################################
# Script : Change FW-PW
# Autor : Andreas Vogel
# Copyright : macenterprise gmbh, 2020
##########################################################################
unset setpassword_fv
unset rotatepassword_fv
unset adduser_fv
############################################# Jamf Hepler Messanger #############################################################
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
jamf="/usr/local/bin/jamf"
ErrorIcon="/Library/Application Support/JAMF/ING/France_road_sign_A14.svg.png"
Error="An unexpected error has occurred. The encryption does not work properly. Please contact Mac support."
MessageIcon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarCustomizeIcon.icns"
Message="The Filevault setting must be updated. Please enter your current Windows password in the next window."
############################################# Variablen #########################################################################
Status=$(fdesetup status | head -1 | cut -d ' ' -f 3)
user=$(stat -f '%u %Su' /dev/console | cut -d ' ' -f 2)
DecryptString() {
# Usage: ~$ DecryptString "Encrypted String" "Salt" "Passphrase"
echo "${1}" | /usr/bin/openssl enc -aes256 -d -a -A -S "${2}" -k "${3}"
}
adminName="$7"
adminPass=$(DecryptString "$4" "$5" "$6")
############################################# Funktion #########################################################################
enable_fv () {
expect <<EOF
spawn fdesetup enable
expect "Enter the user name:"
send "$adminName\r"
expect "Enter the password for user $user:"
send "$adminPass\r"
expect EOF
EOF
}
rotatepassword_fv () {
expect <<EOF
spawn fdesetup changerecovery -personal
expect "Enter the user name:"
send "$adminName\r"
expect "Enter the password for user $adminName:"
send "$adminPass\r"
expect EOF
EOF
}
adduser_fv () {
expect <<EOF
spawn fdesetup add -usertoadd $user
expect "Enter the primary user name:"
send $adminName\r
expect "Enter the password for the user $adminName:"
send $adminPass\r
expect "Enter the password for the added user $user:"
send $APASS\r
expect
EOF
}