Skip to content

Commit

Permalink
Final beta1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BigMacAdmin committed Sep 5, 2023
1 parent 25b0479 commit 8f76e8f
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 81 deletions.
76 changes: 44 additions & 32 deletions Baseline.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/zsh
set -x
#dryRun=1
#dryRun=true

# Written by Trevor Sysock of Second Son Consulting
# @BigMacAdmin on the MacAdmins Slack
Expand Down Expand Up @@ -34,6 +34,7 @@ BaselineScripts="$BaselineDir/Scripts"
BaselinePackages="$BaselineDir/Packages"
BaselineIcons="$BaselineDir/Icons"
BaselineLaunchDaemon="/Library/LaunchDaemons/com.secondsonconsulting.baseline.plist"
BaselineTempIconsDir="$(mktemp -d /var/tmp/baselineTmpIcons.XXXX)"
ScriptOutputLog="/var/log/Baseline-ScriptsOutput.log"

#Binaries
Expand Down Expand Up @@ -164,7 +165,8 @@ function cleanup_and_exit()
dialog_command "quit:"
rm_if_exists "$dialogCommandFile"
rm_if_exists "$dialogJsonFile"
if [ "$dryRun" != 1 ] && [ "$cleanupBaselineDirectory" = "true" ] ; then
rm_if_exists "$BaselineTempIconsDir"
if [ "$dryRun" != true ] && [ "$cleanupBaselineDirectory" = "true" ] ; then
rm_if_exists "$BaselineDir"
fi
exit "$1"
Expand Down Expand Up @@ -200,30 +202,31 @@ function cleanup_and_restart()
rm_if_exists "$dialogCommandFile"
# Delete dialog json file
rm_if_exists "$dialogJsonFile"
# Delete icons tmp directory
rm_if_exists "$BaselineTempIconsDir"

# Check if we are deleting the Baseline working directory and do it
if [ $cleanupBaselineDirectory = "true" ]; then
rm_if_exists "$BaselineDir"
fi


# Determine exit configuration
# If ForceRestart is set to false
if [ $forceRestart = "false" ]; then
if [ $cleanupBaselineDirectory = "true" ]; then
rm_if_exists "$BaselineDir"
fi
echo "Force Restart is set to false. Exiting"
exit "$1"
# If Force Log Out is set to true
elif [ $forceLogOut = "true" ]; then
# If Force Log Out is set to true, force restart is false, and dry run is off
elif [ $forceLogOut = "true" ] && [ "$dryRun" != true ]; then
echo "Force Log Out is set to true. Exiting"
osascript -e "tell application \"/System/Library/CoreServices/loginwindow.app\" to «event aevtrlgo»"
exit "$1"
# If the script is in DryRun mode
elif [ "$dryRun" = 1 ]; then
echo "this is where <shutdown -r now> would go"
elif [ "$dryRun" = true ]; then
echo "this is where <shutdown -r now> or logout would go"
exit "$1"
fi

# Check if we are deleting the Baseline working directory and do it
if [ $cleanupBaselineDirectory = "true" ]; then
rm_if_exists "$BaselineDir"
fi
# Shutting down
shutdown -r now
}
Expand Down Expand Up @@ -474,14 +477,20 @@ function build_dialog_array()
#Get the icon path if populated in the configuration profile
if $pBuddy -c "Print :$configKey:${index}:Icon" "$BaselineConfig" > /dev/null 2>&1; then
currentIconPath=$($pBuddy -c "Print :$configKey:${index}:Icon" "$BaselineConfig")
if [[ ${currentIconPath:0:4} == "http" ]]; then
# Check if Icon is remotely hosted URL
if [[ ${currentIconPath:0:4} == "http" ]]; then
report_message "Icon set to URL: $currentIconPath"
# Check if Icon is an SF Symbol
elif [[ ${currentIconPath:0:3} == 'SF=' ]]; then
report_message "Icon set to SF Symbol: $currentIconPath"
#Check of the given icon path exists on disk
elif [ -e "$currentIconPath" ]; then
report_message "Icon found: $currentIconPath"
elif [ -e "$BaselineIcons/$currentIconPath" ]; then
report_message "Icon found: $currentIconPath"
currentIconPath="$BaselineIcons/$currentIconPath"
cp "$BaselineIcons/$currentIconPath" "$BaselineTempIconsDir"/"$currentIconPath"
chmod 655 "$BaselineTempIconsDir"/"$currentIconPath"
currentIconPath="$BaselineTempIconsDir/$currentIconPath"
else
#If we can't find the local file, report and leave blank
report_message "ERROR: Icon key cannot be located: $currentIconPath"
Expand Down Expand Up @@ -840,6 +849,9 @@ function build_dialog_json_file()

# Set global read permissions for Json file
chmod 644 "$dialogJsonFile"

# Set global read permissions for Icon directory
chmod 655 "$BaselineTempIconsDir"
}

function build_dialog_list_options()
Expand Down Expand Up @@ -887,28 +899,28 @@ function check_restart_option()
function check_progress_options()
{
# Set variable for whether or not we'll display a progress bar. Defaults to 'false'
displayProgressBarSetting=$($pBuddy -c "Print :DisplayProgressBar" "$BaselineConfig")
showProgressBarSetting=$($pBuddy -c "Print :ProgressBar" "$BaselineConfig")

if [ $displayProgressBarSetting = "true" ]; then
displayProgressBar="true"
if [ $showProgressBarSetting = "true" ]; then
showProgressBar="true"
else
displayProgressBar="false"
showProgressBar="false"
fi

# Set variable for whether or not we'll display a progress bar label. Defaults to 'false'
displayProgressBarLabelSetting=$($pBuddy -c "Print :DisplayProgressBarLabel" "$BaselineConfig")
showProgressBarDisplayNameSetting=$($pBuddy -c "Print :ProgressBarDisplayNames" "$BaselineConfig")

if [ $displayProgressBarLabelSetting = "true" ]; then
displayProgressBarLabel="true"
if [ $showProgressBarDisplayNameSetting = "true" ]; then
progressBarDisplayNames="true"
else
displayProgressBarLabel="false"
progressBarDisplayNames="false"
fi
}

function increment_progress_bar()
{
# If we're not displaying the progress bar, skip
if [ "$displayProgressBar" != "true" ]; then
if [ "$showProgressBar" != "true" ]; then
return
fi

Expand All @@ -923,7 +935,7 @@ function increment_progress_bar()
function set_progressbar_text()
{
# If we're not displaying the progress bar, skip
if [ "$displayProgressBarLabel" != "true" ]; then
if [ "$progressBarDisplayNames" != "true" ]; then
return
fi

Expand All @@ -939,7 +951,7 @@ defaultInstallomatorOptions=(
NOTIFY=silent
)

if [ "$dryRun" = 1 ]; then
if [ "$dryRun" = true ]; then
defaultInstallomatorOptions+="DEBUG=2"
fi

Expand Down Expand Up @@ -1036,8 +1048,8 @@ progressBarValue=0
progressBarTotal=0

# Initiate bools
displayProgressBar="false"
displayProgressBarLabel="false"
showProgressBar="false"
progressBarDisplayNames="false"

##############################
# Process Initial Scripts #
Expand Down Expand Up @@ -1116,11 +1128,11 @@ configure_dialog_list_arguments "--width" 900
configure_dialog_list_arguments "--height" 550
configure_dialog_list_arguments "--quitkey" ']'

if [ "$displayProgressBar" = "true" ]; then
if [ "$showProgressBar" = "true" ]; then
configure_dialog_list_arguments "--progress"
fi

if [ "$displayProgressBarLabel" = "true" ]; then
if [ "$progressBarDisplayNames" = "true" ]; then
configure_dialog_list_arguments "--progresstext" ' '
fi

Expand Down Expand Up @@ -1257,7 +1269,7 @@ done
#########################

# Progress Bar will be pulsing until a value is set
if [ "$displayProgressBar" = "true" ]; then
if [ "$showProgressBar" = "true" ]; then
dialog_command "progress: 1"
fi

Expand All @@ -1276,7 +1288,7 @@ if [ -e "/Library/Application Support/Dialog/Dialog.png" ]; then
dialog_command "listitem: Finishing up: success"
fi

if [ "$dryRun" = 1 ]; then
if [ "$dryRun" = true ]; then
sleep 5
fi

Expand Down
Binary file modified Build/Icons/ExampleIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions ExampleConfigurationFiles/Baseline-ProductionExample.mobileconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,39 @@
<dict>
<key>DisplayName</key>
<string>Google Chrome</string>
<key>Icon</key>
<string>ExampleIcon.png</string>
<key>Label</key>
<string>googlechromepkg</string>
<key>Icon</key>
<string>https://parsefiles.back4app.com/JPaQcFfEEQ1ePBxbf6wvzkPMEqKYHhPYv8boI1Rc/917448ac15eced553143cd4336e0187c_c59GvntZQa.icns</string>
</dict>
<dict>
<key>DisplayName</key>
<string>Microsoft Office 365</string>
<key>Icon</key>
<string>SF=doc.circle,color=blue</string>
<key>Label</key>
<string>microsoftoffice365</string>
<key>Icon</key>
<string>https://parsefiles.back4app.com/JPaQcFfEEQ1ePBxbf6wvzkPMEqKYHhPYv8boI1Rc/5cbf1ee8fcedb624cd816f30dd96222b_8DoWCZH0jl.icns</string>
</dict>
<dict>
<key>DisplayName</key>
<string>Zoom</string>
<key>Icon</key>
<string>SF= video.circle,color=blue</string>
<key>Label</key>
<string>zoom</string>
<key>Icon</key>
<string>https://parsefiles.back4app.com/JPaQcFfEEQ1ePBxbf6wvzkPMEqKYHhPYv8boI1Rc/076b419ffe380738636cfe958119baf2_7WtgFVhbf0.icns</string>
</dict>
</array>
<key>Packages</key>
<array>
<dict>
<key>DisplayName</key>
<string>Mist v0.5</string>
<key>Icon</key>
<string>https://github.com/ninxsoft/Mist/blob/main/README%20Resources/App%20Icon.png?raw=true</string>
<key>PackagePath</key>
<string>https://github.com/ninxsoft/Mist/releases/download/v0.5/Mist.0.5.pkg</string>
<key>TeamID</key>
<string>7K3HVCLV7Z</string>
<key>Icon</key>
<string>https://github.com/ninxsoft/Mist/blob/main/README%20Resources/App%20Icon.png?raw=true</string>
</dict>
</array>
<key>PayloadDisplayName</key>
Expand All @@ -52,20 +52,20 @@
<key>PayloadType</key>
<string>com.secondsonconsulting.baseline</string>
<key>PayloadUUID</key>
<string>97DE51A6-850F-46AB-98A6-BD9A80F7AF36</string>
<string>75A6163E-E581-4E91-88B7-17927BF9667A</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>Scripts</key>
<array>
<dict>
<key>DisplayName</key>
<string>Enabling Location Services</string>
<key>Icon</key>
<string>/System/Library/PrivateFrameworks/AOSUI.framework/Versions/A/Resources/findmy.icns</string>
<key>MD5</key>
<string>c32364f1f3f7fc2410e265d82095feee</string>
<key>ScriptPath</key>
<string>https://raw.githubusercontent.com/acodega/macos/main/enable_location-services.sh</string>
<key>Icon</key>
<string>/System/Library/PrivateFrameworks/AOSUI.framework/Versions/A/Resources/findmy.icns</string>
</dict>
</array>
</dict>
Expand All @@ -83,7 +83,7 @@
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>B842AE0F-70AE-4C1C-8556-D28F10168D89</string>
<string>BEDFC054-5B20-430F-B388-A51C3B4D30AE</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
Expand Down

0 comments on commit 8f76e8f

Please sign in to comment.