I've been trying to repackage an installerI was trying to cut down on some code on a post install script by utilizing functions. When I try to run the installer command and target $3, it's not actually targeting /. Rather it is an empty value which means the installer never launches. However, if I run the same installer command outside of a function, it targets $3 and correctly installs to /.
If I run the script with bash set x, I can see the following line in console when using the installer command targeting $3 in a function:
/usr/sbin/installer -dumplog -verbose -pkg '/Volumes/path/to/installer.pkg' -target '' -allowUntrusted
Outside of a function, installer command targeting $3 results in:
/usr/sbin/installer -dumplog -verbose -pkg '/Volumes/path/to/installer.pkg' -target / -allowUntrusted
If I use the installer command and target / instead of $3, the command will also work within a function, but I know that's not the proper way to do things.
It's been a long day and this is probably an easy one. I'm guessing it has to do with certain variables not being passed to a bash function. What am I missing here?
Relevant portion of the script:
#!/bin/bash
#Working directory for script to reference resources
install_dir=`dirname $0`
# Determine OS version
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
#Variables for ScanSnap installer
ScanSnapDMG="ScanSnap.dmg"
ScanSnapDMGVolume="/Volumes/ScanSnap"
ScanSnapInstaller="ScanSnap Manager.pkg"
ScanSnap () {
/usr/bin/hdiutil attach -nobrowse -readonly $install_dir/"$ScanSnapDMG"
/usr/sbin/installer -dumplog -verbose -pkg "$ScanSnapDMGVolume/$ScanSnapInstaller" -target $3 -allowUntrusted
/bin/sleep 10
/usr/bin/hdiutil detach "$ScanSnapDMGVolume"
/usr/bin/killall "ScanSnap Manager"
}
if [[ ${osvers} -le 7 ]]; then
ScanSnap
fi
exit 0
EDIT: For clarification, I'm not testing in the JSS yet. I'm only testing in 10.9.5 and creating the package in Packages.