-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocker-Universal.pkg.recipe
106 lines (91 loc) · 4.2 KB
/
Docker-Universal.pkg.recipe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
Comment: |
Current versions of Docker Desktop may not install correctly in unattented environments.
Due to recent changes to Docker, the postinstall will check for the logged_in_user
and may not install correctly if there is no user logged in.
Description: Downloads the latest versions of Docker (arm and intel) and creates a package.
Identifier: com.github.smithjw.pkg.Docker-Universal
ParentRecipe: com.github.smithjw.download.Docker-Universal
MinimumVersion: '2.3'
Input:
NAME: Docker
Process:
- Processor: PkgRootCreator
Arguments:
pkgroot: '%RECIPE_CACHE_DIR%/payload'
pkgdirs:
pkgroot: '0775'
scripts: '0775'
- Processor: PlistReader
Arguments:
info_path: '%RECIPE_CACHE_DIR%/downloads/Docker-arm64.dmg/Docker.app/Contents/Info.plist'
plist_keys:
CFBundleShortVersionString: version
CFBundleIdentifier: bundleid
CFBundleName: app_name
- Processor: Copier
Arguments:
source_path: '%RECIPE_CACHE_DIR%/downloads/Docker-arm64.dmg'
destination_path: '%RECIPE_CACHE_DIR%/payload/scripts/Docker-arm64-%version%.dmg'
- Processor: Copier
Arguments:
source_path: '%RECIPE_CACHE_DIR%/downloads/Docker-x86_64.dmg'
destination_path: '%RECIPE_CACHE_DIR%/payload/scripts/Docker-x86_64-%version%.dmg'
- Processor: FileCreator
Arguments:
file_path: '%RECIPE_CACHE_DIR%/payload/scripts/postinstall'
file_mode: '0755'
file_content: |
#!/bin/bash
# https://forums.docker.com/t/feature-request-cli-tool-for-automated-installation/18334/4
# https://github.com/autopkg/chilcote-recipes/blob/master/Docker/Docker.munki.recipe
# https://github.com/docker/for-mac/issues/2359
# https://macadmins.slack.com/archives/C056155B4/p1716206699338559
# https://macadmins.slack.com/archives/C056155B4/p1717624187018149
logged_in_user=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
echo "logged_in_user: $logged_in_user"
docker_daemons=(
"com.docker.socket"
"com.docker.vmnetd"
)
for daemon in "${docker_daemons[@]}"; do
if /bin/launchctl print "system/${daemon}" >/dev/null 2>&1; then
echo "bootout: ${daemon}"
/bin/launchctl bootout "system/${daemon}"
fi
done
if [[ $( /usr/bin/arch ) = arm64* ]]; then
echo "Attaching Docker-arm64-%version%.dmg"
/usr/bin/hdiutil attach "Docker-arm64-%version%.dmg" -mountpoint "/Volumes/Docker-%version%" -nobrowse
else
echo "Attaching Docker-x86_64-%version%.dmg"
/usr/bin/hdiutil attach "Docker-x86_64-%version%.dmg" -mountpoint "/Volumes/Docker-%version%" -nobrowse
fi
if [[ -z "$logged_in_user" ]] || [[ "$logged_in_user" =~ (loginwindow|_mbsetupuser|root) ]]; then
echo "User not logged in, running: /Volumes/Docker-%version%/Docker.app/Contents/MacOS/install --accept-license"
"/Volumes/Docker-%version%/Docker.app/Contents/MacOS/install" --accept-license
else
echo "User logged in, running:"
echo " - '/Volumes/Docker-%version%/Docker.app/Contents/MacOS/install config --user ${logged_in_user}'"
"/Volumes/Docker-%version%/Docker.app/Contents/MacOS/install" config --user "${logged_in_user}"
echo " - '/Volumes/Docker-%version%/Docker.app/Contents/MacOS/install --accept-license --user ${logged_in_user}'"
"/Volumes/Docker-%version%/Docker.app/Contents/MacOS/install" --accept-license --user "${logged_in_user}"
fi
echo "Detatching /Volumes/Docker-%version%"
/usr/bin/hdiutil detach "/Volumes/Docker-%version%"
exit 0
- Processor: PkgCreator
Arguments:
pkg_request:
id: '%bundleid%'
options: purge_ds_store
pkgdir: '%RECIPE_CACHE_DIR%'
pkgname: '%NAME%_Universal-%version%'
pkgroot: '%RECIPE_CACHE_DIR%/payload/pkgroot'
scripts: '%RECIPE_CACHE_DIR%/payload/scripts'
version: '%version%'
- Processor: com.github.smithjw.processors/FriendlyPathDeleter
Arguments:
fail_deleter_silently: true
path_list:
- '%RECIPE_CACHE_DIR%/payload'