forked from SimpleMDM/munki-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-autopkg.sh
executable file
·29 lines (24 loc) · 1.2 KB
/
patch-autopkg.sh
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
#!/usr/bin/env bash
set -eu
# This script installs and patches autopkg 2.2 with unreleased changes needed to work with the SimpleMDM Repo Plugin
# The changes are derived from this commit:
# https://github.com/autopkg/autopkg/commit/af858c033643089b8ecbccf0a8ad691d4c28a289
if [ "$(id -u)" != 0 ]; then
echo "Error: Run this as the root user" >&2
exit 1
fi
if ! which -s /usr/local/bin/autopkg; then
release_path="https://github.com/autopkg/autopkg/releases/download/v2.2/autopkg-2.2.pkg"
pkg_name=$(basename $release_path)
pkg_tmp_path="/tmp/$pkg_name"
echo "Downloading and installing $pkg_name" >&2
curl -L -o "$pkg_tmp_path" $release_path;
installer -pkg "$pkg_tmp_path" -target /
rm "$pkg_tmp_path"
fi
autopkg_repo_path="/tmp/autopkg"
git clone https://github.com/autopkg/autopkg.git "$autopkg_repo_path"
cp -v "${autopkg_repo_path}/Code/autopkglib/MunkiImporter.py" /Library/AutoPkg/autopkglib/MunkiImporter.py
cp -v "${autopkg_repo_path}/Code/autopkglib/munkirepolibs/AutoPkgLib.py" /Library/AutoPkg/autopkglib/munkirepolibs/AutoPkgLib.py
cp -v "${autopkg_repo_path}/Code/autopkglib/munkirepolibs/MunkiLib.py" /Library/AutoPkg/autopkglib/munkirepolibs/MunkiLib.py
rm -rf "$autopkg_repo_path"