-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake-installer-pkg.sh
executable file
·58 lines (49 loc) · 1.93 KB
/
make-installer-pkg.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
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
#!/bin/sh
# make-installer-pkg.sh
# Munki Conditions Package
# Script for for creating an installer package with Munki Conditions.
# Written by Gerrit DeWitt (gdewitt@gsu.edu)
# 2015-06-15 (MEC), 2015-08-11 (MEC), 2016-01-05 (MEC), 2016-06-17.
# Copyright Georgia State University.
# This script uses publicly-documented methods known to those skilled in the art.
# References: See top level Read Me.
declare -x PATH="/usr/bin:/bin:/usr/sbin:/sbin"
# MARK: VARIABLES
# Control variable:
declare -i CLEANUP_WHEN_DONE=0
# Variables for package:
declare -x THIS_DIR=$(dirname "$0")
declare -x PACKAGE_IDENTIFIER="edu.gsu.munki.conditions"
declare -x PACKAGE_ROOT_DIR="$THIS_DIR/package-root"
#declare -x PACKAGE_SCRIPTS_DIR="$THIS_DIR/mec-package-scripts"
# MARK: build_package()
# Builds the component pkg.
function build_package(){
# Set permisions on package scripts dir:
#chmod -R 0755 "$PACKAGE_SCRIPTS_DIR" && echo "Set permissions on package scripts directory."
# Set permisions on package root:
chmod -R 0750 "$PACKAGE_ROOT_DIR" && echo "Set permissions on package root."
# Remove ._ files from package root:
find "$PACKAGE_ROOT_DIR" -name ._* -exec rm {} \;
# Remove .DS_Store files from package root:
find "$PACKAGE_ROOT_DIR" -name .DS_Store -exec rm {} \;
# Build MEC package:
pkgbuild --root "$PACKAGE_ROOT_DIR" --identifier "$PACKAGE_IDENTIFIER" --version "$PACKAGE_VERSION" "$PACKAGE_PATH" && echo "Built package."
if [ ! -f "$PACKAGE_PATH" ]; then
echo "Error: Failed to build package."
exit 1
fi
}
# MARK: pre_cleanup()
# Sets up packaging environment.
function pre_cleanup(){
if [ -f "$PACKAGE_PATH" ]; then
rm "$PACKAGE_PATH" && echo "Removed $PACKAGE_PATH."
fi
}
# MARK: main()
echo "Enter a version number (for example YYYY.MM like 2016.07):"
read PACKAGE_VERSION
declare -x PACKAGE_PATH="$THIS_DIR/Munki_Conditions-$PACKAGE_VERSION.pkg"
pre_cleanup
build_package