-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update extension attributes to support verifying account and LAPS exist
- Loading branch information
1 parent
79133aa
commit a906d5b
Showing
4 changed files
with
77 additions
and
44 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/zsh | ||
: ' | ||
--------------------------- | ||
| macOSLAPS EA Expiration | | ||
--------------------------- | ||
| Captures the Expiration from the file outputted | ||
| to the filesystem and sends the result to jamf | ||
| in the following format: | ||
| | Expiration: Expiration Date | | ||
------------------------------------------------------------ | ||
| Created: Richard Purves - https://github.com/franton | ||
| Last Update By: Joshua D. Miller - [email protected] | ||
| Last Update Date: January 29, 2023 | ||
------------------------------------------------------------ | ||
' | ||
### -------------------- ### | ||
### | Global Variables | ### | ||
### -------------------- ### | ||
## Path to macOSLAPS binary ## | ||
LAPS=/usr/local/laps/macOSLAPS | ||
## Path to Password File ## | ||
EXP_FILE="/var/root/Library/Application Support/macOSLAPS-expiration" | ||
## Local Admin Account ## | ||
LOCAL_ADMIN=$(/usr/bin/defaults read \ | ||
"/Library/Managed Preferences/edu.psu.macoslaps.plist" LocalAdminAccount) | ||
# ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # | ||
### ----------------------- ### | ||
### | Verify Requirements | ### | ||
### ----------------------- ### | ||
verify_requirements () { | ||
## Does the binary exist ## | ||
if [ ! -e $LAPS ] | ||
then | ||
/bin/echo "macOSLAPS Not Installed" | ||
return | ||
fi | ||
## Verify Local Admin Specified Exists ## | ||
if id "$1" &> /dev/null | ||
then | ||
/bin/echo "Yes" | ||
else | ||
/bin/echo "Account Not Found" | ||
fi | ||
return | ||
} | ||
# ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # | ||
### ----------------- ### | ||
### | Main Function | ### | ||
### ----------------- ### | ||
## Determine if macOSLAPS itself exits and the local admin account is present ## | ||
VERIFIED=$(verify_requirements "$LOCAL_ADMIN") | ||
## If we have verified LAPS and the Account ## | ||
if [[ "$VERIFIED" == "Yes" ]] | ||
then | ||
## Ask macOSLAPS to write out the current password and echo it for the Jamf EA | ||
$LAPS -getPassword > /dev/null | ||
CURRENT_EXPIRATION=$(/bin/cat "$EXP_FILE" 2&> /dev/null) | ||
## Test $CURRENT_EXPIRATION to ensure there is a value | ||
if [ -z "$CURRENT_EXPIRATION" ] | ||
then | ||
## Write no expiration date is present and send to | ||
## jamf Pro | ||
/bin/echo "<result>No Expiration Date Present</result>" | ||
else | ||
/bin/echo "<result>| Expiration: $CURRENT_EXPIRATION |</result>" | ||
## Run macOSLAPS a second time to remove the Expiration file | ||
## and expiration date file from the system | ||
$LAPS | ||
fi | ||
## Otherwise ## | ||
else | ||
echo "<result>$VERIFIED</result>" | ||
fi | ||
|
||
exit 0 |
2 changes: 1 addition & 1 deletion
2
jamf Extension Attributes/Password Only.sh → jamf Extension Attributes/Password Only.zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
#!/bin/zsh | ||
: ' | ||
------------------------- | ||
| macOSLAPS EA Password | | ||
|
2 changes: 1 addition & 1 deletion
2
...ttributes/Password:Expiration Combined.sh → ...tributes/Password:Expiration Combined.zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
#!/bin/zsh | ||
: ' | ||
------------------------- | ||
| macOSLAPS EA Combined | | ||
|