Install pkg in user context

anniwayy
New Contributor III

We have an issue with Polycom RPD PKG 3.9, since it has to install in user context and not as root. User does not need admin permissions since it will install into ~/Applications. Anyone installed a package in user context already and has some idea on how to go about it?

thanks
anniwayy

4 REPLIES 4

AVmcclint
Honored Contributor

You could put the package in a .dmg that places the .pkg in /tmp, then use a script to run (set as AFTER) as the current user to install the pkg. Something like this:

#!/bin/bash
currentuser=`stat -f "%Su" /dev/console`
sudo -u $currentuser installer -pkg  /tmp/Polycomblahblah.pkg -allowUntrusted -target /

You may need to experiment with it to make sure that particular package will run like this.

thoule
Valued Contributor II

Running anything as a user instead of root is a VFAQ here. In your case, there's a couple ways to do it. If I had this task, I would do it this way.

1- create a script to run the installer and save it as /usr/local/anniwayy/installPolycom.sh

#!/bin/sh
#run the installer
installer -pkg /usr/local/anniwayy/PolycomRPD.pkg -target /
#remove the launchAgent so it won't run again
rm -f /Library/LaunchAgents/edu.anniwayy.installPolycom.plist
#remove the script to clean up
rm -rf  /usr/local/anniwayy/PolycomRPD.pkg
#remove the package
rm -f /usr/local/anniwayy/installPolycom.sh

2- create a LaunchAGENT to run the installer in /Library/LaunchAgents/edu.anniwayy.installPolycom.plist

<?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>Label</key>
        <string>edu.yourschool.anniwayy</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/anniwayy/installPolycom.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
</dict>
</plist>

3- Set the permissions right.

chmod +x /usr/local/anniwayy/installPolycom.sh
chown root:wheel  /Library/LaunchAgents/edu.anniwayy.installPolycom.plist
chmod 644 /Library/LaunchAgents/edu.anniwayy.installPolycom.plist

4- Put those three items into a package with composer. Then the next user that logs into the computer will have Polycomm installed.

Nix4Life
Valued Contributor

Use outset

1.Place script in login-once/login-every folder
2.Done

alexjdale
Valued Contributor III

Does anyone know why, no matter what package I supply (even one I created that does nothing and does not require root or admin), the installer command tells me I have to be running as root? I don't see how these instructions would work unless I am missing something here.