Skip to content

Commit 9039ab5

Browse files
SwiftDialog PKG Sample added
1 parent c4d4cd9 commit 9039ab5

File tree

4 files changed

+257
-0
lines changed

4 files changed

+257
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
############################################################################################
4+
##
5+
## Post-install Script for Swift Dialog
6+
##
7+
## VER 1.0.0
8+
##
9+
############################################################################################
10+
11+
# Define any variables we need here:
12+
logDir="/Library/Application Support/Microsoft/IntuneScripts/Swift Dialog"
13+
14+
# Start Logging
15+
mkdir -p "$logDir"
16+
exec > >(tee -a "$logDir/postinstall.log") 2>&1
17+
18+
# Check if we've run before
19+
if [[ -f "$logDir/onboardingComplete" ]]; then
20+
echo "$(date) | POST | We've already completed onboarding, let's exit quietly"
21+
exit 1
22+
fi
23+
24+
# Check that SwiftDialog is installed
25+
if [[ ! -f "/usr/local/bin/dialog" ]]; then
26+
echo "$(date) | POST | Swift Dialog is not installed [/usr/local/bin/dialog]. Exiting"
27+
exit 0
28+
fi
29+
30+
# Wait for Desktop
31+
until ps aux | grep /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock | grep -v grep &>/dev/null; do
32+
echo "$(date) | + Dock not running, waiting [1] seconds"
33+
sleep 1
34+
done
35+
echo "$(date) | Dock is here, lets carry on"
36+
37+
# Run Swift Dialog
38+
/usr/local/bin/dialog --jsonfile "/Library/Application Support/SwiftDialogResources/swiftdialog.json" --width 1280 --height 670 --blurscreen --ontop &
39+
40+
# Wait for Swift Dialog to start
41+
START=$(date +%s) # Set the start time so we can calculate how long we've been waiting
42+
echo "$(date) | POST | Waiting for Swift Dialog to Start..."
43+
# Loop for 1 minutes (60 seconds)
44+
until ps aux | grep /usr/local/bin/dialog | grep -v grep &>/dev/null; do
45+
# Check if the 60 seconds have passed
46+
if [[ $(($(date +%s) - $START)) -ge 60 ]]; then
47+
echo "$(date) | POST | Failed: Swift Dialog did not start within 60 seconds"
48+
exit 1
49+
fi
50+
echo -n "."
51+
sleep 1
52+
done
53+
echo "OK"
54+
55+
echo "$(date) | POST | Processing scripts..."
56+
for script in /Library/Application\ Support/SwiftdialogResources/scripts/*.*; do
57+
echo "$(date) | POST | Executing [$script]"
58+
xattr -d com.apple.quarantine "$script" >/dev/null 2>&1
59+
chmod +x "$script" >/dev/null 2>&1
60+
nice -n 20 "$script"
61+
done
62+
63+
# Once we're done, we should write a flag file out so that we don't run again
64+
sudo touch "$logDir/onboardingComplete"
65+
exit 0
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
############################################################################################
4+
##
5+
## Pre-install Script for Swift Dialog
6+
##
7+
## VER 1.0.0
8+
##
9+
############################################################################################
10+
11+
# Define any variables we need here:
12+
logDir="/Library/Application Support/Microsoft/IntuneScripts/Swift Dialog"
13+
14+
# Start Logging
15+
mkdir -p "$logDir"
16+
exec > >(tee -a "$logDir/preinstall.log") 2>&1
17+
18+
if [ -e "/Library/Application Support/Dialog" ]; then
19+
echo "$(date) | PRE | Removing previous installation"
20+
rm -rf "/Library/Application Support/Dialog"
21+
rm -rf "/Library/Application Support/SwiftDialogResourcs"
22+
rm -rf "/usr/local/bin/dialog"
23+
fi
24+
25+
echo "$(date) | PRE | Completed Pre-install script"
26+
exit 0
Binary file not shown.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Deploying an Onboarding Splash Screen with Swift Dialog and Intune via custom PKG
2+
3+
## Overview
4+
5+
swiftDialog is an [open source](https://github.com/bartreardon/swiftDialog) admin utility app for macOS 11+ written in SwiftUI that displays a popup dialog, displaying content to your users.
6+
7+
swiftDialog's purpose is as a tool for Mac Admins to show informative messages via scripts, and relay back the users actions.
8+
9+
Source: [bartreardon/swiftDialog: Create user-notifications on macOS with swiftDialog (github.com)](https://github.com/bartreardon/swiftDialog)
10+
11+
![Example](https://github.com/microsoft/shell-intune-samples/blob/master/img/Swift%20Dialog/example1.png)
12+
13+
## Dependencies
14+
15+
In this example, we're going to use the Packages App to create a custom PKG that includes all of the resources we need for an oboarding package.
16+
17+
1. Install [Packages App](http://s.sudre.free.fr/Software/files/Packages.dmg) and grant it full disk access
18+
2. Download and expand SwiftDialog_IntunePKG.zip from this repo.
19+
20+
The ZIP file contains the following resources.
21+
22+
```
23+
|____Swift Dialog Onboarding
24+
| |____Swift Dialog Onboarding.pkgproj <-- This is the Packages project
25+
|____Payload
26+
| |____Application Support
27+
| | |____Dialog
28+
| | | |____Dialog.app
29+
| | |____SwiftDialogResources
30+
| | | |____swiftdialog.json <-- This is the SwiftDialog JSON
31+
| | | |____icons
32+
| | | | |____RemoteDesktop.png
33+
| | | | |____CompanyPortal.png
34+
| | | | |____Settings.png
35+
| | | | |____Edge.png
36+
| | | | |____vscode.png
37+
| | | | |____MicrosoftRemoteHelp.png
38+
| | | | |____office.png
39+
| | | | |____catlab.png
40+
| | | | |____GoogleChrome.png
41+
| | | | |____Defender.png
42+
| | | |____scripts <-- Any scripts in this folder will be executed by the post script
43+
| | | | |____01-installCompanyPortal.zsh
44+
| | | | |____02-installOffice365Pro.sh
45+
| | | | |____03-installEdge.sh
46+
| | | | |____04-installVSCode.zsh
47+
| | | | |____05-installRemoteDesktop.zsh
48+
| | | | |____06-installDefender.zsh
49+
| | | | |____99-setTZfromIP.sh
50+
| | | | |____99-DeviceRename.sh
51+
| | | | |____99-downloadWallpaper.sh
52+
| |____usr
53+
| | |____local
54+
| | | |____bin
55+
| | | | |____dialog
56+
```
57+
58+
# Getting Started
59+
60+
First we need to check that everything is working as it should, to do this, open the Swift Dialog Onboarding folder and double click on the Swift Dialog Onboarding Packages project. It should open in the Packages app.
61+
62+
Click on the Swift Dialog Package and select the Payload tab, check that none of the files are showing in red and there are no errors. Then press CMD+B to build our package. The most common reason for errors are files missing that are defined in the project and/or lack of permissions for the Packages app.
63+
64+
If succesful you will now have a package created under the Swift Dialog Onboarding/Build folder.
65+
66+
Your next step is to test that the package works by installing on a test machine and then you can run the following command.
67+
68+
```
69+
/usr/local/bin/dialog --jsonfile "/Library/Application Support/SwiftDialogResources/swiftdialog.json" --width 1280 --height 670 --blurscreen --ontop
70+
```
71+
72+
You should see the Swift Dialog UI displayed, but no scripts should execute. All Icons should display the right images.
73+
74+
# Customising
75+
76+
There are three areas to consider when customising the package
77+
78+
1. **swiftdialog.json**: This file contains the information that Dialog will use to create the display. Not everything needs to be included here, you can also specify most things on the command line if you need to. Refer to the excellent [SwiftDialog Wiki](https://github.com/swiftDialog/swiftDialog/wiki) for more information about customising this file.
79+
2. **Icons**: It's important that any icons you reference are available, they can either be included in the package or you can define web URLs.
80+
3. **Scripts**: Any scripts that you put in the scripts folder will be executed in alphanumeric order. Some samples are provided here, but remove what you don't need they are provide to show whats possible.
81+
82+
# Deploying via Intune
83+
84+
Once you have your customised PKG ready, you should test it first and then we can upload to Intune for deployment.
85+
86+
You can find out more detail about the unmanaged PKG deployment process in our [public documentation](https://learn.microsoft.com/en-us/mem/intune/apps/macos-unmanaged-pkg).
87+
88+
Follow these steps from the Intune console:
89+
90+
1. **Apps** > **macOS** > **Add** > **macOS app (PKG)** > **Select** > Select app package file > **OK**
91+
2. Edit App Information as required > **Next**
92+
3. Copy and paste Pre and Post install text from **IntuneScripts** folder (intunePre.sh / intunePost.sh) > **Next**
93+
4. Define minimum operating system version if you need to > **Next**
94+
5. Accept default detection rules > **Next**
95+
6. Assign to initial test group of users > **Next**
96+
7. **Create**
97+
8. Make a note of the appid, it's in the Intune Web URL after appid. We'll need this as we move into testing.
98+
https://intune.microsoft.com/#view/Microsoft_Intune_Apps/SettingsMenu/~/0/appId/**0b6e87b5-2e4b-4350-b551-bfb99d114c83**
99+
100+
101+
# Testing
102+
103+
Now we have everything uploaded to Intune, we need to test it. The quickest way to do that is to trigger the Intune Agent to re-check for updates.
104+
105+
Since this is the first time, it's a good idea to open the logs so that we can see what's going on
106+
107+
1. Open the Mac Console app > Log Reports > search for Intune > Select the latest IntuneMDMDaemon log
108+
2. Double click on the log file and type the appid from above into the search box (it shouldn't return anything yet)
109+
110+
Ok, so we can trigger the Intune agent to check-in and pick up our new PKG
111+
112+
```
113+
sudo pkill IntuneMdmDaemon
114+
```
115+
116+
If things go as expected, you should see the SwiftDialog UI appear and the scripts should start executing.
117+
118+
You should see something like this in your IntuneDaemon log
119+
120+
```
121+
2024-05-15 02:15:12:703 | IntuneMDM-Daemon | I | 11254 | SyncActivityTracer | Validating data Context: mac app policies, Count: 2, PolicyID: ["05088685-1fe8-4107-aaec-a41d4f934a14", "0b6e87b5-2e4b-4350-b551-bfb99d114c83"]
122+
2024-05-15 02:15:12:703 | IntuneMDM-Daemon | I | 11254 | SyncActivityTracer | Processing data Context: mac app policies, Count: 2, PolicyID: ["05088685-1fe8-4107-aaec-a41d4f934a14", "0b6e87b5-2e4b-4350-b551-bfb99d114c83"]
123+
2024-05-15 02:15:12:704 | IntuneMDM-Daemon | I | 11255 | AppPolicyHandler | Handling app policy. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, Primary BundleID: au.csiro.dialog, IgnoreVersion: true, Count: 1, AppType: PKG, App Policy Intent: RequiredInstall
124+
2024-05-15 02:15:12:704 | IntuneMDM-Daemon | I | 11255 | AppDetection | Detecting app with specific bundle ID. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, BundleID: au.csiro.dialog, IgnoreVersion: true
125+
2024-05-15 02:15:12:704 | IntuneMDM-Daemon | I | 11255 | ScriptOrchestrationLogger | Running system script. Domain: apps, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
126+
2024-05-15 02:15:12:735 | IntuneMDM-Daemon | I | 11255 | ScriptOrchestrationLogger | Finished system script. Domain: apps, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
127+
2024-05-15 02:15:12:735 | IntuneMDM-Daemon | I | 11255 | AppDetection | Did not find bundle path URL for app. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, BundleID: au.csiro.dialog, IgnoreVersion: true
128+
2024-05-15 02:15:12:735 | IntuneMDM-Daemon | I | 11255 | ScriptOrchestrationLogger | Running system script. Domain: apps, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
129+
2024-05-15 02:15:12:749 | IntuneMDM-Daemon | I | 11255 | ScriptOrchestrationLogger | Finished system script. Domain: apps, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
130+
2024-05-15 02:15:12:749 | IntuneMDM-Daemon | I | 11255 | PkgReceiptProvider | No app receipt found PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, BundleID: au.csiro.dialog
131+
2024-05-15 02:15:12:749 | IntuneMDM-Daemon | I | 11255 | AppDetection | App with specific bundle ID is NOT installed on the device. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, BundleID: au.csiro.dialog, IgnoreVersion: true
132+
2024-05-15 02:15:12:749 | IntuneMDM-Daemon | I | 11255 | AppInstallManager | App policy execution plan: Run pre-install script, Install PKG app Swift Dialog Onboarding, Run post-install script PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, AppType: PKG, BundleID: au.csiro.dialog
133+
2024-05-15 02:15:12:749 | IntuneMDM-Daemon | I | 11255 | AppInstallManager | Pre-install script detected. Executing script. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
134+
2024-05-15 02:15:12:749 | IntuneMDM-Daemon | I | 11255 | ScriptOrchestrationLogger | Running management script. Domain: policy, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
135+
2024-05-15 02:15:12:759 | IntuneMDM-Daemon | I | 11255 | ScriptOrchestrationLogger | Finished management script. Domain: policy, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
136+
2024-05-15 02:15:12:759 | IntuneMDM-Daemon | I | 11255 | AppInstallManager | Pre-install script succeeded PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
137+
2024-05-15 02:15:12:759 | IntuneMDM-Daemon | I | 11255 | AppInstallManager | Starting app installation for mac app policy. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, AppType: PKG, BundleID: au.csiro.dialog
138+
2024-05-15 02:15:12:759 | IntuneMDM-Daemon | I | 11255 | AppBinaryDownloader | Start app content info metadata download PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, BundleID: au.csiro.dialog
139+
2024-05-15 02:15:12:759 | IntuneMDM-Daemon | I | 11255 | SidecarService | Getting mac app content info from GW PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding
140+
2024-05-15 02:15:13:230 | IntuneMDM-Daemon | I | 11258 | AppBinaryDownloader | Successfully fetched app content info response from GW. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, BundleID: au.csiro.dialog
141+
2024-05-15 02:15:13:230 | IntuneMDM-Daemon | I | 11258 | AppBinaryDownloader | Starting app binary download for mac app policy. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, Size: 11132265.0
142+
2024-05-15 02:15:13:246 | IntuneMDM-Daemon | I | 11258 | AppBinaryDownloader | Attempt #1 out of 3 to download app binary PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, BundleID: au.csiro.dialog
143+
2024-05-15 02:15:15:147 | IntuneMDM-Daemon | I | 11248 | AppBinaryDownloader | Successfully downloaded app binary content. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, BundleID: au.csiro.dialog
144+
2024-05-15 02:15:15:147 | IntuneMDM-Daemon | I | 11248 | AppInstallManager | Starting app binary decryption for mac app policy. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, AppType: PKG, BundleID: au.csiro.dialog
145+
2024-05-15 02:15:15:200 | IntuneMDM-Daemon | I | 11248 | AppInstallManager | Install required for app PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, AppType: PKG, BundleID: au.csiro.dialog
146+
2024-05-15 02:15:15:200 | IntuneMDM-Daemon | I | 11248 | PkgInstaller | Starting PKG app installation PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, BundleID: au.csiro.dialog, AppName: Swift Dialog Onboarding
147+
2024-05-15 02:15:15:200 | IntuneMDM-Daemon | I | 11248 | ScriptOrchestrationLogger | Running system script. Domain: apps, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
148+
2024-05-15 02:15:17:541 | IntuneMDM-Daemon | I | 11248 | ScriptOrchestrationLogger | Finished system script. Domain: apps, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
149+
2024-05-15 02:15:17:541 | IntuneMDM-Daemon | I | 11248 | PkgInstaller | Successful PKG installation - installer completed with success status PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, BundleID: au.csiro.dialog, AppName: Swift Dialog Onboarding
150+
2024-05-15 02:15:17:542 | IntuneMDM-Daemon | I | 11248 | AppInstallManager | Post-install script detected. Executing script. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
151+
2024-05-15 02:15:17:542 | IntuneMDM-Daemon | I | 11248 | ScriptOrchestrationLogger | Running management script. Domain: policy, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
152+
2024-05-15 02:15:17:549 | IntuneMDM-Daemon | I | 11250 | AppInstallManager | App policy file cleanup successful. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding
153+
2024-05-15 02:15:17:549 | IntuneMDM-Daemon | I | 11257 | AppInstallManager | App policy file cleanup successful. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding
154+
2024-05-15 10:25:49:533 | IntuneMDM-Daemon | I | 11248 | ScriptOrchestrationLogger | Finished management script. Domain: policy, User: root, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
155+
2024-05-15 10:25:49:534 | IntuneMDM-Daemon | I | 11248 | AppInstallManager | Post-install script succeeded. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
156+
2024-05-15 10:25:49:534 | IntuneMDM-Daemon | I | 11248 | AppInstallManager | Successfully installed all apps PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, AppName: Swift Dialog Onboarding, ComplianceState: Installed, EnforcementState: Success, Product Version (BundleID of primary app): 2.3.2, Primary BundleID: au.csiro.dialog
157+
2024-05-15 10:25:49:534 | IntuneMDM-Daemon | I | 11248 | AppPolicyHandler | Handling app policy finished. PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, Primary BundleID: au.csiro.dialog, IgnoreVersion: true, Count: 1, AppType: PKG, App Policy Intent: RequiredInstall
158+
2024-05-15 10:25:49:534 | IntuneMDM-Daemon | I | 11248 | ExecutionClock | Measurement: Policy Identifier: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, Type: macAppInstall, Duration: 636.8304209709167
159+
2024-05-15 10:25:49:537 | IntuneMDM-Daemon | I | 31568 | AppResultStateChangeManager | This policy has never been executed on this device before the current check-in PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
160+
2024-05-15 10:25:49:539 | IntuneMDM-Daemon | I | 31568 | AppResultStateChangeManager | Successfully cached new app policy state change record PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83, PolicyResult: ["ResultCreatedTimeUTC": 2024-05-15T09:15:17Z, "Intent": 3, "EnforcementStateMessage": {
161+
}, "PolicyId": 0b6e87b5-2e4b-4350-b551-bfb99d114c83, "ApplicationName": Swift Dialog Onboarding]
162+
2024-05-15 10:25:49:539 | IntuneMDM-Daemon | I | 31568 | AppStateChangePersistence | Fetch app policy state change records PolicyID: [Optional("05088685-1fe8-4107-aaec-a41d4f934a14"), Optional("0b6e87b5-2e4b-4350-b551-bfb99d114c83")]
163+
2024-05-15 10:25:49:539 | IntuneMDM-Daemon | I | 31568 | AppPolicyResultsReporter | Create state change report for app policies PolicyType: macAppInstall, Count: 1, PolicyID: 0b6e87b5-2e4b-4350-b551-bfb99d114c83
164+
2024-05-15 10:25:49:539 | IntuneMDM-Daemon | I | 31568 | AppPolicyResultsReporter | Number of app policies executed PolicyType: macAppInstall, Count: 2, PolicyID: 05088685-1fe8-4107-aaec-a41d4f934a14, 0b6e87b5-2e4b-4350-b551-bfb99d114c83
165+
2024-05-15 10:25:49:539 | IntuneMDM-Daemon | I | 31568 | SyncActivityTracer | Reporting results Context: mac app policies, Count: 1, PolicyID: ["0b6e87b5-2e4b-4350-b551-bfb99d114c83"]
166+
```

0 commit comments

Comments
 (0)