autopkginstall
Summary: automate the installation of .pkg or .mpkg files if put into a certain folder
In response to http://apple.stackexchange.com/questions/113489/unattended-installation-of-pkg-file, here is a script to automate the installation of .pkg and/or .mpkg files.
Installation
com.tjluoma.AutoInstallPKG.plist
file and change /Users/luomat/Action/AutoInstallPKG
to the full path to whatever directory that you want to monitor for new .pkg or .mpkg files
1) You must edit the <key>QueueDirectories</key>
<array>
<string>/Users/luomat/Action/AutoInstallPKG</string>
</array>
com.tjluoma.AutoInstallPKG.plist
move it to ~/Library/LaunchAgents/com.tjluoma.AutoInstallPKG.plist
2) After editing autopkginstall.sh
to somewhere in your $PATH such as /usr/local/bin/autopkginstall.sh
3) Install autopkginstall.sh
is executable:
4) Make sure that chmod 755 `which autopkginstall.sh`
/etc/sudoers
5) In order for installations to run unattended, you must add this line to %admin ALL=NOPASSWD: /usr/sbin/installer
(See man visudo
for more information on editing the sudoers file. BBEdit users should check out bbwait to use BBEdit to edit the sudoers file.)
Note that this change introduces a minor security concern in that any administrator account on the local Mac which is a member of the admin
group will be able to install pkg and mpkg files without having to enter their password.
terminal-notifier (Optional)
6) InstallIf found in $PATH, terminal-notifier
will be used to tell the user when packages are installed using this script.
Troubleshooting
Error messages will be saved to /tmp/AutoInstallPKG.errors.log
Other informational messages may be saved to /tmp/AutoInstallPKG.log
If you do not want to use /tmp/ for those files, edit the com.tjluoma.AutoInstallPKG.plist
file accordingly.
Warranty
Absolutely None. Zero. Zilch. Nada.
If the laws where you live do not allow for me to deny any responsibility for this, then you are not allowed to use it.
(That being said, I'm using this myself and haven't have any problems. YMMV. Use at your own risk. If it breaks, you get to keep both pieces.)