Files
Alte_Skripte/aktuelle_Scripte/de.ing.change_FileVault_password 2.sh
Andreas Vogel 306149a726 test
2026-02-16 15:28:29 +01:00

109 lines
4.8 KiB
Bash

#!/bin/bash
##########################################################################
# Shellscript : Ermöglich das ändern des FileVault-Kennwortes
# Autor : Andreas Vogel, nextenterprise gmbh, 31.10.2019
##########################################################################
## Variablen
# UUID=$(dscl . -list /Users GeneratedUID | awk '{print $2}' | sort -ug | tail -1)
user=$(stat -f '%u %Su' /dev/console | cut -d ' ' -f 2)
UUID=$(dscl . -read /Users/$user GeneratedUID | awk '{print $2}')
askPassphrase () {
osascript <<EOF - 2>/dev/null
tell application "SystemUIServer"
activate
text returned of (display dialog "$1" default answer "" with hidden answer)
end tell
EOF
}
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
jamf="/usr/local/bin/jamf"
## INGIcon
FileVaultIcon="/Library/Application Support/JAMF/ING/SmallFileVaultIcon.png"
ErrorIcon="/Library/Application Support/JAMF/ING/France_road_sign_A14.svg.png"
SuccessfulIcon="/Library/Application Support/JAMF/ING/ok-1976099_640.png"
######################################################################################################################################
## Messages
Message="Mit diesem Programm wird das Windows Passwort und das FileVault Passwort synchronisiert.
Nur fortfahren, wenn das Filevault Passwort nicht dem aktuellen Windows Passwort entspricht.
This program synchronizes the Windows password and the FileVault password.
Only proceed if the Filevault password does not match the current Windows password."
FailedPwMessage="Die Prüfung des Passworts ist fehlgeschlagen, bitte das neue Passwort erneut eingeben.
The verification of the password failed, please re-enter the new password."
FailedPwMessageAgain="Die Eingabe stimmt erneut nicht überein. Das Programm wird beendet.
The input does not match again. The program is ended."
FailedChange="Das Passwort konnte nicht geändert werden. Versuche es erneut. Falls das Problem weiterhin besteht, wende dich an dem Client_Service_Mac.
The password could not be changed. Try again. If the problem persists, contact the Client_Service_Mac."
SuccessfulChange="Das Passwort wurde erfolgreich geändert.
Your password has been changed successfully."
######################################################################################################################################
## Abfrage, ob der User das Passwort wirklich ändern möchte.
HELPER=$("$jamfHelper" -windowType utility -icon "$FileVaultIcon" -title "Change FileVault password" -description "$Message" -button1 "OK" -button2 "Cancel" -cancelButton "2" -defaultButton 2)
echo "Jamf Helper Exit Code: $HELPER"
## Wenn der User den zustimmt, wird das alte Passwort und das neue Passwort abgefragt.
if [ "$HELPER" == "0" ]
then
oldPassphrase=$(askPassphrase 'Bitte gebe das alte Passwort ein. Please enter the old password.') || exit
newPassphrase=$(askPassphrase 'Bitte gebe das aktuelle Windows-Passwort ein. Please enter the current Windows password.') || exit
newPassphrase2=$(askPassphrase 'Bitte gebe das aktuelle Windows-Passwort erneut ein. Please enter the current Windows password again.') || exit
## Prüfen ob das neue Passwort übereinstimmt.
if [[ $newPassphrase != $newPassphrase2 ]]
then
HELPER=$("$jamfHelper" -windowType utility -icon "$ErrorIcon" -title "Wrong Entry" -description "$FailedPwMessage" -button1 "OK" -defaultButton 1)
echo "Exit Code: Die Eingabe stimmte nicht überein"
newPassphrase=$(askPassphrase 'Bitte gebe das aktuelle Windows-Passwort ein. Please enter the current Windows password.') || exit
newPassphrase2=$(askPassphrase 'Bitte gebe das aktuelle Windows-Passwort erneut ein. Please enter the current Windows password again.') || exit
fi
## Erneute Prüfung. Ist die erneute Prüfung fehlerhaft, so wird das Tool beendet.
if [[ $newPassphrase != $newPassphrase2 ]]
then
HELPER=$("$jamfHelper" -windowType utility -icon "$ErrorIcon" -title "Renewed wrong entry" -description "$FailedPwMessageAgain" -button1 "OK" -defaultButton 1)
echo "Exit Code: Die Eingabe war erneut falsch."
exit 1
fi
## Wurde das Tool nicht beendet, so wird das Passwort geändert.
if diskutil apfs changePassphrase disk1s1 -user $UUID -oldPassphrase $oldPassphrase -newPassphrase $newPassphrase
then
printf HELPER=$("$jamfHelper" -windowType utility -icon "$SuccessfulIcon" -title "Successful Change" -description "$SuccessfulChange" -button1 "OK" -defaultButton 1)
echo "Exit Code: Passwort wurde erfolgreich geändert."
else
printf HELPER=$("$jamfHelper" -windowType utility -icon "$ErrorIcon" -title "Error" -description "$FailedChange" -button1 "OK" -defaultButton 1)
echo "Exit Code: Passwort konnte nicht geändert werden. Ist das alte Passwort richtig?"
fi
fi
exit 0