<commit_before>#!/bin/bash

fname="MunkiScripts"
version="$2"
BASEURL="$1"
CATALOG="testing"
EXTENSION=".plist"

if [[ ( -z "$version" ) || ( -z "$BASEURL" ) ]]; then
    echo "Usage: $0 baseurl version"
    exit 1
fi

dmg_fname="$fname-$version.dmg"

tmpdir=`mktemp -d -t munkiscripts`
tmproot="$tmpdir/munkiscripts"
mkdir "$tmproot"

printf "\nCopying files\n"
for i in preflight postflight report_broken_client; do
	sed "s#REPLACE_BASEURL#${BASEURL}#" $i > "${tmproot}/${i}";
done

printf "\nCreating image\n"
hdiutil create -srcfolder "$tmproot" -ov "$dmg_fname"

md5_preflight=`md5 ${tmproot}/preflight | awk '{print $NF}'`
md5_postflight=`md5 ${tmproot}/postflight | awk '{print $NF}'`
md5_report_broken_client=`md5 ${tmproot}/report_broken_client | awk '{print $NF}'`

printf "\nCleaning up\n"
rm -rf "$tmpdir"

printf "\nGenerating munki info file\n"
sha256_dmg=`shasum -a 256 "$dmg_fname" | awk '{print $1}'`

cat > "${fname-}-${version}${EXTENSION}" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>autoremove</key>
	<false/>
	<key>catalogs</key>
	<array>
		<string>${CATALOG}</string>
	</array>
	<key>forced_install</key>
	<true/>
	<key>installer_item_hash</key>
	<string>${sha256_dmg}</string>
	<key>installer_item_location</key>
	<string>$dmg_fname</string>
	<key>installer_item_size</key>
	<integer>15</integer>
	<key>installer_type</key>
	<string>copy_from_dmg</string>
	<key>installs</key>
	<array>
		<dict>
			<key>md5checksum</key>
			<string>${md5_preflight}</string>
			<key>path</key>
			<string>/usr/local/munki/preflight</string>
			<key>type</key>
			<string>file</string>
		</dict>
		<dict>
			<key>md5checksum</key>
			<string>${md5_postflight}</string><commit_msg>FIXED Added unattended_install to MunkiScripts-X.Y.plist. (http://code.google.com/p/munkireport-php/issues/detail?id=3)<commit_after>#!/bin/bash

fname="MunkiScripts"
version="$2"
BASEURL="$1"
CATALOG="testing"
EXTENSION=".plist"

if [[ ( -z "$version" ) || ( -z "$BASEURL" ) ]]; then
    echo "Usage: $0 baseurl version"
    exit 1
fi

dmg_fname="$fname-$version.dmg"

tmpdir=`mktemp -d -t munkiscripts`
tmproot="$tmpdir/munkiscripts"
mkdir "$tmproot"

printf "\nCopying files\n"
for i in preflight postflight report_broken_client; do
	sed "s#REPLACE_BASEURL#${BASEURL}#" $i > "${tmproot}/${i}";
done

printf "\nCreating image\n"
hdiutil create -srcfolder "$tmproot" -ov "$dmg_fname"

md5_preflight=`md5 ${tmproot}/preflight | awk '{print $NF}'`
md5_postflight=`md5 ${tmproot}/postflight | awk '{print $NF}'`
md5_report_broken_client=`md5 ${tmproot}/report_broken_client | awk '{print $NF}'`

printf "\nCleaning up\n"
rm -rf "$tmpdir"

printf "\nGenerating munki info file\n"
sha256_dmg=`shasum -a 256 "$dmg_fname" | awk '{print $1}'`

cat > "${fname-}-${version}${EXTENSION}" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>autoremove</key>
	<false/>
	<key>catalogs</key>
	<array>
		<string>${CATALOG}</string>
	</array>
	<key>forced_install</key>
	<true/>
	<key>unattended_install</key>
	<true/>
	<key>installer_item_hash</key>
	<string>${sha256_dmg}</string>
	<key>installer_item_location</key>
	<string>$dmg_fname</string>
	<key>installer_item_size</key>
	<integer>15</integer>
	<key>installer_type</key>
	<string>copy_from_dmg</string>
	<key>installs</key>
	<array>
		<dict>
			<key>md5checksum</key>
			<string>${md5_preflight}</string>
			<key>path</key>
			<string>/usr/local/munki/preflight</string>
			<key>type</key>
			<string>file</string>
		</dict>
		<dict>
			<key>md5checksum</key>
			<string>${md5_postflight}</string>
{'fraction_non_alphanumeric': 0.20284510010537407, 'fraction_numerical': 0.018703898840885143, 'mean_word_length': 5.33889816360601, 'pattern_counts': {'":': 0, '<': 118, '<?xml version=': 2, '>': 118, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6857015', 'n_tokens_mistral': 1710, 'n_tokens_neox': 1575, 'n_words': 266}