Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix installer postflight #949

Merged
merged 1 commit into from Feb 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions app/views/install/install_script.php
Expand Up @@ -62,7 +62,7 @@ function usage {

# Set munkireport preference
function setpref {
PREF_CMDS=( "${PREF_CMDS[@]}" "defaults write ${PREFPATH} ${1} \"${2}\"" )
PREF_CMDS=( "${PREF_CMDS[@]}" "defaults write \"\${TARGET}\"${PREFPATH} ${1} \"${2}\"" )
}

# Set munkireport reportitem preference
Expand All @@ -72,7 +72,7 @@ function setreportpref {

# Reset reportitems
function resetreportpref {
PREF_CMDS=( "${PREF_CMDS[@]}" "defaults write ${PREFPATH} ReportItems -dict" )
PREF_CMDS=( "${PREF_CMDS[@]}" "defaults write \"\${TARGET}\"${PREFPATH} ReportItems -dict" )
}

while getopts b:m:p:r:c:v:i:nh flag; do
Expand Down Expand Up @@ -102,7 +102,7 @@ function resetreportpref {
INSTALLROOT="$INSTALLTEMP"/install_root
MUNKIPATH="$INSTALLROOT"/usr/local/munki/
TARGET_VOLUME='$3'
PREFPATH="${TARGET_VOLUME}/Library/Preferences/MunkiReport"
PREFPATH="/Library/Preferences/MunkiReport"
PREFLIGHT=0
BUILDPKG=1

Expand Down Expand Up @@ -245,15 +245,19 @@ function resetreportpref {

# Add Preference setting commands to postinstall
echo "#!/bin/bash" > $SCRIPTDIR/postinstall
cat >>$SCRIPTDIR/postinstall <<EOF
if [[ "\$3" == "/" ]]; then
TARGET=""
else
TARGET="\$3"
fi

# Create prefpath
PREFDIR=$(dirname ${PREFPATH})
echo "mkdir -p '${PREFDIR}'" >> $SCRIPTDIR/postinstall
EOF

for i in "${PREF_CMDS[@]}";
do echo $i >> $SCRIPTDIR/postinstall
done
echo "defaults write ${PREFPATH} Version ${VERSIONLONG}" >> $SCRIPTDIR/postinstall
echo "defaults write \"\${TARGET}\"${PREFPATH} Version ${VERSIONLONG}" >> $SCRIPTDIR/postinstall
chmod +x $SCRIPTDIR/postinstall


Expand Down